feat(core): add redis lock during insertion of event in event table during initial attempt of outgoing webhook delivery #7579
feat(core): add redis lock during insertion of event in event table d…
5738c1f2
cookieg13
force pushed
from
882433c3
to
5738c1f2
10 days ago
Type of Change
Description
The current implementation of insertion of an event in
event
table does not handle the case where multiple requests with the same idempotent_event_id might be processed concurrently, leading to multiple unique constraint violation errors in the database.This was reported by a merchant who was facing high volumes of unique constraint violation errors.
NOTE: this unique constraint log error issue is only applicable for the
initial
attempt of outgoing webhook delivery, not for retry attemptsWhy does this happen?
idempotent_event_id
might reach the database at the same time.Solution (Using Redis Lock)
Before querying the database, acquire a lock in Redis for the given idempotent_event_id.
Only one process/thread will hold the lock, preventing others from inserting at the same time.
If a lock is acquired:
Additional Changes
Motivation and Context
How did you test it?
Checklist
cargo +nightly fmt --all
cargo clippy