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

fix deadlock that happens when fetching blocks #1118

Merged
merged 3 commits into from
Sep 5, 2024
Merged

fix deadlock that happens when fetching blocks #1118

merged 3 commits into from
Sep 5, 2024

Conversation

Tofel
Copy link
Contributor

@Tofel Tofel commented Sep 4, 2024

We do not decrease workgroup count on error :/

Tests executed:

  • set block fetch timeout to 1 second and fetch 100 blocks -> code doesn't block, when call timeouts
  • set block fetch timeout to 10 seconds and fetch 100 blocks -> code doesn't block, when no call timeouts

Added a ticket to add tests: https://smartcontract-it.atlassian.net/browse/TT-1604


Below is a summarization created by an LLM (gpt-4-0125-preview). Be mindful of hallucinations and verify accuracy.

Why

The changes enhance the error handling within the asynchronous block header fetching process by ensuring the wait group counter is decremented even when an error occurs during header retrieval. This prevents potential deadlocks by guaranteeing that the wait group's count is accurately managed, allowing the process to complete as intended.

What

  • seth/gas_adjuster.go: Added a wg.Done() call in the error handling section of the asynchronous block header fetching function. This ensures that the wait group count is decremented in case of an error, preventing the goroutine from blocking indefinitely.
    • Added wg.Done() within the error handling to ensure the wait group is properly decremented upon an error, facilitating error handling in concurrent operations.

@Tofel Tofel marked this pull request as ready for review September 4, 2024 14:13
@Tofel Tofel requested review from sebawo and a team as code owners September 4, 2024 14:14
@cl-sonarqube-production
Copy link

@Tofel Tofel merged commit 0512b7a into main Sep 5, 2024
41 checks passed
@Tofel Tofel deleted the fix_deadlock branch September 5, 2024 05:58
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