Repository navigation
Request ids resume from the store, so a restart stops eating history - #70
Merged
Merged
Conversation
…ing history Every restart destroyed the oldest records, silently. `EventBus::new` starts the request counter at 1 and nothing ever seeded it from disk, while the recorder writes with `INSERT OR REPLACE` — it has to, because a request is written twice, once when it starts and once when it ends. Put together, the first request after a restart overwrites historical request 1, the second overwrites 2, and so on. The desktop app restarts on every update, so this ran regularly. Measured against v0.14.0 with a throwaway instance: eight requests, restart, eight more, restart, five more. Twenty-one requests, eight rows left. With the counter seeded: twenty-one rows. `Db::last_request_id` reads `MAX(id)`, and `build_store` hands it to the bus before `serve` starts, so the first request of the run already has a number above everything on disk. `resume_after` is a `fetch_max`: winding the counter backwards would be manufacturing collisions, which is the bug itself. Reading it can fail, and then the run carries on as before — losing a few old records is worse than recording nothing at all this session. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Merged
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.
Every restart destroyed the oldest records, silently.
EventBus::newstarts the request counter at 1 and nothing ever seeded it from disk, while the recorder writes withINSERT OR REPLACE— it has to, because a request is written twice, once when it starts and once when it ends. Put together, the first request after a restart overwrites historical request 1, the second overwrites 2, and so on. The desktop app restarts on every update, so this ran regularly.Measured
A throwaway instance, eight requests, restart, eight more, restart, five more:
Twenty-one requests, eight rows left.
The fix
Db::last_request_idreadsMAX(id), andbuild_storehands it to the bus beforeservestarts, so the first request of the run already has a number above everything on disk.resume_afteris afetch_max: winding the counter backwards would be manufacturing collisions, which is the bug itself.Reading it can fail, and then the run carries on as before — losing a few old records is worse than recording nothing at all this session.
Tests cover both halves: that
MAX(id)is what the next run has to start from, that a reused id really does overwrite the older row (the problem this exists to avoid), and that resuming never hands out a number twice.🤖 Generated with Claude Code