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

Synchronize writing to connection and aborting connection #10043

Merged
merged 9 commits into from May 12, 2019

Conversation

BrennanConroy
Copy link
Member

@BrennanConroy BrennanConroy commented May 7, 2019

Fixes #6701

Verified perf didn't change.

@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label May 7, 2019
@BrennanConroy BrennanConroy added this to the 3.0.0-preview6 milestone May 7, 2019
@davidfowl
Copy link
Member

Help me understand this change? The description of the fix is a bit light on explanation.

@BrennanConroy
Copy link
Member Author

Servers could get error logs saying "Writing is not allowed after writer was completed" if the connection was closed while writing, especially when writing the ping message. This synchronizes the abort with the writing so we wont see error logs when writing would be expected to fail.

@JamesNK
Copy link
Member

JamesNK commented May 10, 2019

Unit test?

@BrennanConroy
Copy link
Member Author

Unit test?

It's a race and there isn't anywhere to inject our own test code to force it.

@@ -173,7 +178,7 @@ public virtual ValueTask WriteAsync(HubMessage message, CancellationToken cancel
/// <returns></returns>
public virtual ValueTask WriteAsync(SerializedHubMessage message, CancellationToken cancellationToken = default)
{
if (_connectedAborted)
if (_connectionAborted)
Copy link
Member

Choose a reason for hiding this comment

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

Is there much reason to check _connectionAborted before acquiring the lock when we check immediately after? Presumably, if the connection is aborted, whoever has the lock shouldn't for long. I prefer removing redundant checks if possible.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed

@davidfowl
Copy link
Member

Do we need to backport this?

@BrennanConroy
Copy link
Member Author

Do we need to backport this?

Worst case it's an erroneous error log. There is no functional issue here. Based on that I don't think we should, but open to other opinions.

@davidfowl
Copy link
Member

davidfowl commented May 11, 2019

Looks like a legit test failures:

  • Microsoft.AspNetCore.SignalR.Tests.HubConnectionHandlerTests.ConnectionTimesOutIfInitialPingAndThenNoMessages

  • Microsoft.AspNetCore.SignalR.Tests.HubConnectionHandlerTests.AbortFromHubMethodForcesClientDisconnect

@BrennanConroy
Copy link
Member Author

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact aspnetcore-build@microsoft.com.

I've triaged the above build. I've created/commented on the following issue(s)
https://github.com/aspnet/AspNetCore-Internal/issues/2511

@BrennanConroy BrennanConroy merged commit 208299a into master May 12, 2019
@BrennanConroy BrennanConroy deleted the brecon/sync branch May 12, 2019 07:38
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Writing is not allowed after writer was completed", with SignalR 1.1
6 participants