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

core/bloombits: fix deadlock when matcher session hits an error #1895

Merged
merged 1 commit into from
Sep 27, 2023
Merged

core/bloombits: fix deadlock when matcher session hits an error #1895

merged 1 commit into from
Sep 27, 2023

Conversation

msmania
Copy link
Contributor

@msmania msmania commented Sep 25, 2023

Description

Calling eth_getLogs for pruned blocks causes deadlock. The exact same issue was reported as #1125 but it was never fixed.

This patch has been merged in the upstream and will be included in the next version v1.13.2. More technical details are described in ethereum/go-ethereum#28184.

Rationale

Every node runners running pruned nodes encounter this deadlock. If a request causes deadlock, the request fail with timeout. To make matters worse, piled-up deadlock goroutines keep consuming system resource and the process will eventually be killed. due to OOM.

With this patch, the request immediately returns a jsonrpc error.

Example

Sending a single eth_getLogs for a single pruned block is enough to reproduce deadlock.

Changes

Notable changes:

When MatcherSession encounters an error, it attempts to close the session.
Closing waits for all goroutines to finish, including the 'distributor'.
However, the distributor will not exit until all requests have returned.

This patch fixes the issue by delivering the (empty) result to the distributor
before calling Close().
Copy link
Collaborator

@brilliant-lx brilliant-lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@brilliant-lx brilliant-lx merged commit 35b21ca into bnb-chain:master Sep 27, 2023
5 checks passed
@msmania msmania deleted the bugfix-deadlock-eth_getLogs branch September 28, 2023 00:31
msmania added a commit to msmania/bsc that referenced this pull request Oct 30, 2023
…chain#1895)

When MatcherSession encounters an error, it attempts to close the session.
Closing waits for all goroutines to finish, including the 'distributor'.
However, the distributor will not exit until all requests have returned.

This patch fixes the issue by delivering the (empty) result to the distributor
before calling Close().
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.

4 participants