Skip to content

Commit a2fa701

Browse files
committed
fix: flooding postgres logs when checking for duplicate events
1 parent 8967cbd commit a2fa701

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ayon_server/events/eventstream.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ async def dispatch(
133133
payload = EXCLUDED.payload,
134134
updated_at = NOW()
135135
"""
136+
else:
137+
query += "ON CONFLICT (hash) DO NOTHING"
136138

137139
try:
138-
await Postgres.execute(
140+
res = await Postgres.execute(
139141
query,
140142
event.id,
141143
event.hash,
@@ -156,14 +158,15 @@ async def dispatch(
156158
) from e
157159

158160
except Postgres.UniqueViolationError as e:
159-
if reuse:
160-
raise ConstraintViolationException(
161-
"Unable to reuse the event. Another event depends on it",
162-
) from e
163161
raise ConstraintViolationException(
164-
"Event with same hash already exists",
162+
"Unable to reuse the event. Another event depends on it",
165163
) from e
166164

165+
if (not reuse) and res == "INSERT 0 0":
166+
raise ConstraintViolationException(
167+
"Event with the same hash already exists",
168+
)
169+
167170
depends_on = (
168171
str(event.depends_on).replace("-", "") if event.depends_on else None
169172
)

0 commit comments

Comments
 (0)