Fix crash recovery and flush contention in delete/restore (#125) #498

Closed
kayg wants to merge 0 commits from train/2026-10-16s into dev
Owner

A crash after a closed-note delete could replay a stale index and remove the only Trash file. Restore could also return success while the file stayed in Trash. This preserves the surviving file, repairs stale paths, and keeps a restored outside file's original ID when its markdown has no embedded ID.

The audit also fixes shadowed IDs omitted by the leaf lookup, torn JSON/Unicode log tails hiding later durable mappings, and missing Trash details making a freshly deleted old note immediately eligible for the retention purge. Expanded SIGKILL tests hold the index writer, exercise rapid delete/restore/delete/forget sequences, and check files, Trash, index and lists after restart. Folder rename and outside-move bursts are covered too.

Builds on issue/125-delete-remeasure and PR #475. Targets dev and replaces no PR. Issue #125 remains open.

The permanent-delete slowdown reproduces in five interleaved HDD runs per build. Background index fsyncs overlap Trash removal; deferring restore completion adds competing history writes. Rebuildable index records now append promptly without background fsync, and durable commands still sync prior records. Final batches containing restores await completion. Trash removal and history purge retain their required syncs.

Comparison Build Runs × samples p50 ms p95 ms Max ms
initial Baseline c82161d 5 × 30 32.788 91.934 164.531
initial Author c37ffe1 5 × 30 98.529 201.999 284.030
final Baseline c82161d 5 × 30 33.809 71.618 131.863
final Review fe53835 5 × 30 35.835 67.174 191.339

The final HDD restore p50/p95 is 103.526/203.345 ms versus baseline 93.288/202.533 ms. The 150 ms restore target remains unmet. Permanent-delete p50 is within overlapping baseline run variation; its maximum remains higher.

Validation: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace pass. Workspace tests: 445 passed, two ignored; 195 notes tests passed. One earlier concurrent run timed out in the existing seed-crash test; it passed alone and in the final run with RUST_TEST_THREADS=2.

Independent review and measurements · Verbatim gate output

(Replaces #477, merged with current dev. Review on #477.)

A crash after a closed-note delete could replay a stale index and remove the only Trash file. Restore could also return success while the file stayed in Trash. This preserves the surviving file, repairs stale paths, and keeps a restored outside file's original ID when its markdown has no embedded ID. The audit also fixes shadowed IDs omitted by the leaf lookup, torn JSON/Unicode log tails hiding later durable mappings, and missing Trash details making a freshly deleted old note immediately eligible for the retention purge. Expanded SIGKILL tests hold the index writer, exercise rapid delete/restore/delete/forget sequences, and check files, Trash, index and lists after restart. Folder rename and outside-move bursts are covered too. Builds on `issue/125-delete-remeasure` and [PR #475](https://git.kayg.org/kayg/calternal/pulls/475). Targets `dev` and replaces no PR. Issue #125 remains open. The permanent-delete slowdown reproduces in five interleaved HDD runs per build. Background index fsyncs overlap Trash removal; deferring restore completion adds competing history writes. Rebuildable index records now append promptly without background fsync, and durable commands still sync prior records. Final batches containing restores await completion. Trash removal and history purge retain their required syncs. | Comparison | Build | Runs × samples | p50 ms | p95 ms | Max ms | |---|---|---:|---:|---:|---:| | initial | Baseline c82161d | 5 × 30 | 32.788 | 91.934 | 164.531 | | initial | Author c37ffe1 | 5 × 30 | 98.529 | 201.999 | 284.030 | | final | Baseline c82161d | 5 × 30 | 33.809 | 71.618 | 131.863 | | final | Review fe53835 | 5 × 30 | 35.835 | 67.174 | 191.339 | The final HDD restore p50/p95 is 103.526/203.345 ms versus baseline 93.288/202.533 ms. The 150 ms restore target remains unmet. Permanent-delete p50 is within overlapping baseline run variation; its maximum remains higher. Validation: `cargo fmt --all --check`, `cargo clippy --workspace --all-targets -- -D warnings`, and `cargo test --workspace` pass. Workspace tests: 445 passed, two ignored; 195 notes tests passed. One earlier concurrent run timed out in the existing seed-crash test; it passed alone and in the final run with `RUST_TEST_THREADS=2`. [Independent review and measurements](https://git.kayg.org/kayg/calternal/src/commit/1b2c2807715fb1eec37b4677643fc5fdf252625b/docs/perf/issue-125-delete-review.md) · [Verbatim gate output](https://git.kayg.org/kayg/calternal/src/commit/1b2c2807715fb1eec37b4677643fc5fdf252625b/docs/perf/issue-125-delete-review-gates.md) (Replaces #477, merged with current dev. Review on #477.)
perf(notes): remeasure trash delete and restore (#125)
Some checks failed
CI / server (pull_request) Successful in 24s
CI / rust (pull_request) Successful in 2m16s
CI / web (pull_request) Failing after 48m45s
c37ffe1031
docs(perf): record independent delete review and interleaved HDD gates
Some checks failed
CI / server (pull_request) Successful in 28s
CI / rust (pull_request) Successful in 2m3s
CI / web (pull_request) Failing after 48m52s
1b2c280771
docs: move #125 evidence to the issue, not the repo
Some checks failed
CI / server (pull_request) Successful in 22s
CI / rust (pull_request) Successful in 2m10s
CI / web (pull_request) Failing after 48m8s
1cf10a6960
Measurements, run logs and gate output live on Forgejo #125.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QGa6qjALuHyi8H1naGp6b
Author
Owner

This PR's commits are on dev (landed). Forgejo kept it open and its merge endpoint answers 405, so it is closed by hand.

This PR's commits are on dev (landed). Forgejo kept it open and its merge endpoint answers 405, so it is closed by hand.
kayg closed this pull request 2026-10-21 11:32:58 +00:00
Some checks failed
CI / server (pull_request) Successful in 22s
CI / rust (pull_request) Successful in 2m10s
CI / web (pull_request) Failing after 48m8s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!498
No description provided.