-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Cancel write semantic #12727
base: jetty-12.1.x
Are you sure you want to change the base?
Cancel write semantic #12727
Conversation
Provide a write cancel mechanism so that removing pooled buffers can be avoided.
Provide a write cancel mechanism so that removing pooled buffers can be avoided.
Signed-off-by: Ludovic Orban <[email protected]>
public Callback cancel(Throwable cause, Callback callback) | ||
{ | ||
Callback nested = new Callback.Nested(callback) | ||
{ | ||
@Override | ||
public void succeeded() | ||
{ | ||
super.failed(cause); | ||
} | ||
|
||
@Override | ||
public void failed(Throwable x) | ||
{ | ||
ExceptionUtil.addSuppressedIfNotAssociated(cause, x); | ||
super.failed(cause); | ||
} | ||
}; | ||
reset(HTTP3ErrorCode.REQUEST_CANCELLED_ERROR.code(), cause); | ||
return nested; | ||
} |
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.
@lorban that looks simple enough. Same as h2. Any idea how to test this?
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.
This is the big question: the implementation looks fairly easy but I've been scratching my head trying to find a way to reliably test that.
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.
Same comment as HTTP/2.
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 am dubious about the H2/h3 implementation; we should talk about it.
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpStream.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpStream.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java
Show resolved
Hide resolved
...-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
Outdated
Show resolved
Hide resolved
@@ -13,6 +13,7 @@ | |||
|
|||
package org.eclipse.jetty.http2.frames; | |||
|
|||
@Deprecated (forRemoval = true, since = "12.1.0") |
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.
Why deprecating this?
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.
because it is not used
...ty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Flusher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/HttpStream.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
@gregw another issue is the use of So it has not the right semantic for the usage that was done in H2 and H3. |
@sbordet See new |
Signed-off-by: Ludovic Orban <[email protected]>
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 believe the mechanism is sane, but I can't wrap my head around the newly introduced API and how this should all work.
I've attempted to write a test for this functionality (I've pushed it to this PR) and that left me puzzled. We should probably discuss it.
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/WriteFlusher.java
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java
Show resolved
Hide resolved
Signed-off-by: Ludovic Orban <[email protected]>
@gregw The H1 and H2 implementations have been reworked and are now tested. What this PR lacks before it can be considered complete is handling a set of TODOs, javadoc, naming and minor potential improvements. The H3 implementation has been deferred to after #12742 is merged, as that other PR changes too drastically the QUIC/H3 interactions so any work on the current impl would need to be completely re-done. |
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
@lorban can you re-review this PR and merge it? |
@gregw Not yet, as I would like a firm confirmation that this PR solves the problem once and for all. The #12776 issue is exactly about this bug, but not only: yesterday we discovered together with @sbordet that we have an extra bug (#12805) that still makes that user's use-case fail despite the fix in this PR. I would like to get a confirmation from this user that 12.1 is working before merging this PR as he's been very willing to help, responsive and came up with a reliable reproducer. |
Signed-off-by: Ludovic Orban <[email protected]>
… end already sent one Signed-off-by: Ludovic Orban <[email protected]>
8d5dbd0
to
81927fe
Compare
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
The H3 implementation will come after #12742 gets merged. |
if (LOG.isDebugEnabled()) | ||
LOG.debug("cancelSend reset callback complete"); | ||
appCallback.failed(cause); | ||
})); |
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.
_stream.reset()
may still return early.
How about introducing a HTTP2Session.flush(Callback)
that queues a "fake" FlushEntry
into the HTTP2FLusher
whose only scope is to be flushed and notify the callback when done?
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'll do that, and I'll also write a test similar to testResetAfterTCPCongestedWrite()
that waits for idle timeout instead of resolving the TCP congestion.
Added a cancel write/send semantic so that buffers for failed writes need not be removed from the pool