Skip to content

Fix TestServer hang with duplex streaming requests #17158

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 4 commits into from
Jan 15, 2020

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Nov 15, 2019

Description

TestServer does not correctly execute bidirectional requests. The HttpClient from a TestServer request will hang reading the response in two situations:

  1. The server writes no response content
  2. The client stream is not completed.

This PR resolves both of these issues.

Customer Impact

Because of these issues, TestServer can't be used to host gRPC functional tests of bidirectional gRPC calls.

For gRPC functional testing customers will be forced to host an in-process Kestrel instance and call via TCP sockets. This could cause port exhaustion on some OS with a large number of tests.

Regression?

No, TestServer has never correctly supported bidirectional requests.

Risk

Low. TestServer is designed for unit tests, not production use. Note: TestServer ships in Microsoft.AspNetCore.TestHost, an out-of-sdk NuGet package: https://www.nuget.org/packages/Microsoft.AspNetCore.TestHost/

@thefringeninja
Copy link

Any chance of getting this into 3.1?

@analogrelay
Copy link
Contributor

analogrelay commented Nov 20, 2019

Any chance of getting this into 3.1?

Not for 3.1.0, it's locked down tight. It could be considered for a patch to 3.1 though. @JamesNK is there any workaround for this issue?

@Tratcher
Copy link
Member

@Tratcher
Copy link
Member

Calling Response.Body.FlushAsync or Response.CompleteAsync should mitigate it.

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact [email protected].

I've triaged the above build.

@JamesNK
Copy link
Member Author

JamesNK commented Nov 20, 2019

Might be able to have a middleware in the test server instance that does nothing other than flush/complete. That wouldn’t be too intrusive.

Otherwise this could be a 3.1 patch.

@JamesNK
Copy link
Member Author

JamesNK commented Nov 26, 2019

Calling Response.Body.FlushAsync or Response.CompleteAsync should mitigate it.

I've tested and this isn't enough. The response will be returned to the HttpClient, but the response stream won't close until the request stream is complete. That is because clean up will wait for the request to be completed before the response:

await CompleteRequestAsync();
await CompleteResponseAsync();

I think we'll need to do this as a 3.1 patch.

@JamesNK JamesNK added 3.1-candidate Servicing-consider Shiproom approval is required for the issue and removed 3.1-candidate labels Nov 26, 2019
@JamesNK
Copy link
Member Author

JamesNK commented Nov 26, 2019

@anurse Added servicing label. Also update description with required template.

@JamesNK JamesNK modified the milestones: 5.0.0-preview1, 3.1.x Nov 26, 2019
@analogrelay analogrelay modified the milestones: 3.1.x, 5.0.0-preview1 Dec 2, 2019
@analogrelay analogrelay removed the Servicing-consider Shiproom approval is required for the issue label Dec 2, 2019
@analogrelay
Copy link
Contributor

Do you want this to go in to 3.1 directly or backport from master? The PR is targeting master but you put servicing labels on it :).

If you want it to go to 3.1, retarget to release/3.1 and put the label back on :). I'll take it to tactics.

@JamesNK
Copy link
Member Author

JamesNK commented Dec 3, 2019

I'd like to put it directly into 3.1 and then have it merged back to master. There is no urgency to get it into 5.0.

I'll retarget.

@JamesNK JamesNK force-pushed the jamesnk/testserver-duplexstreaming-nowrite branch from 1611131 to 953a7f9 Compare December 3, 2019 01:22
@analogrelay
Copy link
Contributor

I want to have a chat with you offline about this one @JamesNK .

@analogrelay analogrelay added the Servicing-consider Shiproom approval is required for the issue label Dec 6, 2019
@analogrelay
Copy link
Contributor

@Tratcher helped me clear this up.

  • In 3.0, bidirectional requests worked
  • We made changes in 3.1 that regressed this behavior
  • This PR is to fix those changes.

Given that, this definitely is worth submitting for patch. Reapplied the labels.

@JamesNK
Copy link
Member Author

JamesNK commented Dec 6, 2019

No.

  • 3.0, bidirectional requests hung.
  • 3.1 fixed bidirectional requests hanging. However it was discovered from users that the two scenarios listed here (request does not finish, no content written) still hang.
  • This PR fixes the two scenarios.

@jamshedd jamshedd added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Dec 10, 2019
@jamshedd jamshedd modified the milestones: 3.1.x, 3.1.1 Dec 10, 2019
@mkArtakMSFT
Copy link
Contributor

These were approved for 3.1.2, so updating the milestone accordingly /cc @jamshedd

@mkArtakMSFT mkArtakMSFT modified the milestones: 3.1.1, 3.1.2 Dec 11, 2019
@analogrelay analogrelay assigned analogrelay and unassigned JamesNK Jan 8, 2020
@vivmishra vivmishra modified the milestones: 3.1.2, 3.1.3 Jan 9, 2020
@vivmishra
Copy link

Moved to Mar as per Tactics. Will need to be explicitly approved for Feb, if required.

@analogrelay
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@analogrelay analogrelay merged commit 34294a3 into release/3.1 Jan 15, 2020
@analogrelay analogrelay deleted the jamesnk/testserver-duplexstreaming-nowrite branch January 15, 2020 19:08
@vivmishra vivmishra modified the milestones: 3.1.3, 3.1.2 Jan 15, 2020
dougbu added a commit that referenced this pull request Jan 16, 2020
@amcasey amcasey added the area-hosting Includes Hosting label Jun 1, 2023
@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-hosting Includes Hosting Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants