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 race between CompleteAsync and call dispose #1429

Merged
merged 7 commits into from
Sep 30, 2021

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Sep 29, 2021

Addresses #1394

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King
Comment on lines 1063 to 1079
var sentEndStreamCount = lastLogs.Count(l =>
{
// This is HTTP/2 specific. If this test is run with HTTP/3 then this check will need to be updated.
if (l.EventId.Name == "Http2FrameReceived" &&
l.State is IEnumerable<KeyValuePair<string, object>> state)
{
var frameType = state.Single(s => s.Key == "type").Value.ToString();
var flags = state.Single(s => s.Key == "flags").Value.ToString();

if (frameType == "DATA" && flags == "END_STREAM")
{
return true;
}
}

return false;
});
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only way I could figure out how to unit test this. I think if this test becomes troublesome then it could be deleted.

@@ -996,5 +997,90 @@ async Task WaitForAllStreams(IAsyncStreamReader<DataMessage> requestStream, ISer
}
}
#endif

[TestCase(2)]
Copy link
Contributor

Choose a reason for hiding this comment

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

I might've missed the nuance in the issue text but why are we testing on iterations up to 2 and 20?

Copy link
Member Author

Choose a reason for hiding this comment

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

The race condition happened randomly.

When I was testing, I had 2 iterations so the logs weren't too long in one test run, and 20 in another run to ensure the race condition didn't happen over many iterations.

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King
@JamesNK
Copy link
Member Author

JamesNK commented Sep 30, 2021

I hate the test. Removed.

@JamesNK JamesNK merged commit ac3b3f4 into grpc:master Sep 30, 2021
@JamesNK JamesNK deleted the jamesnk/completeasync-race branch September 30, 2021 18:21
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.

None yet

2 participants