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

Fix safeLock not run when interrupt & Fix partial notification being cancelled in ServiceInstancesChangedListener #14730

Merged
merged 6 commits into from
Sep 30, 2024

Conversation

AlbumenJ
Copy link
Member

What is the purpose of the change?

Checklist

  • Make sure there is a GitHub_issue field for the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?

@AlbumenJ AlbumenJ changed the title Fix safeLock not run when interrupt & Clear interrupted status for MetadataUtils Fix safeLock not run when interrupt & Fix partial notification being cancelled in ServiceInstancesChangedListener Sep 29, 2024
@AlbumenJ AlbumenJ merged commit 86c1a9d into apache:3.3 Sep 30, 2024
18 checks passed
}
} catch (InterruptedException e) {
logger.warn(LoggerCodeConstants.INTERNAL_ERROR, "", "", "Try to lock failed", e);
interrupted = true;
}
runnable.run();
Copy link

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants