Skip to content

fix(retention): drain backlog and retire unheld flow families - #145

Draft
wolfy-j wants to merge 4 commits into
masterfrom
fix/retention-drains-backlog
Draft

wolfy-j wants to merge 4 commits into
masterfrom
fix/retention-drains-backlog

Conversation

@wolfy-j

@wolfy-j wolfy-j commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Retention deleted one batch per interval, so any load above that rate grew the commit and data tables without bound, and terminal flow families (flows, nodes, results, inputs and outputs) were never deleted.

  • The diagnostics sweeper drains its backlog in bounded transactions per pass, selecting through age-leading indexes; a protected head page no longer hides later eligible rows. One log line per productive pass, none when idle.
  • Terminal flow families age out after flow_retention_days (default follows the diagnostic window, 30-day minimum; zero disables). Children are deleted in bounded pages, leaves first, with a durable fence for restart recovery.
  • Owners keep their flows: create accepts retain = true, and release drops the hold (actor-checked, idempotent). Held families are never aged out. Every family created before this migration is held, so installed owners lose nothing they still read.

Migration 10 backfills family identity on populated databases. Tested on SQLite and PostgreSQL (1,582 each), including a populated upgrade.

@wolfy-j
wolfy-j requested a review from skhaz November 14, 2026 06:26
@wolfy-j
wolfy-j marked this pull request as draft November 22, 2026 03:58
@wolfy-j

wolfy-j commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

The PostgreSQL job failed because the populated upgrade test connects to dataflow_retention_upgrade_test, while the GitHub service creates just dataflow_test. The exact run log and a local reproduction using the CI runtime and PostgreSQL image both report SQLSTATE 3D000. Commit 7b7af9bd creates the separate fixture DB before the tests. The native populated migration test passed with that database present.

I moved this PR to draft after finding a separate compatibility failure. Current KickSide Workflows calls create_workflow(payload.commands, payload.options) and stores options without retain, including for a launch that retries an existing reservation. In the native test, that call created a new workflow under an ordinary owner. Once terminal and eligible by age, the draft removed its row on both SQLite and PostgreSQL. Released Workflows reads results by the engine ID and only prunes its owning row after the terminal event is acknowledged. That condition cannot be established from the engine age, even when both windows default to 30 days.

Keep family reclamation behind an explicit owner lifecycle contract. The diagnostics backlog work is independently testable and should not depend on adding the family backfill and deletion policy. Workflows creation options · Owner retention check

The corrected fixture was also used for a full clean PostgreSQL rerun with the exact CI image and Wippy 0.3.59a. All 1,582 tests passed. The owner-compatibility finding above still blocks the family deletion change.

Commit 320bde18 preserves existing callers: omitted retain holds a new root, as does explicit true. Only explicit false opts into expiry. The root-age index now excludes held roots, so adding the default hold does not turn an idle family pass into a scan of all that history. The native retention and populated-migration suites passed on both databases. The caller's same-database release contract and the diagnostics backlog are still under qualification before this draft is ready.

I also checked the root selection query with 100,000 held roots and three eligible roots. In the disposable PostgreSQL fixture the previous index plus the same eligibility predicate examined 100,003 entries and filtered 100,000 heap rows. The partial index returned the same three rows directly, with one warm execution dropping from 9.87 ms to 0.025 ms. SQLite issued fewer than 100 VM instructions with the partial index, versus about 500,000 with the previous one. This isolates root selection; it does not measure family deletion or diagnostic work.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants