fix(cron): serialize delivery deduplication with terminal retention

This commit is contained in:
liuzikaii
2026-09-06 10:51:53 +08:00
committed by Teknium
parent 76af5ebf09
commit 5b2c417db8
2 changed files with 65 additions and 0 deletions
+3
View File
@@ -140,6 +140,9 @@ def enqueue(
) -> dict:
"""Persist one idempotent delivery request before the worker waits."""
with _transaction() as conn:
# Serialize the tombstone check and insert with retention in other
# processes, which can move a terminal delivery into the tombstone table.
conn.execute("BEGIN IMMEDIATE")
tombstone = conn.execute(
"SELECT terminal_status, finished_at FROM delivery_tombstones "
"WHERE execution_id=?",