fix(cmpp): honor UTC inbox retry leases

This commit is contained in:
hectorzhao
2026-08-20 17:50:00 +08:00
parent 0b63bcd74e
commit 53073461e9
5 changed files with 44 additions and 6 deletions
@@ -1086,10 +1086,10 @@ startInboundWorkflowWorker() {
FROM "CmppInboundSubmissionInbox"
WHERE (
status = 'pending'
AND "nextAttemptAt" <= NOW()
AND "nextAttemptAt" <= (NOW() AT TIME ZONE 'UTC')
) OR (
status = 'processing'
AND "lockedAt" <= NOW() - make_interval(secs => ${staleSeconds})
AND "lockedAt" <= (NOW() AT TIME ZONE 'UTC') - make_interval(secs => ${staleSeconds})
)
-- Priority applications enter the same durable Inbox, but are claimed first while
-- preserving FIFO within each class. This keeps the V5 priority contract effective
@@ -1101,9 +1101,9 @@ startInboundWorkflowWorker() {
UPDATE "CmppInboundSubmissionInbox" AS inbox
SET status = 'processing',
attempts = inbox.attempts + 1,
"lockedAt" = NOW(),
"lockedAt" = (NOW() AT TIME ZONE 'UTC'),
"lockedBy" = ${this.inboundWorkflowWorkerId},
"updatedAt" = NOW()
"updatedAt" = (NOW() AT TIME ZONE 'UTC')
FROM candidates
WHERE inbox.id = candidates.id
RETURNING inbox.id, inbox."requestKey", inbox."applicationId", inbox.attempts, inbox.payload