-
Notifications
You must be signed in to change notification settings - Fork 1k
Shutdown ClusterTopologyRefreshTask properly #2985
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
base: main
Are you sure you want to change the base?
Shutdown ClusterTopologyRefreshTask properly #2985
Conversation
src/test/java/io/lettuce/core/cluster/RedisClusterClientIntegrationTests.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @thachlp,
Thanks for giving this fix a go. I think, however, you may be on the wrong path.
Judging from the stack trace in #2904 the ClusterTopologyRefreshScheduler
attempts to refresh the topology AFTER the connections have been closed and the client is shutting down.
The suspendTopologyRefresh()
is supposed to suspend any topology refresh tasks, but it seems there is some case (race condition perhaps?) where a task is still executed during shurdown.
From the Java docs of
From my view, when we shut down RedisClusterClient, we should STOP running CANCEL scheduled tasks, that why I write STOP running tasks. Thank @tishun for explaining to me, do you have any suggestion for the fix? |
I will try to come back to you in the end of the week |
This PR introduces a check for a very specific scenario. The change doesn't necessary lead to a proper cancellation as the task itself is comprised from a series of refresh steps that are coupled through completable future's. Specifically, I think conceptually the easiest approach is to synchronize (and wait) until It would require also a bit of housekeeping, e.g. if (isEventLoopActive()) {
clientResources.eventExecutorGroup().submit(clusterTopologyRefreshTask);
return true;
} isn't atomic, |
@tishun @mp911de @thachlp |
fbb3951
to
d8507a5
Compare
Thanks @mp911de @tishun for reviews |
Hey @thachlp , The Then when the event loop is shut down it would print this message. What we need to do is:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are getting close to what we want to have.
It would be very hard to test this, but if you can think of some unit test that would also be handy. This is good to have, but not mandatory.
Thank you for spending time on this!
src/main/java/io/lettuce/core/cluster/ClusterTopologyRefreshScheduler.java
Outdated
Show resolved
Hide resolved
src/main/java/io/lettuce/core/cluster/ClusterTopologyRefreshScheduler.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tishun thanks for reviewing it.
I updated as you commented, please take a look 🙇
be55f44
to
d71ae46
Compare
Okay, I kind of broke it completely. I will come back to this next week. |
Issue: #2904
Make sure that:
mvn formatter:format
target. Don’t submit any formatting related changes.