Skip to content

Take over a team reminder left claimed - #149

Closed
wayx112 wants to merge 1 commit into
Team6083:mainfrom
wayx112:fix/reminder-stale-claim
Closed

wayx112 wants to merge 1 commit into
Team6083:mainfrom
wayx112:fix/reminder-stale-claim

Conversation

@wayx112

@wayx112 wayx112 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Summary

A team reminder run is claimed by inserting its ReminderDelivery row as claimed, and a failed send releases it. But if the process dies between the claim and the end of the run (serverless timeout, restart, out of memory), nothing releases it: the row stays claimed, the unique index makes every later call skip the rule, and no reminder goes out that day with nothing recording why (#146).

claimRun
  insert row as claimed                       → this call owns the run
  row exists and is claimed for > 10 min      → take it over (one conditional write), log a warning
  row exists otherwise (fresh claim, sent, …) → skip
  • Stale: 10 minutes (STALE_CLAIM_MS), longer than one run takes. The claim time is the row's sentAt, now set from the run's now.
  • One taker: the takeover is updateMany on result: "claimed" and sentAt < now − 10 min, so of two calls only one gets the run.
  • Finished runs: a sent or nobodyMissing row still blocks the day, however old.

Closes #146.

Evidence

Test Files  25 passed (25)
     Tests  335 passed (335)

New tests: a run claimed a minute ago is skipped, one claimed 11 minutes ago is taken over and sent, and a sent run is never taken over.

tsc --noEmit and ESLint on the changed files pass.

Merge danger

Door: two-way. One function; no schema change.

Blast radius: team reminders only.

🤖 Generated with Claude Code

A run is claimed by inserting its delivery row as claimed and released if sending fails, but if the process died
between the claim and the end of the run (timeout, restart, out of memory) nothing released it, and the rule was
skipped for the rest of the day with nothing recording why. A row still claimed after 10 minutes, longer than a run
takes, is now taken over by the next call in one conditional write, so only one call gets it; a sent or
nobodyMissing row still blocks the day.

Closes Team6083#146

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wayx112 added a commit to wayx112/OverHours that referenced this pull request Nov 15, 2026
If the process died between claiming a run and finishing it (timeout, restart, out of memory), the row stayed
claimed and the rule was skipped for the rest of the day. A run still claimed after 10 minutes, longer than a run
takes, is now taken over by the next call in one conditional write. It counts as a failure and continues after the
parts already sent, so a run that keeps dying is given up like one that keeps failing, and a crash doesn't repeat
messages. A sent or nobodyMissing run still blocks the day.

This was Team6083#149, folded in here since both change claimRun.

Closes Team6083#146

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wayx112

wayx112 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #151: both changed claimRun, so they are fixed together there. A run abandoned while claimed is now taken over after 10 minutes as here, and also counts as a failure and continues after the parts already sent, so a crash doesn't repeat messages and a run that keeps dying is given up. #151 closes #146.

@wayx112 wayx112 closed this Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A team reminder left as claimed is never retried that day

1 participant