-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8302732: sun/net/www/http/HttpClient/MultiThreadTest.java still failing intermittently #12676
Conversation
👋 Welcome back djelinski! A progress list of the required criteria for merging this PR into |
@djelinski The following label will be automatically applied to this pull request:
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. |
Webrevs
|
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.
Looks reasonable to me. Good analysis. But now that the cacheLock
is used everywhere, do we still need the other lock in the ClientVector
? It seems that all accesses to the client vector are already protected by the coarser cacheLock
.
@djelinski 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 65 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 |
You're right, all accesses to ClientVector use the cacheLock. I removed the vector lock. |
KeepAliveCache.logger.finest(msg); | ||
} | ||
return e.hc; | ||
// check the most recent connection, use if still valid |
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 might be prudent to assert that the global cacheLock is held by the current thread in get & put (if that's feasible without too much hackery). Just worrying about future maintainers possibly modifying this code and using ClientVector outside of the lock. The assert would make sure they ponder the consequences.
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.
Asserts added; let me know if the amount of hackery involved looks acceptable.
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.
Looks reasonable. I personally dislike having several top-level classes in the same file so I'd say having ClientVector as an inner class is a plus. Having ClientVector carry a (hidden) pointer to its parent instance shouldn't be an issue since ClientVector shouldn't escape. I'd say this is good, provided that the modified test still passes. Otherwise, we can replace the assert with a simple comment, to warn that the class is not thread-safe and should not be used outside of blocks protected by the cacheLock.
/integrate |
Going to push as commit a2c5a4a.
Your commit was automatically rebased without conflicts. |
@djelinski Pushed as commit a2c5a4a. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please review this fix for a race in KeepAliveCache.
The sweeper thread (
KeepAliveCache.run()
) terminates when the cache is empty. The check for empty cache was performed without holding the cache lock. As a result, there was a small window of time where a new connection could be added to the cache while the sweeper thread was stopping. The added connection would then be removed from cache without closing when a new sweeper thread was started.As an additional observation, the check for empty cache was performed after sweeping. The cache could be empty because all connections were closed, or because all connections were busy. In the latter case, a new thread was created soon after the old one terminated.
This patch addresses both these issues. The sweeper thread makes the decision to terminate while holding the lock, and other threads are aware of that when they acquire the lock. Also, the sweeper thread only terminates if the cache is empty AND there was no cache activity in the last
LIFETIME
(5 seconds).Tier1-3 clean. No new tests, the issue was very hard to reproduce without adding delays in production code..
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12676/head:pull/12676
$ git checkout pull/12676
Update a local copy of the PR:
$ git checkout pull/12676
$ git pull https://git.openjdk.org/jdk pull/12676/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12676
View PR using the GUI difftool:
$ git pr show -t 12676
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12676.diff