fix potential deadlock in dynconfig resolver #3024
Merged
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.
Description
This is a quite easy patch to fix potential grpc connection resolve deadlock with
dynconfig
resolver.Related Issue
Motivation and Context
The grpc-go introduce the
WithIdleTimeout
feature in v1.56.0, and the defaultidleTimeout
set as30 * time.Minute
in v1.59.0. This may be a potential cause of many reporting of preheat failed withDeadlineExceeded
.It seems that grpc with gc the idle connection after 30 minutes. And scheduler doesn't health check the seed peer, so when we create a preheat task, the last idle connection may be already closed by grpc, but when new connection is created, the connection is waiting for the resolver state to be done.
Here is the goroutine stack:
The
dynconfig
resolver is comparing the seed peers' address, but seed peer has no change. So there is no another chance to callcc.UpdateState
like below:These cause the deadlock in
waitForResolvedAddrs
method.Another fix is tracing the connection state, but it's more complicated. Or maybe grpc-go should clarify the resolver behavior first.
I have to Dragonfly2 cluster, one for test and one for production. After disable the
idleTimeout
feature, I haven't seen it happen again after 4 hours.But I still change many code in
dynconfig
resolver to digging this state. Hope this is the root cause.Screenshots (if appropriate)
Types of changes
Checklist