-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Small fix in JedisClusterInfoCache.discoverClusterNodesAndSlots. #2682
Conversation
Approved |
we just call
When I would like to ask, does this PR fix the actual problems encountered in the production environment, or is the idea obtained by reading the code? |
Hi Yang, Since the function |
@@ -107,8 +107,8 @@ public void discoverClusterNodesAndSlots(Jedis jedis) { | |||
w.lock(); |
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.
List<Object> slots = jedis.clusterSlots();
w.lock();
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.
Since the function discoverClusterNodesandSlots is part of the API for the class JedisClusterInfoCache, I think it is a good idea to add a better safety guarantee.
@adiamzn Agree, I think we can move jedis.clusterSlots()
to the top of w.lock()
, just like the discoverClusterSlots
function.
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.
agreed, made the change
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.
@adiamzn jedis.clusterSlots()
to the top of w.lock()
, the lock time can be shortened.
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.
true, fixing
34296d7
to
557c28c
Compare
557c28c
to
a20966f
Compare
Calls jedis.Clusterslots before calling reset, instead of the other way around. Co-authored-by: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com>
791843e
to
d618fa5
Compare
Calls jedis.Clusterslots before calling reset, instead of the other way around. Co-authored-by: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Co-authored-by: EC2 Default User <ec2-user@ip-172-31-47-142.us-west-2.compute.internal> Co-authored-by: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com>
Description:
The change calls
Jedis.cluserSlots
beforereset
is called instead of the other way around.Why the change?
the
reset
function deletes thenodes
andslots
fields.If the
Jedis.clusterSlots
throws an exception in the try-catch blockthe function fails and the data is deleted.
It would be nicer if the data (nodes and slots) were left untouched if jedis.clusterSlots throws an exception.