Repository navigation
Serialize chat index cursor updates - #205
Merged
nickjalbert merged 3 commits intoOct 6, 2026
Merged
nickjalbert merged 3 commits into
nickjalbert merged 3 commits into
Conversation
nickjalbert
added a commit
that referenced
this pull request
Oct 6, 2026
…ed updates A reader killed with SIGKILL while holding messages.jsonl.lock left the index stuck until an operator reset it, and since #205 every history, pending, or sent read takes the lock. The holder now records its pid, pid namespace, and start time in <lock>/owner. The next reader takes the lock over when that process is gone. A running holder, or one in another pid namespace, keeps its lock. A lock with no owner record is taken over after 60 seconds. The offset record now ends with the sizes of the three index files after the last completed update. Before indexing, each file is cut back to its recorded size, so rows from a killed update are indexed once. The record is written by rename, and a rebuild records its restart before emptying the files. Old four-field records upgrade in passing with no rebuild. index-reset --offline accepts a lock that holds only the owner record and refuses when the recorded holder is still running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Two history readers can snapshot the same index offset before either obtains the lock. When the later reader eventually acquires the lock, it appends the range that the first reader already indexed, duplicating messages. Acquire the existing per-index lock before reading the offset or deciding to rebuild, and release it after the update.
Closes #204.
Validation: a new bounded regression runs two actual
chat historyprocesses against a temporary trajectory. Astatshim pauses the first reader at the offset boundary while the other reader completes; all indexing and filesystem writes use production code. The original version indexes messagem2twice; the fix indexes each message once, advances the cursor and releases the lock. The new regression and existing index-rebuild/history/sent scripts all pass on Ubuntu: 4 scripts, including 82 existing checks.git diff --checkpasses. Current-commit CI is pending; macOS and live identity execution were not tested locally.