Skip to content

Recover Dag processor work and expire inactive processors - #74791

Merged
ephraimbuddy merged 12 commits into
dag-processor-publication-apifrom
dag-processor-work-delivery
Nov 6, 2026
Merged

ephraimbuddy merged 12 commits into
dag-processor-publication-apifrom
dag-processor-work-delivery

Conversation

@ephraimbuddy

@ephraimbuddy ephraimbuddy commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Claim and acknowledge callbacks and priority parse requests through the Execution API, retaining them for recovery until acknowledged or their owner retires. Move inactive-bundle, warning, and expired-processor cleanup into bounded scheduler maintenance, and keep direct database consumers compatible with claimed work.

Layer 4 of the seven-part replacement for #74233, in GitHub native stack #74792. Depends on #74790. Base: dag-processor-publication-api.

GitHub's Files changed tab shows this layer. Compare this layer.

Merge order:

  1. FAB validation
  2. Source consistency
  3. Publication API
  4. Durable work delivery
  5. HTTP manager
  6. Complete processor API mode
  7. Helm and Compose deployment

Focused SQLite tests: 410 passed, 11 backend-only skips. PostgreSQL: 330 passed. The priority-claim race regression failed before the locking fix; the final related reruns passed 13 PostgreSQL cases and 10 SQLite cases (3 backend-only skips). Regular/manual static checks and the complete 151-revision migration round trip passed.


Was generative AI tooling used to co-author this PR?
  • Yes — Codex (GPT-6)

Generated-by: Codex (GPT-6) following the guidelines

@ephraimbuddy
ephraimbuddy force-pushed the dag-processor-work-delivery branch from 53dab83 to 1e44909 Compare October 28, 2026 20:16
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The re-run of the jobs stopped by EC2 Spot interruptions finished: attempt 2 passed.

@ephraimbuddy
ephraimbuddy force-pushed the dag-processor-work-delivery branch from 1e44909 to ed8e8b7 Compare October 29, 2026 16:55
@ephraimbuddy
ephraimbuddy force-pushed the dag-processor-work-delivery branch from ed8e8b7 to 7b53ef6 Compare October 30, 2026 15:40

@kaxil kaxil left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the earlier points all look addressed. Two small nits inline, neither blocking.

@ephraimbuddy
ephraimbuddy force-pushed the dag-processor-work-delivery branch from 7b53ef6 to 6eb02ca Compare November 5, 2026 11:44
@ephraimbuddy
ephraimbuddy force-pushed the dag-processor-work-delivery branch from 6eb02ca to 2d075fe Compare November 5, 2026 13:11
Expose bounded, replayable claims for callback and priority parsing requests through the Execution API. Keep ownership until acknowledgment or processor retirement, and let the scheduler clean stale metadata in bounded batches.
Lost responses and reparses during an active import must not consume later requests. Callback replay must preserve priority, and routine cleanup must remain safe on SQLite and avoid scanning completed Job history.
Legacy Dags whose files were removed must become stale after a 2.x upgrade even when migration 0082 assigns a non-null bundle name. Existing files must remain active when bundle names or directories change.
The upstream migration sequence has advanced, so claim migrations and their
regressions need the next available number. Claim receipts inherit Job
cleanup through their foreign key and must retain replay protection while
the Job remains alive.
Bundle discovery now returns source failure information alongside files.
The upgrade regression must use the discovered files to exercise legacy
Dag deactivation after migration 0082.
Inactive bundles must stop scheduling without waiting through multiple
cleanup intervals, and expired owners must not retain parse checkpoints
or leave callbacks outside normal database cleanup.

Callback context needs a versioned response schema, while heartbeat
thresholds must agree on when a processor can lose ownership. Regression
coverage must exercise the configured database backend as well as replay,
claim limits, inactive bundles, and interrupted cleanup.
Existing heartbeat settings must not prevent inactive bundles and retired
processor metadata from being cleaned up when API expiration is unsafe.

Distinct file paths must retain separate priority requests even when the
database collation ignores case or accents, so requesting one file does
not release another file's claim or lose the requested reparse.
Airflow's structlog bridge does not render stdlib `extra=` fields, so the
warning logged when scheduler maintenance expired an API Dag processor Job
carried only its message. Operators tracing a callback that ran twice
could not tell which Job or host was expired, or which timeout applied.

Maintenance also validated `job_heartbeat_timeout` on every run. That
timeout only applies to API Dag processor Jobs, and database-mode
deployments may legitimately set `[dag_processor] health_check_threshold`
above it, so each scheduler logged a configuration warning every cleanup
interval about an option the deployment never uses. The timeout is now
checked only when a live API Dag processor Job exists, and a test keeps
Job expiry batched, since nothing failed if that limit was dropped.

Before maintenance moved to the scheduler, every Dag processor loop
removed all warnings of stale Dags. Purging one batch per cleanup
interval left warnings of a bulk-deactivated bundle listed in the Dag
warnings API for many minutes, so they now drain in committed batches
like the Dag and publication-receipt steps.
A Dag processor numbers callback and priority claims independently. If
both kinds shared one claim record, a processor that had already claimed
callbacks at a higher sequence would see every priority claim as stale,
and priority reparses would never reach it. The claim body bounds cap how
many rows one request can lock, and the route's Job check covers a Job
that closes between token admission and the row lock. Nothing failed if
any of these was removed.

Some tests did not exercise this change. The takeover test passed without
the new heartbeat-timeout validation, whose guard the registration test
already covers, so it is dropped. The replaced legacy inventory test also
passed without this change, so the original from the publication API
change is restored. Tests of DagFileProcessorManager belong with the
manager tests, SQLite-only tests should declare their backend instead of
skipping themselves, and the lock-timeout test no longer names an
inactive bundle it does not use.
The parsing_cleanup_interval description read as if every Dag processor
Job is ended once it exceeds job_heartbeat_timeout. Only Jobs registered
through the Execution API carry a session and are expired, so a
database-mode operator could expect a hung processor to be ended when it
never is.

The stale Dag warning and publication receipt cleanups each capped their
key batches at 499, but only one said why: each two-column key takes two
bind parameters, and SQLite before 3.32 allows 999. Two copies of that
bound could drift apart and break cleanup on older SQLite.

The claim and acknowledgment routes took an untyped execution token,
while the other Dag processor routes refuse any other token type before
the handler runs. Main added migrations 0152 and 0153, so the
work-claims migration is now 0155.
Main added migration 0154 and the publication-state migration below this
one is now 0155, so the work-claims migration and its test move to 0156.
@ephraimbuddy
ephraimbuddy force-pushed the dag-processor-work-delivery branch from 2d075fe to 99e077a Compare November 6, 2026 09:07
@ephraimbuddy
ephraimbuddy merged commit f2edf56 into main Nov 6, 2026
282 of 302 checks passed
@ephraimbuddy
ephraimbuddy deleted the dag-processor-work-delivery branch November 6, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants