-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
cleanup block indices for missing blocks #15040
base: develop
Are you sure you want to change the base?
Conversation
c9fa7ad
to
c4aa1da
Compare
cb0e184
to
137d9b6
Compare
// - Seeking before the beginning of the bucket (the `start` param is lower than the lowest slot). | ||
// In both of these cases k,v will be nil and we can handle the same way using `edge` to | ||
// - continue to the next iteration. If the following Prev() key/value is nil, Prev has gone past the beginning. | ||
// - Otherwise, iterate as usual. |
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.
Do we have a unit test for these particular edge cases ?
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.
Yes, TestStore_Blocks_FiltersCorrectly
that touch the upper bounds of the blocks with SetStartSlot
+ SetEndSlot
. LMK if that is sufficient, or if you think we need a separate test.
func (q *QueryFilter) SimpleSlotRange() (primitives.Slot, primitives.Slot, bool) { | ||
if len(q.queries) != 2 || q.queries[StartSlot] == nil || q.queries[EndSlot] == nil { | ||
return 0, 0, false | ||
} | ||
start, ok := q.queries[StartSlot].(primitives.Slot) | ||
if !ok { | ||
return 0, 0, false | ||
} | ||
end, ok := q.queries[EndSlot].(primitives.Slot) | ||
if !ok { | ||
return 0, 0, false | ||
} | ||
return start, end, true | ||
} |
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.
Good candidate for unit test
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.
LGTM
b9a428d
to
360b869
Compare
360b869
to
2c57ad0
Compare
What type of PR is this?
Bug fix
What does this PR do? Why is it needed?
For any existing nodes impacted by the block cleanup bug fixed recently, this is a hack to help those nodes self-heal and avoid a complete db wipe and resync.
**Notes for reviewers **
blockParentRootIndicesBucket
maps from a block root to its children. When the db is in this state, we don't have the parent root of the missing block to clean up the index going the other direction. As I was wrapping this PR up I did think a couple ways to do it.blocksForSlotRange
, we could keep track of roots in the previous slot so that when we add something to thebadBlocks
slice for cleanup we have parent roots to check for the missing root. If the block root is in the first slot of the range we won't have seen its possible parents and need to fall back to method 1, so this is really just an optimization for method 1 and might not be worth the complexity.Acknowledgements