-
Notifications
You must be signed in to change notification settings - Fork 925
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
Stop updating endpoints when HealthCheckedEndpointGroup
is closing
#6063
base: main
Are you sure you want to change the base?
Conversation
Motivation: When `HealthCheckedEndpointGroup` is closing, it clears the internal endpoints. https://github.com/line/armeria/blob/011741dc51cf328b78488655e78ceca1cdc0a1b3/core/src/main/java/com/linecorp/armeria/client/endpoint/healthcheck/DefaultHealthCheckerContext.java#L135 In fact, the closing process is not a problem. However, when the endpoints changes, the change is propagated to `EndpointSelector`. Some `EndpointSelector` implementations warn about the empty endpoints. https://github.com/line/armeria/blob/62da203bd9e11d669476e6999937352749cd7339/core/src/main/java/com/linecorp/armeria/client/endpoint/WeightedRoundRobinStrategy.java#L81 The warning is not a real problem but a false positive alarm. For better compatibility with `EndpointSelector` implementations, I propose to stop additional endpoints from being updated when `HealthCheckedEndpointGroup` is closed. As a result, `EndpointSelector` will not updated with empty endpoints. Modifications: - Stop updating endpoints when `HealthCheckedEndpointGroup` is closing Result: You no loger see a false positive warning log when `HealthCheckedEndpointGroup` is closing.
@@ -303,10 +303,17 @@ private void updateHealth(Endpoint endpoint, boolean health) { | |||
|
|||
// Each new health status will be updated after initialization of the first context group. | |||
if (updated && initialized) { |
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.
What do you think of not calling the updateHealth
at all from the DefaultHealthCheckerContext
?
private DefaultHealthCheckerContext newCheckerContext(Endpoint endpoint) {
return new DefaultHealthCheckerContext(endpoint, port, protocol, clientOptions, retryBackoff,
this::updateHealth, this);
}
DefaultHealthCheckerContext(Endpoint endpoint, int port, SessionProtocol protocol,
ClientOptions clientOptions, Backoff retryBackoff,
BiConsumer<Endpoint, Boolean> onUpdateHealth,
ListenableAsyncCloseable listenableAsyncCloseable) {
...
}
// Use listenableAsyncCloseable.isClosing( ) to check if the HealthCheckedEndpointGroup is closing or not.
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 realized that there's no heavy logic in the DefaultHealthCheckerContext
.
So probably just check isClosing()
in the updateHealth()
method would be enough.
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.
updateHealth()
is not the only method that calls setEndpoint()
. If a context is lazily initialized after HealthCheckedEndpointGroup
is closed, empty endpoints will be set to the delegate. That situation will not happen normally though.
Line 197 in d7a4d29
setEndpoints(allHealthyEndpoints()); |
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.
What I meant was adding the logic that checks isClosing()
instead of replacing the current location.
There is a logic that iterates the contextGroupChain
while holding a lock in updateHealth()
method and I thought we don't have to do this when isClosing()
is true
.
Line 250 in 62da203
private DefaultHealthCheckerContext findContext(Endpoint endpoint) { |
But, if it's a relatively light job you think, I'm fine with the current logic. 👍
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.
Understood, fixed.
Motivation:
When
HealthCheckedEndpointGroup
is closing, the internally managed endpoints are cleared.armeria/core/src/main/java/com/linecorp/armeria/client/endpoint/healthcheck/DefaultHealthCheckerContext.java
Line 135 in 011741d
EndpointSelector
. SomeEndpointSelector
implementations warn about the empty endpoints. The warning is not a real problem but a false positive alarm.armeria/core/src/main/java/com/linecorp/armeria/client/endpoint/WeightedRoundRobinStrategy.java
Line 81 in 62da203
For better compatibility with
EndpointSelector
implementations, I propose to stop additional endpoints from being updated whenHealthCheckedEndpointGroup
is closed. As a result,EndpointSelector
will not updated with empty endpoints.Modifications:
HealthCheckedEndpointGroup
is closingResult:
You no loger see a false positive warning log when
HealthCheckedEndpointGroup
is closing.