Skip to content

Conversation

@jaikiran
Copy link
Member

@jaikiran jaikiran commented Aug 2, 2024

Can I please get a review of this change which fixes the issue noted in https://bugs.openjdk.org/browse/JDK-8335181?

As noted in that issue, the current implementation in the java.net.http.HttpClient doesn't correctly handle an incoming GOAWAY frame. The HTTP3 RFC https://www.rfc-editor.org/rfc/rfc9113#name-goaway notes the specifics on what the expectations are when an endpoint receives a GOAWAY frame from the peer.

Before the changes proposed in this PR, the HttpClient implementation would (incorrectly) shutdown the connection and abort requests when a GOAWAY frame was received. The changes in this PR fixes that by retrying relevant unprocessed requests (if any) and not initiating any new streams on the connection.

A new test has been introduced to exercise this detail. The test continues to pass along with other existing tests. tier testing as well as a repeated testing (with test-repeat 50) is currently in progress with this change.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8335181: Incorrect handling of HTTP/2 GOAWAY frames in HttpClient (Bug - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20442/head:pull/20442
$ git checkout pull/20442

Update a local copy of the PR:
$ git checkout pull/20442
$ git pull https://git.openjdk.org/jdk.git pull/20442/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20442

View PR using the GUI difftool:
$ git pr show -t 20442

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20442.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 2, 2024

👋 Welcome back jpai! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Aug 2, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 2, 2024
@openjdk
Copy link

openjdk bot commented Aug 2, 2024

@jaikiran The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the net net-dev@openjdk.org label Aug 2, 2024
@mlbridge
Copy link

mlbridge bot commented Aug 2, 2024

Webrevs

@jaikiran
Copy link
Member Author

jaikiran commented Aug 2, 2024

I'm investigating an intermittent failure that happened once with this change. I will update this PR once I have additional details.

@jaikiran
Copy link
Member Author

jaikiran commented Aug 6, 2024

I've updated the PR to address the intermittent failure in the new test. The test now consistently passes in several hundred repeat runs.

In the updated PR, I have updated the client to even handle REFUSED_STREAM error code in a RST_FRAME. The RFC states that REFUSED_STREAM indicates that the server hasn't processed the request and the client is free to retry the request afresh. The HttpClient code has been updated to handle REFUSED_STREAM in a similar manner to GOAWAY, except that in the REFUSED_STREAM case we only mark (and retry) that current stream as unprocessed.

The test server has also been enhanced to send out REFUSED_STREAM errors in RST_FRAME to exercise this change.

Finally, with the support for GOAWAY handling in the client, it's now possible that a stream might be unregisters from the WindowController before request headers are sent on that stream and thus the WindowController required an update to not "assert" the presence of the stream being removed in the streams map.

With all these changes in the latest PR, this test (and all existing tests in java/net/httpclient) continue to pass in several test repeat runs.

Comment on lines 646 to 653
// A REFUSED_STREAM error code implies that the stream wasn't processed by the
// peer and the client is free to retry the request afresh.
// Here we arrange for the request to be retried.
markUnprocessedByPeer();
errorRef.compareAndSet(null, new IOException("request not processed by peer"));
if (debug.on()) {
debug.log("request unprocessed by peer (REFUSED_STREAM) " + this.request);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.... Should we just call:

    closeAsUnprocessed():
    return;

here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now updated this PR to follow this suggestion. The finally block which does connection.decrementStreamsCount(streamid); is needed (otherwise the HttpClient close() doesn't complete), so I haven't changed that part.

With the latest state of this PR, a test-repeat 50 of java/net/httpclient tests continues to pass without any failures.

Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the previous comment about calling closeAsUnprocessed() this looks good to me.

jaikiran and others added 14 commits August 13, 2024 16:40
Co-authored-by: Fei Yang <fyang@openjdk.org>
Reviewed-by: vlivanov, adinn
Reviewed-by: aivanov, stuefe, prr
Kim Barrett and others added 26 commits August 13, 2024 17:30
….java fails with release build

Reviewed-by: chagedorn, thartmann
…after JDK-8338058

Reviewed-by: mdoerr, clanger
Reviewed-by: kbarrett, tschatzl, shade
…oken after JDK-8333840

Reviewed-by: chagedorn, thartmann, kvn
…AD_MUTEX_INITIALIZER

Reviewed-by: dholmes, dlong
…on_failure) failed: Has low-order bits set

Reviewed-by: stefank, eosterlund, aboldtch
…n failing due to a LinkageError or other errors

Reviewed-by: alanb
@jaikiran
Copy link
Member Author

Looks like I did some mistake with a "git merge" command locally when trying to refresh this PR with latest mainline changes. I'll close this one and open a new one with only the relevant commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

net net-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.