feat: add configurable batch size for bulk inserting failed rsources records#6873
Open
feat: add configurable batch size for bulk inserting failed rsources records#6873
Conversation
a0bc0ea to
d838708
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6873 +/- ##
==========================================
- Coverage 80.08% 79.66% -0.42%
==========================================
Files 565 565
Lines 63308 63323 +15
==========================================
- Hits 50698 50447 -251
- Misses 9619 9897 +278
+ Partials 2991 2979 -12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d838708 to
91e7652
Compare
91e7652 to
94718f8
Compare
atzoum
reviewed
Apr 12, 2026
| batchSize := sh.config.FailedRecordsInsertBatchSize | ||
| defaultFailedRecordsBatchSize := 5000 | ||
| if batchSize <= 0 { | ||
| batchSize = defaultFailedRecordsBatchSize |
Contributor
There was a problem hiding this comment.
need an upper limit based on the max number of parameters allowed
…records 🔒 Scanned for secrets using gitleaks 8.28.0
94718f8 to
3da64f6
Compare
🔒 Scanned for secrets using gitleaks 8.28.0
ktgowtham
approved these changes
Apr 14, 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.
Description
Txn Inserting into
rsources_failed_keys_v2_recordsis taking too much time. The core bottleneck isAddFailedRecords()for rsources_stats. It uses tx.Prepare + a loop of individual stmt.ExecContext calls. Each ExecContext is a separate network round-trip to Postgres. If a batchhas 1,000 aborted jobs with record_ids, that's 1,000 sequential INSERT round-trips all within one transaction.
rsources_failed_keys_v2_recordsWe could have used the COPY command, but the insert needs
ON CONFLICT (id, record_id) DO UPDATE SET ts = NOW(), and COPY doesn't support ON CONFLICTLinear Ticket
Security