Repository navigation
fix(rusqlite-runtime): retire ledger rows of exited daemon incarnations - #4129
Merged
Merged
Conversation
|
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
ScriptedAlchemy
enabled auto-merge
October 16, 2026 11:30
ScriptedAlchemy
disabled auto-merge
October 16, 2026 13:41
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Step 3 of the storage redesign (
docs/plans/storage/README.mdin #4118), growth source 9 from #4099.Every store's writer keeps an idempotency ledger (
td_runtime_writer_idempotency_v2). A lookup matches on(shard, incarnation, authority_epoch, key), and the incarnation is the daemon's generation. So each daemon restart left the previous incarnation's rows unreachable, and nothing removed them. The only prune deleted rows of the committing incarnation at a superseded authority epoch.A commit now also retires the rows of any incarnation whose checkpoint on that shard has been unchanged for more than 7 days. Each checkpoint row already holds its incarnation's last commit time, so the candidates come from the small checkpoint table plus the idempotency key prefix. No age column is scanned, and no schema object changes, so the exact-final-shape admission of existing stores is unaffected. Both rules share the existing bound of 256 deleted rows per commit.
The committing incarnation is never a candidate. Its checkpoint has just been persisted at this commit's own time, and a test pins that ordering. So a daemon that runs past 7 days keeps replaying its own receipts. That keeps the module's existing rule that content-derived keys of a live writer are never retired by age.
This differs from the design's literal "idempotency pruned at 7 d of age". Pruning the live incarnation by age needs an index on
committed_at_micros. That index changes the store's exact schema shape, and memory-holding stores have no migration path yet (step 2). Retiring exited incarnations ends the stranding the design names, without that schema change.Test plan
bazel test //crates/tracedecay-rusqlite-runtime:unit_test //crates/tracedecay-rusqlite-runtime:rusqlite_suitea_restarted_daemon_retires_the_previous_incarnations_records_after_a_quiet_week: rows of incarnation 1 survive a commit by incarnation 2 at exactly 7 days and are retired 1 µs later. Skipping the retirement fails it, and so does changing<to<=.the_live_incarnation_keeps_replaying_its_own_receipts_past_the_window: a two-week-old receipt of the committing incarnation still replays. Moving the prune beforecheckpoint::persistfails it.bazel build --config=clippy //crates/tracedecay-rusqlite-runtime/...and//crates/tracedecay-rusqlite-runtime:rustfmt_check_2024//crates/tracedecay:daemon_suite,:mcp_suite,:session_suite,:unit_testin CIRefs #4099