-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8292381: java/net/httpclient/SpecialHeadersTest.java fails with "ERROR: Shutting down connection: HTTP/2 client stopped" #9908
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
Conversation
…R: Shutting down connection: HTTP/2 client stopped"
👋 Welcome back dfuchs! A progress list of the required criteria for merging this PR into |
Webrevs
|
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof HttpTestRequestHeaders headers)) return false; | ||
return Objects.equals(entrySet(), headers.entrySet()); |
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 code confused me a bit initially. Each of the subclasses of HttpTestRequestHeaders
has a headers
private member and I misread this line to be comparing the headers entrySet with itself. Would it be better if we renamed this local variable (in the instanceof line above) to otherHeaders
to avoid any confusion?
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 doesn't this comment appears when I click on the "Files Changed" tab? Strange.
Anyway - yes - good point - will change headers
to other
- I agree it's confusing.
tasksFailed = true; | ||
out.printf(now() + "Task %s failed: %s%n", id, t); | ||
err.printf(now() + "Task %s failed: %s%n", id, t); | ||
FAILURES.putIfAbsent("Task " + id, t); |
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.
Hello Daniel, is the putIfAbsent
intentional here? I wouldn't expect the task id to repeat here (or would there be that many tasks that the long
id value overflows and repeats?).
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.
It's copy-pasted from other tests that use the same technique. Mainly we want to make sure we get the first error. I agree that putIfAbsent
might not been necessary but it doesn't hurt either: it makes it clear that the value associated with the key will not be overridden.
// expectation that the first HTTP/2 clear request | ||
// will be an upgrade | ||
if (shared != null) { | ||
TRACKER.track(shared); |
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.
Is it intentional that we track a shared client when it is being reset, instead of tracking it when we create it (a few lines later)? This is unlike a non-shared instance which we track when we create one.
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.
Yes - because the tracker will complain if any of the tracked client is still alive when check() is called. So the idea is to start tracking the shared client when we're no longer using it.
client = null; | ||
System.gc(); | ||
var error = TRACKER.check(500); | ||
if (error != null) throw error; |
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.
Given slowness on CI systems, would it be better to use the jtreg timeout factor here (and other similar places in other test methods) to adjust the 500ms
timeout? Or better still, perhaps just log a warning instead of throwing an error? After all this test's main goal is to verify the request headers and in that context it should be OK if some HttpClient(s) aren't gc collected by the time the test completes?
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 haven't observed any issue yet with using a 500ms
. Here or in other tests. And I do want to throw an error if a client doesn't cleanly exits. So if we get a failure here - we should look at what prevented the client from exiting - and if it looks like it might be that the GC didn't get enough cycle then we would raise the timeout.
.proxy(NO_PROXY) | ||
.sslContext(sslContext) | ||
.build(); | ||
HttpClient client = newHttpClient("testHomeMadeIllegalHeader", sameClient); |
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.
Previously before this change, this test method wasn't using the sameClient
param while creating the new client and instead was creating it always. I don't know if that was intentional (in fact it wasn't even using the headerNameAndValue
param being passed to it). Is this change to use the sameClient
param while creating this client here, intentional?
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.
yes - before that the method would be running twice with a brand new client. I believe that was an oversight. I don't think that sameClient=true|false matters much here, which probably explains why the sameClient parameters was ignored. We could create a special provider that doesn't pass sameClient, but since this method should be quite short I decided to simply change it to take the value of sameClient
into account.
Additionally, the |
Overall, I understand these changes but I'm still a bit surprised with the way this test failed on the CI system especially after how we try to stop/close the relevant resources (like the SelectorManager thread) as soon as we realize the client is no longer used and doesn't have any pending operations. |
This is a test bug. We only add a |
Yes I agree the OOM was surprising. We never had that before and we didn't change anything in the client recently. Maybe that was a new machine with lower specs. Making these tests less greedy in resources is a worthwhile goal however. |
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 don't really understand why the test (originally) needed to create so many clients. Wouldn't it be easier and more maintainable to only create the minimum number of clients?
Yeah - maybe. But there are differences between a brand new client and 'used' client: one may go through the upgrade when using h2c where the other might not because it might already have a connection opened. These tests are what there are. They did help flush a number of race conditions over the time that we might not have seen if we had simpler tests. |
I pushed the requested changes to the PR branch. |
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.
Thank you for the changes, Daniel. Looks fine to me.
@dfuch This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 27 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit 256b523.
Your commit was automatically rebased without conflicts. |
Please find here a change that improves SpecialHeadersTest. This test creates a large amount of ephemeral clients and has been observed running out of heap space in our CI once. This change updates the test to wait for the previous HttpClient to be eligible for garbage collection before it creates a new one. It also verifies that no outstanding operation are still running on the client by the time the client is released.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9908/head:pull/9908
$ git checkout pull/9908
Update a local copy of the PR:
$ git checkout pull/9908
$ git pull https://git.openjdk.org/jdk pull/9908/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 9908
View PR using the GUI difftool:
$ git pr show -t 9908
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9908.diff