Skip to content

fix: claim reminders before delivery - #218

Open
QueryPlanner wants to merge 1 commit into
mainfrom
codex/claim-reminder-before-delivery
Open

QueryPlanner wants to merge 1 commit into
mainfrom
codex/claim-reminder-before-delivery

Conversation

@QueryPlanner

Copy link
Copy Markdown
Owner

What

Prevent a one-time or recurring reminder from running its delivery callback twice for the same scheduled occurrence.

Why

On November 14, one calorie reminder ran 19 times in nine minutes while SQLite reported a full disk. Blacki tried to send the Telegram reminder before writing its next scheduled time. The write failed, so the next poll picked up the same occurrence.

How

  • Atomically update the exact pending occurrence before invoking its callback. A failed SQLite write or stale snapshot leaves the callback uncalled.
  • Advance recurring schedules strictly past the current occurrence and preserve the existing grace period for late reminders.
  • Treat delivery as at most once. A process exit between the database update and the callback can skip that occurrence.

Tests

  • Reproduced the duplicate callback with a real SQLite page quota for one-time and recurring reminders.
  • Verified recovery after SQLite could write, with one delivery and the correct next occurrence.
  • Ran Ruff format and lint checks, MyPy, and the full pytest suite. 2,886 passed, 1 skipped, 100% coverage.

- Save each occurrence before running its delivery callback.
- Guard against stale polls and advance past the current cron time.
- Reproduce full-database retries with real SQLite writes.
@QueryPlanner QueryPlanner mentioned this pull request Nov 14, 2026
3 of 4 tasks

This branch has not been deployed

No deployments
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.

1 participant