-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Revert the output pipe in the DuplexStreamPipeAdapter #11601
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
Conversation
- This leads to trunated data in some cases. Instead just yield the middleware so we can be sure no more user code is running (Http1OutputProducer does this as well). There are still cases where a misbeaving application that doesn't properly await writes gets cut off but that will be fixed in the SteamPipeWriter itself. - Updated tests
src/Servers/Kestrel/Core/src/Middleware/Internal/DuplexPipeStreamAdapter.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Middleware/Internal/DuplexPipeStreamAdapter.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Middleware/Internal/DuplexPipeStreamAdapter.cs
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Middleware/Internal/DuplexPipeStreamAdapter.cs
Outdated
Show resolved
Hide resolved
} | ||
catch (Exception ex) | ||
{ | ||
Log?.LogError(0, ex, $"{GetType().Name}.{nameof(WriteOutputAsync)}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that both LibuvConnection and SocketConnection will not complete their PipeReaders with an error unless it was completely unexpected, it's tempting to make this a critical log. That's unless we're worried about something like SslStream throwing an Exception in the middle of WriteAsync despite there being no transport issue.
Maybe that is something we should be worried about... I'm just extra worried about swallowing errors now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave it at error for now. I do agree that swallowing errors is a concern, but what else should we do. Debug.Assert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
David already passed in a logger here. Critical logs are the new, much-improved Debug.Assert. Any critical log should cause the majority of our tests to fail.
readerScheduler: PipeScheduler.Inline, | ||
writerScheduler: PipeScheduler.Inline, | ||
pauseWriterThreshold: 1, | ||
resumeWriterThreshold: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use the defaults here like we did before to reduce thrashing:
internal PipeOptions AdaptedOutputPipeOptions => new PipeOptions
(
pool: MemoryPool,
readerScheduler: PipeScheduler.Inline,
writerScheduler: PipeScheduler.Inline,
pauseWriterThreshold: _context.ServiceContext.ServerOptions.Limits.MaxResponseBufferSize ?? 0,
resumeWriterThreshold: _context.ServiceContext.ServerOptions.Limits.MaxResponseBufferSize ?? 0,
useSynchronizationContext: false,
minimumSegmentSize: MemoryPool.GetMinimumSegmentSize()
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the pauseWriterThreshold and resumeWriterThreshold before merging though.
@@ -89,7 +89,6 @@ public void Complete() | |||
|
|||
_completed = true; | |||
_connectionOutputFlowControl.Abort(); | |||
_outputWriter.Complete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Maybe trying out the lower thresholds are OK for a preview. It does seem a little unecsary to try out new options now if we're removing it completely in the next preview though. |
I'd rather leave it as it so its as passthrough as possible. Also the fact that it is temporary and the fact that those options aren't readily available (they need to be flowed from the UseHttps call) is just more churn. If you do feel strongly about changing those limits back to the Kestrel limits, I'll do it. |
I'm fine with the way it is since it's temporary. Otherwise, I'd at least ask for benchmarks. |
Maybe it's reasonable to leave the defaults then. |
I just realized though, you'll very likely never hit those limits since we always consume the entire buffer and the scheduling is inline. It means call to write will yield the await, write to the Stream then call Advance). It'll only matter when we're experiencing back pressure from the transport itself (which is the effect we want, complete passthrough). |
That has always been my assumption. I talked to @jkotalik about exactly this earlier today. That's why I'm not too worried. I like validating my assumptions though. |
This reverts commit 6de357e. # Conflicts: # src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs # src/Servers/Kestrel/Core/src/Middleware/Internal/DuplexPipeStreamAdapter.cs
This reverts commit 6de357e. # Conflicts: # src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs # src/Servers/Kestrel/Core/src/Middleware/Internal/DuplexPipeStreamAdapter.cs
This reverts commit 6de357e. # Conflicts: # src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs # src/Servers/Kestrel/Core/src/Middleware/Internal/DuplexPipeStreamAdapter.cs
This reverts commit 6de357e. # Conflicts: # src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs # src/Servers/Kestrel/Core/src/Middleware/Internal/DuplexPipeStreamAdapter.cs
This reverts commit 6de357e. # Conflicts: # src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs # src/Servers/Kestrel/Core/src/Middleware/Internal/DuplexPipeStreamAdapter.cs
Fixes #11560