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

Support interleaved requests in access logger #6785

Merged
merged 5 commits into from
Jan 26, 2022
Merged

Conversation

yawkat
Copy link
Member

@yawkat yawkat commented Jan 21, 2022

HttpAccessLogHandler used a channel attribute to manage the AccessLog instance for a request. Because AccessLog does not support concurrent requests, this breaks on HTTP1 pipelining and on concurrent HTTP2 streams.

This patch multiplexes the requests onto multiple AccessLog instances.

Fixes #6782


I built this PR based on the branch of #6753 to avoid merge conflicts, that needs to be merged first. I'm making this a separate PR because it's a bug that's independent of the exclusion feature.

@yawkat
Copy link
Member Author

yawkat commented Jan 21, 2022

The GH changeset is ugly, will fix that once #6753 is in. The relevant commit is 4906ff2

@yawkat yawkat added the type: bug Something isn't working label Jan 21, 2022
@yawkat yawkat added this to the 3.3.0 milestone Jan 21, 2022
yawkat and others added 2 commits January 25, 2022 10:28
`HttpAccessLogHandler` used a channel attribute to manage the `AccessLog` instance for a request. Because `AccessLog` does not support concurrent requests, this breaks on HTTP1 pipelining and on concurrent HTTP2 streams.

This patch multiplexes the requests onto multiple `AccessLog` instances.

Fixes #6782
@yawkat yawkat marked this pull request as ready for review January 25, 2022 09:29
@timyates timyates linked an issue Jan 25, 2022 that may be closed by this pull request
@yawkat
Copy link
Member Author

yawkat commented Jan 25, 2022

Okay there was another issue: It seems like we don't routinely add the stream ID to HttpContent messages we write to the channel. I think this causes bugs with concurrent responses in HTTP2, but they're another issue entirely. I've changed the HttpAccessLogHandler to match the behavior of HttpToHttp2ConnectionHandler in this case, so the tests pass now. This can be merged in time for 3.3.0.

I will look at the HTTP2 concurrency issues further, but it won't make it into 3.3.0.

@yawkat yawkat merged commit f6b2389 into 3.3.x Jan 26, 2022
@yawkat yawkat deleted the interleave-access-log branch January 26, 2022 10:08
yawkat added a commit that referenced this pull request Jun 24, 2022
* Support interleaved requests in access logger
`HttpAccessLogHandler` used a channel attribute to manage the `AccessLog` instance for a request. Because `AccessLog` does not support concurrent requests, this breaks on HTTP1 pipelining and on concurrent HTTP2 streams.

This patch multiplexes the requests onto multiple `AccessLog` instances.

Fixes #6782

* Test interleaved access logs with exclusions

* Attach stream ID to publisher responses

* checkstyle

* remove `@Contract`

Co-authored-by: Tim Yates <tim.yates@gmail.com>
yawkat added a commit that referenced this pull request Sep 28, 2022
This PR refactors the NettyHttpServer to have a more straight-forward pipeline setup in a separate class (HttpPipelineBuilder), and then uses netty's Http2MultiplexHandler to multiplex each HTTP2 stream from one connection to its own Channel.

Multiplexing improves compatibility with HTTP 1 handlers downstream. While HTTP 1 handlers do not need to be aware of multiple concurrent request or response streams, HTTP 2 handlers do. With multiplexing, the HTTP 1 handlers only manage one HTTP 2 stream each, so concurrent requests are not an issue anymore.

This change prevents a class of bugs related to faulty STREAM_ID handling, such as #6785. It also adds a new feature, concurrent streaming responses (tested in this PR by Http2ConcurrentStreamSpec).

While all tests pass, this is a bit of a risky change. We expose a lot of the handler pipeline to downstream users, and this PR changes that pipeline fundamentally. For example, the SslHandler isn't visible on the pipeline anymore, which might lead downstream code to think SSL is disabled (this caused the test failure fixed in c9456e2). It's possible that there are similar downstream dependencies on the structure of the pipeline in other modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix access logger for interleaved requests
4 participants