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
fix: synchronize the reserve sampling process #3614
Merged
Merged
Conversation
This file contains 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
istae
approved these changes
Dec 2, 2022
istae
requested changes
Dec 2, 2022
istae
reviewed
Dec 5, 2022
janos
reviewed
Dec 5, 2022
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.
The approach looks pretty good with not so drastic changes. It should be good to go after linter is satisfied.
istae
approved these changes
Dec 6, 2022
notanatol
approved these changes
Dec 7, 2022
mrekucci
approved these changes
Dec 7, 2022
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.
Checklist
Description
In the localstore we usually guard parallel operations using the
batchMu
mutex. This is a huge bottleneck, but one that cannot be avoided at the moment. Due to the nature of the current localstore code, we need to have this exclusive lock to protect any changes to the underlying DB.For the sampling, we never acquired this lock. But we should as there could be changes to the pullIndex during iteration which should not happen. Also, currently, we do not acquire this lock when we evict batches from the batchstore. Both these cases are now fixed.
With this change, if there is a sampling process ongoing and reserve evictions happen, we will cancel the sampler. This will cause the player to not participate in the lottery game for that round. This is considered better as if the player does participate and end up submitting a wrong sample, he might get frozen. Also, having the lock for the sampling process seems to be an overkill and would slow down the Put path causing bottlenecks.
Along with this, I have added metrics for the BatchEviction process which were missing.
Fixes #3611 hopefully.
This change is