fix(db): batch route reconfirmation to avoid ingest stalls - #180
Merged
Merged
Conversation
This was referenced Sep 28, 2026
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.
What this PR does
Route reconfirmation held locks across a transaction of up to 750,000 routes. Production wait-state captures showed it blocking ingest route upserts, followed by timeouts and MQTT queue overflows.
Process 1,000 routes per transaction with a five-second batch timeout, retaining the 750,000-route run limit. Skip busy rows and use one cutoff per run so completed rows are not selected again, including when application time is ahead of database time. Existing stale/ambiguous route validation stays intact; busy rows and cancelled batches remain eligible for a later run.
Type of change
Checklist
go build ./...passesgofmt -l .is emptygo vet ./...passesgo test ./...passes with local PostgreSQL integration tests enabledsqlc generateand mock regeneration completed; no schema migration neededTesting notes
db,internal/backgroundandinternal/ingestwith PostgreSQL enabled.Local tests demonstrate preservation for the exercised cases, not a universal production losslessness guarantee. Busy routes may have validation deferred. Production has not been changed.