-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
EurekaClientConfigurationRefresher & DiscoveryClient#refreshInstanceInfo concurrent execution #4094
Comments
It is recommended that the operation of querying the shared variable first and then updating it be locked here, and this problem has not been reproduced after the lock is currently added. @OlgaMaciaszek Can you give a little advice? void refreshInstanceInfo() {
applicationInfoManager.refreshDataCenterInfoIfRequired();
applicationInfoManager.refreshLeaseInfoIfRequired();
// need lock here
synchronized (applicationInfoManager) {
InstanceStatus status;
try {
status = getHealthCheckHandler().getStatus(instanceInfo.getStatus());
} catch (Exception e) {
logger.warn("Exception from healthcheckHandler.getStatus, setting status to DOWN", e);
status = InstanceStatus.DOWN;
}
if (null != status) {
applicationInfoManager.setInstanceStatus(status);
}
}
} |
Hello, @yuhuangbin, thanks for reporting the issue. Will take a look next week. |
Hello, @OlgaMaciaszek , Is there a conclusion to this issue? |
Looks like a bug. |
This needs to be addressed within Netflix/Eureka |
Describe the bug
As we know, when
RefreshScopeRefreshedEvent
is published, service instances perform deregister and register actions.refer: EurekaDiscoveryClientConfiguration
deregister and register will call
ApplicationInfoManager#setInstanceStatus
to modifyInstanceStatus
.But, the DiscoveryClient will also be modified
InstanceStatus
by schedule task.So,
EurekaClientConfigurationRefresher
&DiscoveryClient#refreshInstanceInfo
concurrent execution causes concurrency issuesStep1 deregister instance then modify
InstanceStatus
toDOWN
byEurekaClientConfigurationRefresher
Step2 get
InstanceStatus
frominstanceInfo
isDOWN
byDiscoveryClient#refreshInstanceInfo()
Step3 deregister instance then modify
InstanceStatus
toUP
byEurekaClientConfigurationRefresher
Step4 modify
InstanceStatus
toDOWN
byDiscoveryClient#refreshInstanceInfo()
If the execution order is as above, the service
InstanceStatus
changes toDOWN
.The text was updated successfully, but these errors were encountered: