Repository navigation
fix(document): a standalone MongoDB seal is never withdrawn after readers see it - #101
Conversation
…ders see it On a deployment without transactions, seal inserted its marker, then re-checked the truncation and append epochs and withdrew the marker on a change. In between, every reader already saw the sealed view, so a rolled-back seal was briefly visible. A standalone truncate_before now publishes a truncation floor on the stream head before it edits any segment, and sealed and live reads clip at it. A seal no longer has to be withdrawn because of a truncation: the floor already clips the sealed view. Appends are arbitrated by the unique (scope, stream, generation, offset) index. After inserting its marker, a seal withdraws only if the stream was deleted (generation moved) or a newer seal already published past its length, and neither withdrawn marker is ever the one readers see. Also on the standalone path: a withdrawn seal's blob is deleted rather than leaked; a truncation that finds the stream sealed after raising the floor reports what it removed instead of a conflict after its edits; and deleting a stream resets its floor with the generation. The transactional path is unchanged. Heads without a floor read as zero. Part of tinyhumansai#49
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Tiny Sweeper reviewReviewed head: Verdict: Ready for maintainer review · Priority: none Diagnostics and supporting detailsFull summaryPull request purpose (title): fix(document): a standalone MongoDB seal is never withdrawn after readers see it. This pull request, titled "fix(document): a standalone MongoDB seal is never withdrawn after readers see it" (part of #49, item (a), non-breaking), reworks the non-transactional (standalone `mongod`) stream seal and truncate protocol so a seal is never rolled back after readers have already observed it. Previously a standalone `seal` inserted its marker, re-checked truncation and append epochs, and deleted the marker if either had moved — but in between, `read_window`, `info`, and append refusal already treated the stream as sealed. The same code also leaked a withdrawn seal's blob, missed a `delete_stream` occurring between the seal snapshot and marker insert, and let a truncation report `Conflict` after its segment edits had already run. The fix introduces a truncation floor published on the stream head before any segment edit, clips sealed and live reads at that floor, arbitrates appends through the unique `(_scope, s, g, o)` index, and limits post-insert withdrawal to the generation-moved and newer-seal cases — each of which deletes both marker and blob. The transactional path and migration story (a head without `floor` reads as 0) are unchanged. Review snapshot
Completeness: Complete Features
TestsNo supported feature-to-test mapping was produced. Test execution is not inferred. FindingsNo active actionable findings. Before mergeNone. Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
Part of #49, item (a). The design note was agreed with the maintainer side first. Not breaking.
Summary
On a MongoDB deployment without transactions (a standalone
mongod),sealinserted its marker, then re-checked the truncation and append epochs, and deleted the marker again if either had moved. In between, every reader (read_window,info, appends refused) already treated the stream as sealed, so a rolled-back seal was briefly visible. Three more standalone flaws sat in the same code:delete_streambetween the seal's snapshot and its marker insert went unnoticed (no generation re-check), so the marker landed in a dead generation andsealreturned Ok;Conflictafter its segment edits had already run.Fix (standalone path only)
truncate_beforepublishesflooron the stream head ($max, filtered on the current generation) before it edits any segment. Sealed and live reads clip at the floor (read_windowandinfo), so a truncation is visible at once and the row edits are only reclamation.(_scope, s, g, o)index arbitrates them. An append that took the seal's offset makes the marker insert fail before it's visible, and an append after the marker sees it and refuses.In both cases the withdrawn marker is never the one readers see.
delete_stream(advance_generation) resets the floor to 0 with the generation bump.Migration: none. A head without
floorreads as 0. Transactional path: unchanged.publish_seal_markerandtruncate_transactionalkeep their single-session guarantees.Validation
On a Linux build host, merged onto main 6372924:
mongodb::tests, 60 passed, 0 failed, 0 skipped.transactions_available()or needConditionalWrites. They fail identically without this change; CI runs a replica set.The fifth new test (a floor belongs to its generation) passes on the old code by construction, since there was no floor; it guards the new field.
cargo test --workspace --all-features --locked: 859 passed, 0 failed, 1 ignored.-D warnings(0 items),cargo fmt --check, rustdoc-D warnings.Tests (
mongodb/mod_tests.rs, live MongoDB)a_truncation_finished_during_a_standalone_seal_never_withdraws_it: the seal is paused after its snapshot, a truncation completes, and the seal succeeds clipped at the floor.deleting_a_stream_during_a_standalone_seal_withdraws_the_marker_and_its_blob.an_append_racing_a_standalone_seal_takes_the_offset_and_the_seal_conflicts: the blob is deleted.a_standalone_truncation_floor_belongs_to_its_generation.standalone_truncate_and_seal_linearize_without_losing_the_truncated_view: updated. The truncation now returnsOk(1)rather than a conflict after its edits.stale_seal_attempt_cannot_replace_the_newer_published_blob(existing) now also passes on a standalone.transactional_truncation_invalidates_a_seal_snapshot_taken_before_blob_publish(existing) now asserts it runs with transactions, like the other transaction-only tests; on a standalone the floor path clips instead.A test-only pause hook (
pause_seal_for_test) joins the existing truncate hook.