Repository navigation
fix: search the BoltDB history backwards from the newest event - #1394
Merged
Merged
Conversation
maxHistoryScan bounded a forward walk starting at the oldest key, so any Last-Event-ID newer than the first 10,000 stored events was never found and reconnect replay stopped working on any hub holding more history than the cap. Search backwards from the newest event instead: the scan limit now bounds the ancient or forged ids the guard exists for, and a configured `size` raises it so the retention an operator pays for stays searchable. Fixes #1382
dunglas
force-pushed
the
fix/bolt-history-backward-scan
branch
from
September 21, 2026 13:43
0fac467 to
bd3330e
Compare
dunglas
added a commit
that referenced
this pull request
Sep 23, 2026
The backward search introduced by #1394 returned the newest update bearing the requested ID. The spec requires the earliest one, followed by every later update, including those reusing the ID. The search now scans the whole window and keeps the oldest match.
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.
Fixes #1382
maxHistoryScanbounded a forward walk starting atc.First(), the oldest key. Once the bucket held more than 10,000 events, everyLast-Event-IDnewer than the 10,000th oldest one was unreachable: the hub loggedCan't find requested LastEventID, replayed nothing and answeredLast-Event-ID: earliest. Ancient ids (the DoS case the cap protects against) were still found, recent ids (the normal reconnect case) were not.Changes
findLastEventIDsearches backwards from the newest event (c.Last()/c.Prev()) and returns the found sequence number. The cap now bounds the work for ancient or forged ids, while a client reconnecting after a short drop always finds its cursor.replayHistoryreplays forward fromSeek(fromSeq+1), keeping thepastSeqBoundguard against updates dispatched since the subscribe snapshot.historyScanLimitismax(maxHistoryScan, size). A configuredsizeabove 10,000 is retention the operator pays for in disk and cleanup passes, so it stays entirely searchable instead of being silently overridden by the constant.size 0keeps the 10,000 default bound.responseLastEventIDtracking from the search phase. It became unreachable in fix(bolt): report "earliest" when the requested Last-Event-ID is missing #1321, which forcesearliestwhenever the requested id is not found, and it cost a JSON unmarshal per scanned event.Notes
docs/concepts/reconnection-and-history.mdnow states the replay-depth bound next tosize, which the docs previously described as unlimited.