You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have request monitoring for eureka server,and I found that /eureka/apps/ has irregular traffic surges, like this:
Then I checked the source code and learned about the update mechanism. I found that the following code seemed to have a bug.
the code from com.netflix.discovery.DiscoveryClient#updateDelta
privatevoidupdateDelta(Applicationsdelta) {
intdeltaCount = 0;
for (Applicationapp : delta.getRegisteredApplications()) {
for (InstanceInfoinstance : app.getInstances()) {
Applicationsapplications = getApplications();
StringinstanceRegion = instanceRegionChecker.getInstanceRegion(instance);
if (!instanceRegionChecker.isLocalRegion(instanceRegion)) {
ApplicationsremoteApps = remoteRegionVsApps.get(instanceRegion);
if (null == remoteApps) {
remoteApps = newApplications();
remoteRegionVsApps.put(instanceRegion, remoteApps);
}
applications = remoteApps;
}
++deltaCount;
if (ActionType.ADDED.equals(instance.getActionType())) {
ApplicationexistingApp = applications.getRegisteredApplications(instance.getAppName());
if (existingApp == null) {
//⭐️⭐️⭐️attention here! if existingApp == null, it will set whole application from delta. but the application from delta may contain multiple instances. Maybe contain instances with status down.applications.addApplication(app);
}
logger.debug("Added instance {} to the existing apps in region {}", instance.getId(), instanceRegion);
applications.getRegisteredApplications(instance.getAppName()).addInstance(instance);
} elseif (ActionType.MODIFIED.equals(instance.getActionType())) {
ApplicationexistingApp = applications.getRegisteredApplications(instance.getAppName());
if (existingApp == null) {
//⭐️⭐️⭐️same problem also arises here applications.addApplication(app);
}
logger.debug("Modified instance {} to the existing apps ", instance.getId());
applications.getRegisteredApplications(instance.getAppName()).addInstance(instance);
} elseif (ActionType.DELETED.equals(instance.getActionType())) {
ApplicationexistingApp = applications.getRegisteredApplications(instance.getAppName());
if (existingApp != null) {
logger.debug("Deleted instance {} to the existing apps ", instance.getId());
existingApp.removeInstance(instance);
/* * We find all instance list from application(The status of instance status is not only the status is UP but also other status) * if instance list is empty, we remove the application. */if (existingApp.getInstancesAsIsFromEureka().isEmpty()) {
applications.removeApplication(existingApp);
}
}
}
}
}
logger.debug("The total number of instances fetched by the delta processor : {}", deltaCount);
getApplications().setVersion(delta.getVersion());
getApplications().shuffleInstances(clientConfig.shouldFilterOnlyUpInstances());
for (Applicationsapplications : remoteRegionVsApps.values()) {
applications.setVersion(delta.getVersion());
applications.shuffleInstances(clientConfig.shouldFilterOnlyUpInstances());
}
}
and when calculate ReconcileHashCode
publicvoidpopulateInstanceCountMap(Map<String, AtomicInteger> instanceCountMap) {
for (Applicationapp : this.getRegisteredApplications()) {
//⭐️⭐️⭐️,it use getInstancesAsIsFromEureka(), this function will get instance in real time.for (InstanceInfoinfo : app.getInstancesAsIsFromEureka()) {
AtomicIntegerinstanceCount = instanceCountMap.computeIfAbsent(info.getStatus().name(),
k -> newAtomicInteger(0));
instanceCount.incrementAndGet();
}
}
}
At this time, if this application had only one instance before, the instance whose execution status is down will delete the local application, but an instance whose execution status is up will re-add the down service to the application's instances. calculating ReconcileHashCode will be inconsistent with the one in delta.
Please help me, did I understand it wrong? thranks.
The text was updated successfully, but these errors were encountered:
sorry for my poor English.
environment:
eureka-server: 1.7.2
eureka-client: 2.0.1
I have request monitoring for eureka server,and I found that /eureka/apps/ has irregular traffic surges, like this:
Then I checked the source code and learned about the update mechanism. I found that the following code seemed to have a bug.
the code from com.netflix.discovery.DiscoveryClient#updateDelta
and when calculate ReconcileHashCode
so, if I have a service, Go register immediately after unregister, I might get a delta like this:
At this time, if this application had only one instance before, the instance whose execution status is down will delete the local application, but an instance whose execution status is up will re-add the down service to the application's instances. calculating ReconcileHashCode will be inconsistent with the one in delta.
Please help me, did I understand it wrong? thranks.
The text was updated successfully, but these errors were encountered: