Skip to content

fix: don't advance eventlog LastSeq() until the write is confirmed - #47

Open
AmirF194 wants to merge 1 commit into
tokencanopy:mainfrom
AmirF194:fix/46-eventlog-lastseq-gap-on-failed-write
Open

fix: don't advance eventlog LastSeq() until the write is confirmed#47
AmirF194 wants to merge 1 commit into
tokencanopy:mainfrom
AmirF194:fix/46-eventlog-lastseq-gap-on-failed-write

Conversation

@AmirF194

@AmirF194 AmirF194 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Log.Append incremented l.last before attempting the write, so a failed write (or flush) left LastSeq() pointing at a seq that never made it into l.entries. Session.Attach trusts since <= LastSeq() as proof the log can answer a resume, so when the failed Append was the most recent one, Since(since) came back empty across that gap instead of erroring, and the documented snapshot fallback never ran.

Moved the l.last assignment to right after the write and flush succeed, next to where the entry gets appended to l.entries, so the counter and the replay buffer always move together.

Added TestFailedAppendDoesNotAdvanceLastSeq: append one entry, close the underlying file to force the next write to fail, then assert LastSeq() and Since(0) still only see the one entry that actually landed. The new test fails without the change, at LastSeq() after failed Append = 2, want 1. Ran internal/eventlog and internal/session with -race, and make verify (module-path, protocol/control guards, full suite, build, vet) clean.

Fixes #46

Log.Append incremented l.last before attempting the write, so a failed
write left LastSeq() pointing past a gap that Since() answers as empty
instead of unanswerable. Session.Attach trusts since<=LastSeq() as proof
the log can serve a resume, so the documented snapshot fallback never
fired and a reconnecting viewer was left silently stuck.

Fixes tokencanopy#46
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.

Log.Append advances LastSeq() past a write that never lands, so a resuming viewer's cursor reads as answerable when Since() has nothing there

1 participant