debug: identify the writer that persists NextUID via flush()/createFresh() (#644/#647)#652
Merged
Merged
Conversation
…esh() (#644/#647) Live evidence on 2.1.13: the properly-locked reload (locked=true) already observes NextUID=1 on disk at the moment it reads — the regression is committed to the base .index file BEFORE that read, not caused by it. This rules out withFolderRO's unlocked reload (#647) as the direct writer in this instance and points back to whichever flush()/createFresh() call persisted the bad value in the first place. flush() now logs its caller (via runtime.Caller) and the NextUID/ MessagesCount it's about to persist — the single choke point that writes fs.file.Header as ground truth and discards the log, called from compactLogIfNeeded, SaveFolder, RecomputeVSize, and reload's indexid-mismatch recovery. createFresh() now logs its caller and requested UIDValidity on every invocation, at WARN — it unconditionally resets NextUID to 1, correct only for a genuinely first-ever OpenFolder or the documented post-corruption fallback. An invocation on an already-established folder (one that has delivered mail earlier in the same run) is the bug. Purely additive logging behind LOG_LEVEL=debug (WARN for createFresh, to survive without needing debug level enabled) — no behavior change.
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
Live evidence on 2.1.13 (after #645 and #648): the properly-locked reload (
locked=true) already observesNextUID=1on disk at the moment it reads — the regression is committed to the base.indexfile before that read, not caused by it. This rules outwithFolderRO's unlocked reload (#647) as the direct writer in this specific instance and points back to whicheverflush()/createFresh()call persisted the bad value in the first place.This PR
flush()now logs its caller (viaruntime.Caller) and theNextUID/MessagesCountit's about to persist — the single choke point that writesfs.file.Headeras ground truth and discards the log, called fromcompactLogIfNeeded,SaveFolder,RecomputeVSize, andreload's indexid-mismatch recovery.createFresh()now logs its caller and requestedUIDValidityon every invocation, at WARN (survives without needing debug level enabled) — it unconditionally resetsNextUIDto 1, correct only for a genuinely first-everOpenFolderor the documented post-corruption fallback. An invocation on an already-established folder (one that delivered mail earlier in the same run) is the bug.Purely additive logging — no behavior change.
go test ./...green.