fix: use WriteBatch in BadgerDB to prevent "Txn is too big" errors#2228
fix: use WriteBatch in BadgerDB to prevent "Txn is too big" errors#2228nimrod-teich wants to merge 2 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Review Summary by QodoFix BadgerDB transaction size limits with WriteBatch and improve error handling
WalkthroughsDescription• Replace single-transaction db.Update() with BadgerDB's WriteBatch in saveAll() to handle large writes • Fix missing else branch in RewardDB.BatchSave that returned errors after successful chunked saves • Add comprehensive tests for large transaction handling exceeding BadgerDB limits • Simplify batch chunking logic using min() function Diagramflowchart LR
A["Single Transaction<br/>db.Update()"] -->|"Replace with"| B["WriteBatch<br/>Auto-splits large writes"]
C["Missing else branch<br/>returns error"] -->|"Fix"| D["Proper error handling<br/>after chunked saves"]
B -->|"Tested by"| E["Large payload tests<br/>2000 entries x 10KB"]
D -->|"Verified by"| E
File Changes1. protocol/rpcprovider/rewardserver/badger_db.go
|
Code Review by Qodo
1. saveAll() lacks wb.Cancel()
|
Replace single-transaction db.Update() with BadgerDB's WriteBatch in saveAll(), which automatically splits large writes across multiple transactions. This fixes providers seeing repeated "Txn is too big to fit into one request" errors when serving high relay volumes. Also fix a bug in RewardDB.BatchSave where successful chunked saves still returned the original error due to a missing else branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
aae86eb to
9bbf789
Compare
Replace single-transaction db.Update() with BadgerDB's WriteBatch in saveAll(), which automatically splits large writes across multiple transactions. This fixes providers seeing repeated "Txn is too big to fit into one request" errors when serving high relay volumes.
Also fix a bug in RewardDB.BatchSave where successful chunked saves still returned the original error due to a missing else branch.
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking changemainbranchReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...