-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect duplicates in the same insert batch #32528
Conversation
Codecov Report
@@ Coverage Diff @@
## master #32528 +/- ##
=======================================
Coverage 82.0% 82.0%
=======================================
Files 780 780
Lines 210704 210764 +60
=======================================
+ Hits 172874 172926 +52
- Misses 37830 37838 +8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, definitely a sneaky bug. Really just two nit comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find!
should we backport this to 1.16? |
(cherry picked from commit b6927db)
#32557) Detect duplicates in the same insert batch (#32528) (cherry picked from commit b6927db) Co-authored-by: carllin <[email protected]>
(cherry picked from commit b6927db) # Conflicts: # ledger/src/blockstore.rs
(cherry picked from commit b6927db) # Conflicts: # ledger/src/blockstore.rs
#32591) * Detect duplicates in the same insert batch (#32528) (cherry picked from commit b6927db) # Conflicts: # ledger/src/blockstore.rs * Resolve conflicts --------- Co-authored-by: carllin <[email protected]>
What would be the impact of a duplicate not being detected? Is it only wasteful, or is it a correctness issue? |
Problem
There's a race condition where duplicate shreds in the same insert batch might not get detected as duplicate. The order of events is as follows:
A
andB
arrive toinsert_shreds_handle_duplicate()
fromwindow_service
: https://github.com/solana-labs/solana/blob/cfb028819a63de8f726bab3c9c981eb3155e9886/core/src/window_service.rs#L283C42-L283C72A
is inserted intojust_inserted_shreds
here:solana/ledger/src/blockstore.rs
Line 867 in cfb0288
B
is detected here:solana/ledger/src/blockstore.rs
Line 1340 in cfb0288
solana/core/src/window_service.rs
Line 423 in cfb0288
solana/core/src/window_service.rs
Lines 147 to 148 in cfb0288
A
hasn't been inserted yetSummary of Changes
Only invoke the duplicate handler after the shreds have been committed in insert. That way all shreds are findable.
Crux of change:
solana/ledger/src/blockstore.rs
Lines 1073 to 1075 in d263794
Fixes #