Skip to content

tsan, xds: fix data races in ServerWrapperForXds #8114

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

Merged
merged 1 commit into from
Apr 26, 2021

Conversation

YifeiZhuang
Copy link
Member

fix tsan complain

@@ -290,7 +292,7 @@ private static boolean isPermanentErrorFromXds(Throwable throwable) {

private void cleanupStartRetryTaskAndShutdownDelegateAndXdsClient(boolean shutdownNow) {
Server delegateCopy = null;
synchronized (this) {
synchronized (ServerWrapperForXds.this) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this in this context only means ServerWrapperForXds.this so what does this change achieve? To make Tsan happy?

Copy link
Contributor

@sanjaypujare sanjaypujare Apr 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling that with the fix on line 242 (synchronizing on ServerWrapperForXds.this instead of ServerWrapperForXds.StartRetryTask.this) was all that was needed and the warning for this line should disappear with this unneeded change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have different understanding. It looks the original this means StartRetryTask.this instead of ServerWrapperForXds.this because this is in nested class.
And L242 looks a different usage of the racy object startRetryTask, so it needs synchronization on the ServerWrapperForXds.this, not StartRetryTask.this, which the original synchronization method locks on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanupStartRetryTaskAndShutdownDelegateAndXdsClient is a method of the outer class ServerWrapperForXds and not of a nested class. So ServerWrapperForXds. is not necessary. I was just wondering about Tsan warning for this line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right it is outside of the nested class, then ServerWrapperForXds.this change is not needed. Not a tsan problem, Tsan was reporting data races in all those places and yes the l242 is the problem and it is passing now w/o the change here. Thanks for pointing out.

Copy link
Contributor

@sanjaypujare sanjaypujare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but pls see the couple of comments

@YifeiZhuang YifeiZhuang merged commit 8468b5c into grpc:master Apr 26, 2021
@YifeiZhuang YifeiZhuang deleted the zivy/fix_tsan2 branch June 10, 2021 19:00
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants