-
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
Review HTTP client feature setRemoveIdleDestinations
#8493
Comments
@lorban here's an idea for fixing this issue.
boolean HttpDestination::stale() {
lock {
boolean stale = _stale;
if (!stale) {
_staleCount = 0;
}
return stale;
}
} Then, if boolean HttpDestination::sweep() {
boolean remove = false;
lock {
boolean stale = _exchanges.isEmpty() && _connectionPool.isEmpty();
if (stale)
++_staleCount;
else
_staleCount = 0;
if (_staleCount == 4) {
_stale = true;
remove = true;
}
}
if (remove) {
getHttpClient().removeDestination(this);
LifeCycle.stop(this);
}
return remove;
} The sweeper's attempt to remove/stop the destination gets pushed into the future every time
At this point we know that the stale destination cannot be referenced for new requests, and it is not processing any request (as it has been stale for 4 sweeper cycles) therefore it can be safely stopped. |
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]>
… branches Signed-off-by: Ludovic Orban <[email protected]>
…ing. Signed-off-by: Ludovic Orban <[email protected]>
Fixes #8493: RemoveIdleDestinations's race condition and improve logging. Signed-off-by: Ludovic Orban <[email protected]>
Jetty version(s)
9.4.x, 10.0.x+
Description
The
removeIdleDestinations
feature always was racy, but with the advent of #5218 the race went from benign to problematic, because thePool
object does not give back connections when it is closed.Also review why we use both
HttpDestination.close()
andHttpDestination.doStop()
to manage lifecycle, and whyHttpDestination
is both added as lifecycle bean and in aMap
withinHttpClient
.The text was updated successfully, but these errors were encountered: