Skip to content

fix: stop the backfill from starving the collector's write lock - #20

Merged
masseselsev merged 1 commit into
masterfrom
fix/backfill-lock-contention
Sep 18, 2026
Merged

masseselsev merged 1 commit into
masterfrom
fix/backfill-lock-contention

Conversation

@masseselsev

Copy link
Copy Markdown
Owner

Live evidence (0.3.35 on the router): Metric bucket refresh failed; discarding this tick's raw samples … SQLITE_BUSY every ~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.

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.
@masseselsev
masseselsev merged commit e1e1ebf into master Sep 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant