Repository navigation
Clean up old generations that are building up in active long-running workflows - #415
Thom Chiovoloni (thomcc-work) wants to merge 9 commits into
Conversation
4c616aa to
b91feb6
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The unreleased provider dependency and deletion of active-workflow history require human review and upgrade/replay validation before landing.
1 open finding
What changed in this PR
Adds age-based cleanup of historical execution generations, including those belonging to active workflows, while preserving current and running executions.
Changes:
- Adds bounded pruning with deadlines and failed-page recovery.
- Makes execution-history inspection consistent during concurrent pruning.
- Updates dependencies, readiness checks, tests, and retention documentation.
| File | Description |
|---|---|
| USER_GUIDE.md | Documents pruning behavior and upgrade considerations. |
| tests/e2e/sql/89_execution_pruning.sql | Tests root, nested, and satellite workflow pruning. |
| src/worker.rs | Implements bounded pruning and regression tests. |
| src/types.rs | Updates retention documentation. |
| src/monitoring.rs | Reads execution details in one snapshot. |
| src/lib.rs | Updates readiness version and retention descriptions. |
| scripts/test-e2e-local.sh | Routes pruning tests to reconciliation configuration. |
| scripts/test-e2e-docker.sh | Skips the configuration-dependent pruning test. |
| docs/upgrade-testing.md | Documents migrations and release prerequisites. |
| Cargo.toml | Updates runtime and provider dependencies. |
| Cargo.lock | Records updated dependency resolutions. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
af3dcc8 to
e53da8d
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The unreleased provider dependency adds startup backfill and destructive history pruning alongside runtime shutdown changes, requiring previous-binary upgrade/replay and PostgreSQL shutdown validation with the final dependency pair.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
Also: - Updated upgrade guidance for fully drained callers, malformed-history diagnostics, WAL/retention impact, and timestamp repair. - Documented that databases using earlier pre-release migrations won’t automatically receive revised function bodies. - Added a regression confirming protected generations advance the cursor without waiting on instance locks.
Compare snapshot inspection against the Client metadata API using tables created by the pinned provider's migrations and populated through provider operations. Document the existing migrated-schema coverage of pruning keys. Ref: #415 review finding 415-1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Explain that pruning holds candidate instance locks until commit and can briefly delay acknowledgements, particularly during the first post-backfill scans. Preserve the existing batch and timeout policies. Ref: #415 review finding 415-2 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Distinguish the provider's ^0.1.32 requirement from pg_durable's deliberate =0.1.32 pin. Record that the combined release with PR 429 needs later runtime changes and coordinated exact pins with replay validation. Ref: #415 review finding 415-3 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pin both runtime and provider to crates.io now that the provider ships the pruning API. Its 0027 and 0028 migrations are byte-identical to the last development pin, so stores initialized with that pin can proceed to the queue migrations without reinstalling pruning functions. Document the worker-queue index build and disabled notification triggers. Keep short polling and the existing connection minimum. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Summary
continue_as_newstarts a fresh execution for replay, but previously every older generation stayed in the database until the workflow itself was removed. Reconciliation now prunes completed, non-current generations and their history once they are older thanpg_durable.retention_days, even while the workflow is still running.This PR pins both
duroxideandduroxide-pgto the0.2.0crates.io releases. The provider release includes microsoft/duroxide-pg#32; no git dependency or local override is needed. The HTTP policies in #429 are separate.Retention and inspection
dfmetadata, and current results. It does not cap a single execution’s history or reclaim separate child instances.pg_durable.reconcile_interval = 0disables pruning.df.instance_executions()reads execution details and event counts in one snapshot, so a concurrent prune cannot turn a disappearing historical row into a lookup error.Upgrade
Drain all old provider callers and transactions, including external clients and deletion jobs. The new worker applies provider migrations before publishing readiness; pruning requires no
ALTER EXTENSION UPDATE. Backfilling completion timestamps can generate substantial WAL and make old generations eligible on the first scan. Acknowledgements for affected workflows can briefly wait on pruning locks.The released pruning migrations (
0027/0028) are byte-identical to the last development pin (79870890). The release also installs the worker-queue index (0029) and disabled notification triggers (0030); pg_durable continues to use short polling. See the upgrade notes for index locking, missing or malformed history, and databases initialized with earlier draft migrations.Validation
Tested this branch independently of #429 using the released crates and the shared PostgreSQL test lock on PG17:
🐾 Generated with PAW