-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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 safeLock not run when interrupt & Fix partial notification being cancelled in ServiceInstancesChangedListener #14730
Conversation
} | ||
} catch (InterruptedException e) { | ||
logger.warn(LoggerCodeConstants.INTERNAL_ERROR, "", "", "Try to lock failed", e); | ||
interrupted = true; | ||
} | ||
runnable.run(); |
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.
This may seem a bit strange, because generally the tryLock method is used like this:
Lock lock = ...;
if (lock.tryLock()) {
try {
// do something with lock
runnable.run();
} finally {
lock.unlock();
}
}
Wouldn't this really lead to some race conditions?
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.
safeLock
here is to try best to wait. In Dubbo, those actions needed safeLock
can accept delay, but cannot accept skip.
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.
Also, the patch indubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
is the real code to fix #14470. The original issue is once invoke failed, submitRetryTask
won't being invoked because of the code order.
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 got it, thanks for your patient explanation.
What is the purpose of the change?
Checklist