Skip to content

Restore the whole cursor on failed read transactions; clarify docs - #17

Merged
jadamcrain merged 2 commits into
mainfrom
transaction-rollback-and-docs
Oct 15, 2026
Merged

jadamcrain merged 2 commits into
mainfrom
transaction-rollback-and-docs

Conversation

@jadamcrain

Copy link
Copy Markdown
Member

Fixes #16

Fix

ReadCursor::transaction restored only the position. A callback that replaced the cursor and then returned an error left it pointing into the replacement input. ReadCursor is Copy, so it now saves and restores the whole cursor. The regression test fails without the fix.

Docs

  • WriteCursor::transaction and at_pos: state that only the position is restored, not buffer contents. For at_pos, a failed operation can leave bytes before the original position changed. We aren't promising to restore buffer contents, since that would need a copy of the touched region.
  • WriteCursor::written_since: document that it returns NumericOverflow when pos is past the current position. The variant itself is unchanged, since changing it would break callers.
  • TrailingBytes::count: it's the number of trailing bytes, not the number of "non-zero" trailing bytes.

Found in a Codex review of 0.5.1; each finding was reproduced before fixing.

Only the position was restored, so a callback that replaced the cursor
and then failed left it pointing into the replacement input.
ReadCursor is Copy, so save and restore all of it.

Fixes #16
Write transactions restore only the position, not buffer contents;
say so, including that a failed at_pos can leave bytes before the
original position changed. Document the error written_since returns,
and correct the TrailingBytes::count description.
@jadamcrain
jadamcrain merged commit 1b955dc into main Oct 15, 2026
3 checks passed
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.

ReadCursor::transaction does not fully restore the cursor on error

1 participant