Repository navigation
Clean up old generations that are building up in active long-running workflows - #415
Thom Chiovoloni (thomcc-work) wants to merge 10 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
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>
…(still-running) workflows
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>
ed29478 to
2ed44a8
Compare
The runtime patch fixes a race between graceful and forced shutdown. Keep duroxide-pg at 0.2.0: it accepts the patched runtime, so the provider and its PostgreSQL migrations do not change. 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
duroxideto0.2.1andduroxide-pgto0.2.0from crates.io. The runtime patch fixes a race between graceful and forced shutdown without adding a PostgreSQL migration. 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 on PG17 independently of #429. The database checks used the shared PostgreSQL test lock.
duroxide0.2.1 andduroxide-pg0.2.0: 18 worker unit tests, both execution inspection and pruning E2Es, 6 shutdown checks, and 7 epoch/lifecycle checks passed. All 177 upgrade checks passed, including resuming workflows created by pg_durable v0.2.9 across binary-only and schema upgrades. The locked build, formatting check, and strict Clippy also passed.🐾 Generated with PAW