Revert the output pipe in the DuplexStreamPipeAdapter#11601
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
| } | ||
| catch (Exception ex) | ||
| { | ||
| Log?.LogError(0, ex, $"{GetType().Name}.{nameof(WriteOutputAsync)}"); |
There was a problem hiding this comment.
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.
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.
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.
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()
);
halter73
left a comment
There was a problem hiding this comment.
Please fix the pauseWriterThreshold and resumeWriterThreshold before merging though.
|
|
||
| _completed = true; | ||
| _connectionOutputFlowControl.Abort(); | ||
| _outputWriter.Complete(); |
|
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