fix: stop the backfill from starving the collector's write lock - #20
Merged
Merged
Conversation
The background backfill runs hourly-sized chunks with a short pause between them; a day-sized chunk held the SQLite write lock past the 5 s busy_timeout on router-class storage, and every collector tick that landed during a chunk rolled back and lost its raw samples (SQLITE_BUSY warnings on the live router). The pause is a var so tests shrink it, matching the retention batch pattern.
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.
Live evidence (0.3.35 on the router):
Metric bucket refresh failed; discarding this tick's raw samples … SQLITE_BUSYevery ~2 min while the background backfill works through its day-sized chunks. Each chunk is one write transaction; on slow storage it exceeds the 5 s busy_timeout and the collector's 10 s tick rolls back — losing raw samples. Chunks shrink to an hour and yield 200 ms between them; total backfill work is unchanged, lock windows are ~24x shorter. Tests shrink the pause via a var, same pattern as rawMetricPruneBatch.