-
Notifications
You must be signed in to change notification settings - Fork 183
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
Reset flush strategy after client request is written #3103
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Motivation: Currently we reset the flush strategy after a request is written and its response is received. If client starts writing another pipelined request on the same connection, it ends up using an overridden flush strategy of the previous request that is still waiting for its response. Modifications: - For client connections (pipelined and non-pipelined) move flush strategy reset from "after full request-response completion" to "before completion of the request write". Using `beforeFinally` we guarantee that reset will happen before any retry/repeat operator initiates a new request on the same connection. It's safe to use "before" because for in-flight request the effective `FlushStrategy` is captured at the beginning of the write and doesn't change regardless of the reset. Only a new request will see the effect of the reset. - Reproduce described scenario in `FlushStrategyOnClientTest`. - Refactor `FlushStrategyOnServerTest` to use `TransportObserver` to observe flushes. This helps to use a real `HttpServerContext` instead of faking a `ServerContext` and reuse code for `FlushStrategyOnClientTest`. - Rename `Cancellable` in `NettyHttpServer` to highlight it's responsible for reset of FlushStrategy. Result: Second pipelined request on the same connection uses its own `FlushStrategy`.
This was referenced Nov 14, 2024
daschl
reviewed
Nov 14, 2024
servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/FlushStrategyOnClientTest.java
Outdated
Show resolved
Hide resolved
servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/FlushStrategyOnClientTest.java
Outdated
Show resolved
Hide resolved
servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/FlushStrategyOnClientTest.java
Show resolved
Hide resolved
servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/FlushStrategyOnServerTest.java
Show resolved
Hide resolved
servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/FlushStrategyOnServerTest.java
Outdated
Show resolved
Hide resolved
daschl
approved these changes
Nov 14, 2024
mgodave
pushed a commit
to mgodave/servicetalk
that referenced
this pull request
Nov 19, 2024
Motivation: Currently we reset the flush strategy after a request is written and its response is received. If client starts writing another pipelined request on the same connection, it ends up using an overridden flush strategy of the previous request that is still waiting for its response. Modifications: - For client connections (pipelined and non-pipelined) move flush strategy reset from "after full request-response completion" to "before completion of the request write". Using `beforeFinally` we guarantee that reset will happen before any retry/repeat operator initiates a new request on the same connection. It's safe to use "before" because for in-flight request the effective `FlushStrategy` is captured at the beginning of the write and doesn't change regardless of the reset. Only a new request will see the effect of the reset. - Reproduce described scenario in `FlushStrategyOnClientTest`. - Refactor `FlushStrategyOnServerTest` to use `TransportObserver` to observe flushes. This helps to use a real `HttpServerContext` instead of faking a `ServerContext` and reuse code for `FlushStrategyOnClientTest`. - Rename `Cancellable` in `NettyHttpServer` to highlight it's responsible for reset of FlushStrategy. Result: Second pipelined request on the same connection uses its own `FlushStrategy`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
Currently we reset the flush strategy after a request is written and its response is received. If client starts writing another pipelined request on the same connection, it ends up using an overridden flush strategy of the previous request that is still waiting for its response.
Modifications:
beforeFinally
we guarantee that reset will happen before any retry/repeat operator initiates a new request on the same connection. It's safe to use "before" because for in-flight request the effectiveFlushStrategy
is captured at the beginning of the write and doesn't change regardless of the reset. Only a new request will see the effect of the reset.FlushStrategyOnClientTest
.FlushStrategyOnServerTest
to useTransportObserver
to observe flushes. This helps to use a realHttpServerContext
instead of faking aServerContext
and reuse code forFlushStrategyOnClientTest
.Cancellable
inNettyHttpServer
to highlight it's responsible for reset of FlushStrategy.Result:
Second pipelined request on the same connection uses its own
FlushStrategy
.