Skip to content
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

vote/vote_pool: use TryRLock in FetchVoteByBlockHash #311

Conversation

minh-bq
Copy link
Collaborator

@minh-bq minh-bq commented Jul 14, 2023

The FetchVoteByBlockHash is called by the consensus engine and we don't want this function to block the consensus engine's operations. Currently, FetchVoteByBlockHash uses RLock to wait to acquire the read lock but as the writers are uncontrolled, it can be blocked when there are a lot of spamming writers. This commit makes FetchVoteByBlockHash to use TryRLock to keep polling for the lock n times and returns nil in case it cannot acquire the lock. This helps to bound the max duration a caller must wait on this function.

core/vote/vote_pool.go Outdated Show resolved Hide resolved
The FetchVoteByBlockHash is called by the consensus engine and we don't want
this function to block the consensus engine's operations. Currently,
FetchVoteByBlockHash uses RLock to wait to acquire the read lock but as the
writers are uncontrolled, it can be blocked when there are a lot of spamming
writers. This commit makes FetchVoteByBlockHash to use TryRLock to keep polling
for the lock n times and returns nil in case it cannot acquire the lock. This
helps to bound the max duration a caller must wait on this function.
@minh-bq minh-bq force-pushed the fix/fetch-finality-vote branch from cb3ff2e to 7ae468d Compare July 17, 2023 03:58
@minh-bq minh-bq merged commit 8879076 into axieinfinity:feat/optimistic_fast_finality Jul 20, 2023
@minh-bq minh-bq deleted the fix/fetch-finality-vote branch July 20, 2023 04:06
minh-bq added a commit to minh-bq/ronin that referenced this pull request Aug 29, 2023
The FetchVoteByBlockHash is called by the consensus engine and we don't want
this function to block the consensus engine's operations. Currently,
FetchVoteByBlockHash uses RLock to wait to acquire the read lock but as the
writers are uncontrolled, it can be blocked when there are a lot of spamming
writers. This commit makes FetchVoteByBlockHash to use TryRLock to keep polling
for the lock n times and returns nil in case it cannot acquire the lock. This
helps to bound the max duration a caller must wait on this function.
minh-bq added a commit to minh-bq/ronin that referenced this pull request Sep 7, 2023
The FetchVoteByBlockHash is called by the consensus engine and we don't want
this function to block the consensus engine's operations. Currently,
FetchVoteByBlockHash uses RLock to wait to acquire the read lock but as the
writers are uncontrolled, it can be blocked when there are a lot of spamming
writers. This commit makes FetchVoteByBlockHash to use TryRLock to keep polling
for the lock n times and returns nil in case it cannot acquire the lock. This
helps to bound the max duration a caller must wait on this function.
minh-bq added a commit that referenced this pull request Sep 7, 2023
The FetchVoteByBlockHash is called by the consensus engine and we don't want
this function to block the consensus engine's operations. Currently,
FetchVoteByBlockHash uses RLock to wait to acquire the read lock but as the
writers are uncontrolled, it can be blocked when there are a lot of spamming
writers. This commit makes FetchVoteByBlockHash to use TryRLock to keep polling
for the lock n times and returns nil in case it cannot acquire the lock. This
helps to bound the max duration a caller must wait on this function.
andicrypt pushed a commit to andicrypt/ronin that referenced this pull request Nov 1, 2023
The FetchVoteByBlockHash is called by the consensus engine and we don't want
this function to block the consensus engine's operations. Currently,
FetchVoteByBlockHash uses RLock to wait to acquire the read lock but as the
writers are uncontrolled, it can be blocked when there are a lot of spamming
writers. This commit makes FetchVoteByBlockHash to use TryRLock to keep polling
for the lock n times and returns nil in case it cannot acquire the lock. This
helps to bound the max duration a caller must wait on this function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants