forked from mtusi2026/mtusi2026lab7
Ограничить повторные уведомления и проверять восстановление в заданный срок
This commit is contained in:
+8
-2
@@ -210,9 +210,15 @@ def watchdog(db):
|
||||
).fetchall()
|
||||
for row in rows:
|
||||
retry(conn, row, "lease_expired")
|
||||
# Recreate a wakeup if its stream entry was lost: never recreate logical jobs.
|
||||
# This is a safety recheck for a lost wakeup, not a delivery retry.
|
||||
# A confirmed durable stream can legitimately have a backlog while the
|
||||
# worker is recovering. Republishing every 15s amplified that backlog:
|
||||
# 149 accepted uploads produced 2204 outbox rows in the PKI experiment.
|
||||
# Failed attempts and expired leases still enqueue their retry at once.
|
||||
recheck = integer("JOB_WAKEUP_RECHECK_SECONDS", 120, 30, 300)
|
||||
rows = conn.execute(
|
||||
"SELECT j.* FROM jobs j WHERE j.state='queued' AND j.next_at<=clock_timestamp() AND NOT EXISTS(SELECT 1 FROM outbox o WHERE o.job_id=j.id AND (o.published_at IS NULL OR o.published_at>clock_timestamp()-interval '15 seconds')) FOR UPDATE OF j SKIP LOCKED LIMIT 16"
|
||||
"SELECT j.* FROM jobs j WHERE j.state='queued' AND j.next_at<=clock_timestamp() AND NOT EXISTS(SELECT 1 FROM outbox o WHERE o.job_id=j.id AND (o.published_at IS NULL OR o.published_at>clock_timestamp()-(%s*interval '1 second'))) ORDER BY j.next_at,j.id FOR UPDATE OF j SKIP LOCKED LIMIT 16",
|
||||
(recheck,),
|
||||
).fetchall()
|
||||
for row in rows:
|
||||
enqueue(conn, row["id"])
|
||||
|
||||
Reference in New Issue
Block a user