RFR: 8302732: sun/net/www/http/HttpClient/MultiThreadTest.java still failing intermittently [v3]
Daniel Jeliński
djelinski at openjdk.org
Thu Feb 23 15:13:23 UTC 2023
> 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..
Daniel Jeliński has updated the pull request incrementally with one additional commit since the last revision:
Add asserts
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/12676/files
- new: https://git.openjdk.org/jdk/pull/12676/files/bb5596cb..0337c28f
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=12676&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=12676&range=01-02
Stats: 75 lines in 2 files changed: 20 ins; 19 del; 36 mod
Patch: https://git.openjdk.org/jdk/pull/12676.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12676/head:pull/12676
PR: https://git.openjdk.org/jdk/pull/12676
More information about the net-dev
mailing list