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

app/eth2wrap: fix lazy client if http times out #2035

Merged
merged 2 commits into from
Apr 6, 2023

Conversation

corverroos
Copy link
Contributor

Fix eth2wrap lazy client when http requests block/timeout. Also respect context cancel while lazy resolving.

category: bug
ticket: none

return &lazy{
provider: provider,
}
}

// lazy is a client that is created on demand.
type lazy struct {
provider func() (Client, error)
providerMu sync.Mutex
Copy link
Contributor Author

@corverroos corverroos Apr 6, 2023

Choose a reason for hiding this comment

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

only one caller will try to resolve the client if it doesn't exit. But use a separate lock so that other calls do not block when trying to read the client

l.mu.Lock()
defer l.mu.Unlock()
// Try until we get the provider lock or the context is cancelled.
for !l.providerMu.TryLock() {
Copy link
Contributor Author

@corverroos corverroos Apr 6, 2023

Choose a reason for hiding this comment

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

only way to wait for a lock while respecting context cancel

@codecov
Copy link

codecov bot commented Apr 6, 2023

Codecov Report

Patch coverage: 46.66% and project coverage change: +0.03 🎉

Comparison is base (0ae3027) 53.40% compared to head (92d0861) 53.43%.

❗ Current head 92d0861 differs from pull request most recent head 3ba0db6. Consider uploading reports for the commit 3ba0db6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2035      +/-   ##
==========================================
+ Coverage   53.40%   53.43%   +0.03%     
==========================================
  Files         174      174              
  Lines       22481    22493      +12     
==========================================
+ Hits        12005    12020      +15     
+ Misses       8968     8967       -1     
+ Partials     1508     1506       -2     
Impacted Files Coverage Δ
app/app.go 7.93% <0.00%> (ø)
app/eth2wrap/eth2wrap_gen.go 12.53% <11.42%> (ø)
app/eth2wrap/lazy.go 54.79% <78.37%> (+8.89%) ⬆️
app/eth2wrap/eth2wrap.go 62.56% <100.00%> (+1.47%) ⬆️

... and 5 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dB2510
Copy link
Contributor

dB2510 commented Apr 6, 2023

@corverroos we need to upgrade to go1.20.3 for govulncheck. Not a blocker though.

@corverroos corverroos added the merge when ready Indicates bulldozer bot may merge when all checks pass label Apr 6, 2023
@obol-bulldozer obol-bulldozer bot merged commit 705ae09 into main Apr 6, 2023
@obol-bulldozer obol-bulldozer bot deleted the corver/fixlazyclient branch April 6, 2023 09:25
corverroos added a commit that referenced this pull request Apr 6, 2023
Fix eth2wrap lazy client when http requests block/timeout. Also respect context cancel while lazy resolving.

category: bug
ticket: none
obol-bulldozer bot pushed a commit that referenced this pull request Apr 6, 2023
Fix eth2wrap lazy client when http requests block/timeout. Also respect context cancel while lazy resolving.

category: bug
ticket: #2037
cherry-pick: #2035
LukeHackett12 pushed a commit that referenced this pull request Apr 11, 2023
Fix eth2wrap lazy client when http requests block/timeout. Also respect context cancel while lazy resolving.

category: bug
ticket: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants