Skip to content

Commit 312c733

Browse files
dgeee13Debarati Ghatakhyperswitch-bot[bot]
authored
fix(core): add fix for stopping multiple event locking idempotent logs (#8034)
Co-authored-by: Debarati Ghatak <[email protected]> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent 8818a9b commit 312c733

File tree

4 files changed

+472
-5
lines changed

4 files changed

+472
-5
lines changed

crates/diesel_models/src/query/events.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ impl Event {
3232
.await
3333
}
3434

35+
pub async fn find_by_merchant_id_idempotent_event_id(
36+
conn: &PgPooledConn,
37+
merchant_id: &common_utils::id_type::MerchantId,
38+
idempotent_event_id: &str,
39+
) -> StorageResult<Self> {
40+
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
41+
conn,
42+
dsl::merchant_id
43+
.eq(merchant_id.to_owned())
44+
.and(dsl::idempotent_event_id.eq(idempotent_event_id.to_owned())),
45+
)
46+
.await
47+
}
48+
3549
pub async fn list_initial_attempts_by_merchant_id_primary_object_id(
3650
conn: &PgPooledConn,
3751
merchant_id: &common_utils::id_type::MerchantId,

crates/router/src/core/webhooks/outgoing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ pub(crate) async fn create_event_and_trigger_outgoing_webhook(
155155

156156
if (state
157157
.store
158-
.find_event_by_merchant_id_event_id(
158+
.find_event_by_merchant_id_idempotent_event_id(
159159
key_manager_state,
160160
&merchant_id,
161-
&event_id,
161+
&idempotent_event_id,
162162
merchant_context.get_merchant_key_store(),
163163
)
164164
.await)

0 commit comments

Comments
 (0)