Repository navigation
Record completed_at for ContinuedAsNew executions - #32
Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The production data backfill and replacement of a critical acknowledgement function warrant the planned manual testing and human review.
Review effort: Balanced
Findings: None
What changed in this PR
Records completion timestamps for continued-as-new executions, enabling age-based pruning of older generations.
Changes:
- Updates acknowledgement logic and backfills recoverable timestamps.
- Adds regression coverage for migration and pruning behavior.
- Documents migration behavior and operational guidance.
| File | Description |
|---|---|
migrations/0024_continue_as_new_completed_at.sql |
Updates and backfills completion timestamps. |
migrations/0024_diff.md |
Documents the migration delta. |
migrations/README.md |
Adds upgrade and pruning guidance. |
src/migrations.rs |
Refreshes the migration embedding marker. |
tests/regression_tests.rs |
Tests fresh installs, upgrades, and pruning. |
CHANGELOG.md |
Records the fix under Unreleased. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
e7773b3 to
97d0ac4
Compare
There was a problem hiding this comment.
Heads-up from #44, now tracked in #46.
#44 also adds migration 0026 and replaces ack_orchestration_item. It adds an advisory lock, a token recheck and a row-count check, to fix the double processing in #29. This PR's 0024 rebuilds ack_orchestration_item from the 0020 body. If this PR merges after #44 as it is, it silently reverts that fix.
Whichever PR merges second needs to:
- renumber its migration;
- carry both changes in its copy of
ack_orchestration_item; - run
cargo test --test deadlocks --test orchestration_ack_lease_tests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rom age-filtered bulk deletion Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c89f754 to
3ed62ed
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Batched pruning and atomic deletion acquire instance locks in inconsistent orders, risking deadlocks during concurrent multi-instance operations that existing single-instance tests cannot expose.
1 open issue
2 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
The retention backfill and destructive-operation lock-order changes require PostgreSQL-backed upgrade, replay/pruning, and concurrency validation that was unavailable in this review.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
Precheck eligibility without changing scanned-key bounds or cursors, then retain the locked eligibility recheck. Exercise the hostile search_path with an eligible row and verify protected instances do not require locks. Ref: #32 (32-S1, 32-S3) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the backfill set-based on success and preserve SQLSTATE while adding the failing history key on JSONB decode errors. Verify atomic rollback, valid upgrades, and a schema built entirely from the pre-0027 migration prefix. Ref: #32 (backfill diagnostics and upgrade-fixture review notes) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Require draining all provider callers, pause retention during upgrades, and describe the one-time deletion wave and backfill/WAL cost. Document an explicit timestamp-only repair after draining, preserve the migration ledger, and classify existing-procedure fixes under Fixed. Ref: #32 (32-M1, 32-S2, changelog review note) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Start one new ApplyAll process first and wait for provider initialization to complete before restarting the remaining upgraded callers. Keep migrations numbered 0027/0028 pending merge-order coordination. Ref: #32 (upgrade-startup review nit) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the database message in ordinary migration error display while retaining the SQLx source for SQLSTATE retry classification. Add a red/green regression that also proves failed migration statements leave the ledger, stored function, and durable rows unchanged. State that migration 0030 must not ship before the 0027-0029 prerequisites, including the dependency of #51 on #32. Addresses review items 41-N6 and 41-N7. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Todd J. Green (tjgreen42)
left a comment
There was a problem hiding this comment.
Review by GPT-6.1 Sol.
No actionable findings in this revision. Reviewed ContinuedAsNew completion timestamps and backfill eligibility, batched pruning, delete/recreate protection, destructive-operation lock ordering, migration registration and cleanup, and the associated regression/concurrency tests. The previously reported pruning and lock-order concerns are addressed at this head.
Scope: static review at 7987089. cargo fmt --check passed. Local nextest compilation was blocked by the available Rust 1.88 toolchain versus a resolved dependency requiring Rust 1.89; no local PostgreSQL integration tests were run.
The runtime now retries activity completion acknowledgements, including after a committed response was lost. Register the upstream duplicate-ack validation to ensure those retries cannot enqueue a second completion, and align the heterogeneous-worker test with at-least-once delivery. Keep the worker-queue progress implementation in the separately coordinated PR #51; retain this PR's migrations 0027/0028 and the current package release metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>


Summary
Record
completed_atforContinuedAsNewexecutions so age-based retention can remove old generations of long-running workflows. Previously, those timestamps remained NULL, leaving continued executions ineligible for age-based pruning.This also adds a paginated SQL pruning API and coordinates locking across pruning and deletion operations to protect live executions during concurrent maintenance.
Changes
Released Duroxide 0.2.0
0.1.32to the published0.2.0release. Both use crates.io; no unreleased checkout or path override is required.duroxide-pgpackage version unchanged. Compatibility notes remain under Unreleased; this is not a release-preparation PR.Coordinated change: Duroxide 0.2.0's worker-queue progress requirement remains in the separate #51 (migration
0029). That change must be included in the coordinated rollout; it is not folded into this PR. This PR retains migrations0027/0028, which precede0029.Completion timestamps — migration
0027OrchestrationContinuedAsNewhistory event, using its original timestamp rather than the upgrade time.Batched pruning — migration
0028prune_executions_batch, which scans a primary-key-ordered page of 1–1,000 execution keys and returns a continuation cursor and scanned/deleted counts.public.Each batch is atomic. The limit bounds scanned execution keys, not the number of history events deleted.
Bulk deletion and compatibility
Upgrade notes
This requires a fully drained upgrade, not a rolling upgrade with old and new provider binaries together.
MigrationPolicy::ApplyAllfirst. Provider initialization applies the migrations; keep provider traffic stopped until initialization succeeds.Stopping only workers is insufficient: old age-based deletion code can delete pending continuations after their completion timestamps are populated.
Expect a one-time wave of age-based deletions of old continue-as-new generations when retention resumes. Backfill time and WAL volume grow with the number of continue-as-new rows to repair; large histories can further increase backfill time. The backfill itself does not delete executions or history.
If the upgrade was not fully drained, an old acknowledgement can write a NULL completion timestamp after the backfill. Drain all callers first, then use the explicit timestamp repair procedure. Re-running the backfill while old calls remain in flight does not close that race; do not delete migration ledger rows to force a rerun.
Validation
Local validation at
ef49fcfagainst the published Duroxide0.2.0crate and isolated PostgreSQL 17.11:cargo check --workspace --all-targets --lockedpassed.Worker-queue progress changes and their validation remain scoped to #51. Live Entra and ignored stress tests were not run locally.
CI status
ef49fcfon the PostgreSQL 15 CI service.AADSTS7000112because theduroxide-pg-entra-ciapplication is disabled. The live Rust test did not run. The CI identity needs administrator attention before this job can be rerun successfully; no provider-code workaround or test bypass is included.