Skip to content

fix(retention): drain diagnostic backlog - #147

Draft
wolfy-j wants to merge 2 commits into
masterfrom
fix/diagnostic-retention-backlog
Draft

wolfy-j wants to merge 2 commits into
masterfrom
fix/diagnostic-retention-backlog

Conversation

@wolfy-j

@wolfy-j wolfy-j commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Drain the configured diagnostic backlog with fixed-cutoff age seeks. Each transaction uses the published family eligibility rules and writer locks. Protected rows advance the cursor.
  • Install partial indexes for aged diagnostic data and applied commits in separate transactions. Existing flow, node, output, pending commit, and last-commit storage keeps its published policy.
  • Cover a populated migration, repeated application, a 1,000-row mixed-history batch, and cancellation between committed pages on SQLite and PostgreSQL.

Verification

  • The exact draft head passed all eight hosted checks. The native suite passed 1,572 tests on each database.
  • A disposable, hash-verified Dataflow 0.7.38 package graph created completed, recent, and parked executions on each database. Both databases restarted with the local candidate and all companion archives pinned. The ordinary retention service drained the aged backlog, preserved completed outputs and protected history, resumed the original parked signal, and completed a new execution.

Review status

This draft covers diagnostic retention. Family reclamation and owner release remain in #145.

Each migration uses normal CREATE INDEX, so the index build can block writes. The first loaded PostgreSQL rehearsal found that building both indexes in one transaction deadlocked with an actual released writer. The split migrations completed on PostgreSQL and SQLite with zero foreground failures. The fixture had 24,000 retained flows and 1.212 million history rows. Both runs removed 294,000 eligible rows.

Database Index migrations Foreground p95 before / during sweep Largest foreground run overlapping index build
PostgreSQL 445 ms data, 376 ms commits 119 / 206 ms 514 ms
SQLite 1,038 ms data, 673 ms commits 77 / 78 ms 485 ms

The migration decision is cold. Drain active Dataflow writers before the ordinary index builds. The split removes the observed deadlock, and the builds still take write-blocking locks. Steady sweeps run after that schema work and have their own foreground contention profile. PostgreSQL retains the existing table lock. SQLite uses its existing writer reservation. Protected diagnostics can be scanned again on later passes, and one wide family can require work beyond the candidate page size.

Steady PostgreSQL control

Each trial cloned the same populated history and ran the ordinary released Dataflow 0.7.38 foreground writer. The benchmark repeatedly invoked the released sweeper and used a roughly 15-second observation window. Released production cadence invokes one paired batch per scheduled pass. The candidate measurements use 1,000 rows per page and a 1 ms pause. The advisory prototype is a separate local experiment that selects possible candidates before acquiring the writer lock and rechecks their eligibility inside it.

Protected history Sweeper Elapsed ms Deleted rows Foreground overlaps Foreground latency during sweep
Direct waiting owner Released 0.7.38 15,084 36,000 4 1,476–8,395 ms observed
Direct waiting owner This draft 15,024 84,000 41 641 ms p95
Direct waiting owner Local advisory read 15,002 233,266 76 367 ms p95
Waiting sibling or descendant This draft 15,008 150,000 70 418 ms p95
Waiting sibling or descendant Local advisory read 15,038 0 53 321 ms p95

The advisory read reduced writer transactions to 235 across 1,126 raw pages when the diagnostic owner itself was waiting. An old terminal owner with a waiting sibling or descendant still required a locked family read for all 408 sampled pages. It stopped inside the 450,000-row protected prefix. Both approaches preserved those rows. The lower p95 in the advisory sibling/descendant trial came with zero deletion work. Keep the advisory experiment local.

The draft's same-page dry run reached 906 pages at 371 ms foreground p95. The destructive run reached 534 pages at 641 ms p95. Sampled foreground waits while maintenance was committing fell from 283 to zero in the dry run. The released control usually blocked its writer in the global eligibility query. The draft shifts observed contention toward transaction commit and repeated lock acquisition. These fixtures do not establish production latency. The PR remains draft for review.

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.

1 participant