-
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 I've been investigating #12776 which happens to be a user-reported bug that is related to the cancel semantic and it appears that 11.0.x, 12.0.x and 12.1.x are buggy. Cancelling was implemented in 12.0.x with a semantic close to 11.0.x (remove the buffer from the pool) but the mechanism is buggy. Then it was decided to implement it correctly for 12.1.x (hence the changes around So we now have:
|
@lorban can you re-review this branch and tell me exactly what you think are the current "broken write cancelling mechanism"? I've forgotten what we discuss last time we hungout on this. |
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
@gregw just to be sure: I was speaking about Here is what can happen for H2 that I call broken:
|
…tate 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]>
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]>
@gregw The H1 implementation has been reworked and now contains tests. What this PR lacks before it can be considered complete is some tests for the H2 impl, 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]>
Added a cancel write/send semantic so that buffers for failed writes need not be removed from the pool