Repository navigation
Follow mode records the pages each applied file wrote, and keeps the position reached before an apply error - #6
Merged
Merged
Conversation
added 2 commits
November 16, 2026 20:54
A follow poll applies each new LTX file in turn and writes the -txid sidecar once the poll completes. When a later file of the poll failed, the files already applied stayed in the database but the position was not written, and a gap-fill dropped the position it had reached. The next poll applied the earlier files again, over pages that newer files had since written, so between two of those applies the database held pages of different transactions. The poll now writes the position it reached before it reports the error, and a gap-fill returns its progress together with its error.
With -follow-pages (RestoreOptions.FollowPages), follow mode appends to the <output>-pages sidecar one "partial" record before an LTX file's first page write and one "ok" record after its last, both while the database file is locked for the apply. An "ok" record carries the file's TXID range, the page count it commits and the page numbers it wrote as ascending ranges. A consumer that holds the database file against the apply reads a record for every page the file contains, can copy only those pages into a copy of its own, and sees a trailing "partial" record exactly when an apply did not complete. The sidecar is opened in append mode for each record, so the consumer may truncate it while it holds the file. Follow mode without the flag is unchanged.
PR Build Metrics✅ All clear — no issues detected
Binary Size
Dependency ChangesNo dependency changes. govulncheck OutputBuild Info
History (1 previous)
🤖 Updated on each push. |
GO-2026-6859 is an HTTP/1 server crash in net/http, present in go1.26.10 and fixed in go1.26.11. The workflows read the Go version from go.mod, so the toolchain line is the only place that names it.
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
Two changes to follow mode (
restore -f), both aimed at a consumer that serves reads from a copy of the follow file.-txidsidecar when the poll completes. When a later file of the poll failed, the files already applied stayed in the database but the position was not written, and a gap-fill dropped the position it had reached. The next poll applied the earlier files again, over pages that newer files had since written, so between two of those applies the database held pages of different transactions. The poll now writes the position it reached before it reports the error, and a gap-fill returns its progress together with its error.-follow-pagesrecords the pages each applied file wrote. With the flag (RestoreOptions.FollowPages), follow mode appends to the<output>-pagessidecar onepartialrecord before an LTX file's first page write and oneokrecord after its last, both while the database file is locked for the apply. A record is one line:<minTXID> <maxTXID> <commit> <ok|partial> <pages>, with the pages as ascending ranges, for example0000000000000014 0000000000000015 12 ok 2,4-6,9. A consumer that holds the database file against the apply reads a record for every page the file contains, can copy only those pages into its own copy, and sees a trailingpartialrecord exactly when an apply did not complete. The sidecar is opened in append mode for each record, so the consumer may truncate it while it holds the file. The flag requires-f; follow mode without it is unchanged.Observed
A reader that copies the whole follow file after every applied batch moved 650 MiB for a one-row change on a 733 MiB database. With the page records the copy is the pages the batch wrote.
Tests
TestReplica_Follow_ErrorKeepsPositionReachedandTestReplica_ApplyNewLTXFiles_GapFillErrorKeepsPositionReachedfail on the current code (the applied file is opened on every poll; the gap-fill reports the position it started from) and pass with the change.TestApplyLTXFile_FollowPages: the two records and their ranges, an append after the consumer truncated the file, a failed apply leaving thepartialrecord last, an unwritable sidecar applying no page, and no sidecar without the flag.TestReplica_Restore_FollowPagesRequiresFollow.TestReplica_Restore_Follow_Pages: against a real database and the file replica, copying the recorded pages onto a copy taken before the apply reproduces the follow file byte for byte.The full suites of the root,
internalandcmd/litestreampackages pass.Toolchain
go.modmoves the toolchain pin from go1.26.10 to go1.26.11 for GO-2026-6859 (an HTTP/1 server crash innet/http, fixed in go1.26.11). The workflows read the Go version fromgo.mod; no other file names the version. The root,internalandcmd/litestreamsuites,gofmt -landgo vetpass under go1.26.11.