Skip to content

feat(task-queue): scheduling handoff watermarks (revision 175) - #591

Closed
aivong-openhands wants to merge 1 commit into
task-queue/05-recoveryfrom
task-queue/06-watermarks
Closed

aivong-openhands wants to merge 1 commit into
task-queue/05-recoveryfrom
task-queue/06-watermarks

Conversation

@aivong-openhands

@aivong-openhands aivong-openhands commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Stack 6/7: OHE-3417 Track 1. Based on #590. Implements T1.8.

Why

Procrastinate has no record that a CronJob already ran an occurrence, and a single cutover instant drops a run that neither scheduler performed. Example: suspend at 05:59, a daily job due at 06:00, drain complete at 06:02. A cutover timestamp of 06:02 skips 06:00, though nothing ran it.

Change

Revision 175 adds scheduled_job_watermark: per job, the last occurrence known complete, its classification, and whether a later run supersedes an earlier one. TASK_QUEUE_DB_ROLE gets DML on it, no DDL.

Classification At or before the mark After
completed skip (skipped_watermark) run
skipped skip, deliberately run
missed / unknown run run
  • unknown runs because these jobs are safe to repeat: a duplicate is bounded, while a skip is silent loss. Since successfulJobsHistoryLimit truncates Job history, unknown will be the common case.
  • A skip also needs supersedes_earlier on the row and single_watermark on the job. That is declared per ScheduledJob, so a future occurrence-specific job does not inherit the assumption silently.
  • After an executed run the task advances the mark, forward only. The advance is advisory: if it fails, the run still succeeds and the occurrence may run again. That is the safe direction.
  • Operator CLI for cutover step 3: python -m server.task_queue.watermark record --job … --occurrence <ISO with offset> --classification … --by … and show. Operator records are authoritative, and a naive timestamp is rejected.

Tests


This PR was created by an AI agent (OpenHands) on behalf of the user.

@aivong-openhands can click here to continue refining the PR


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-3dceda5

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR contains migrations. Please synchronize before merging to prevent conflicts.

@github-actions github-actions Bot added the type: feat A new feature label Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  migrations/versions
  175_add_scheduled_job_watermark.py 29-30, 45
  server/task_queue
  jobs.py
  tasks.py
  watermark.py 205
Project Total  

This report was generated by python-coverage-comment-action

Procrastinate has no record of what a CronJob already ran, and a single
cutover instant drops the occurrence neither scheduler performed.
scheduled_job_watermark holds, per job, the last occurrence known to
have completed and how that was established.

- Each occurrence checks its job's watermark first: completed or skipped
  at or before the mark is skipped as skipped_watermark; missed, unknown
  and anything after the mark run. unknown runs because a duplicate of
  these jobs is bounded while a skip is silent loss.
- A skip also needs supersedes_earlier on the row and single_watermark
  on the job, declared per job so a future occurrence-specific job does
  not inherit the assumption.
- After an executed run the task advances the mark, forward only. The
  advance is advisory: if it fails the run still succeeds and the
  occurrence may run again, which is the safe direction.
- python -m server.task_queue.watermark record/show for the operator at
  cutover (T1.10.1 step 3); operator records are authoritative.
- Revision 175 grants TASK_QUEUE_DB_ROLE DML on the table, no DDL.

OHE-3417 (Track 1, T1.8)

Co-authored-by: openhands <openhands@all-hands.dev>
@aivong-openhands

Copy link
Copy Markdown
Contributor Author

Closing: superseded by the revised CronJob migration plan for OHE-3417 (rev 16). That plan replaces the single watermark table with a per-occurrence table. Revision 175 also now belongs to #599. The branch is kept for reference. Worth reusing in the new work, under a new migration number: the 'unknown means run' rule, the operator record/show CLI for seeding at cutover, and the drain-boundary tests (#19, #20, #22b).


This comment was posted by an AI agent (OpenHands) on behalf of @aivong-openhands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants