[ https://issues.apache.org/jira/browse/SCB-165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16315597#comment-16315597 ]
ASF GitHub Bot commented on SCB-165: ------------------------------------ wujimin commented on a change in pull request #486: [SCB-165] Service registry not given proper instances URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/486#discussion_r160068678 ########## File path: service-registry/src/main/java/io/servicecomb/serviceregistry/client/IpPortManager.java ########## @@ -65,45 +66,47 @@ public IpPortManager(ServiceRegistryConfig serviceRegistryConfig, InstanceCacheM // we have to do this operation after the first time setup has already done public void initAutoDiscovery() { - if (this.serviceRegistryConfig.isRegistryAutoDiscovery()) { - instanceCache = instanceCacheManager.getOrCreate(REGISTRY_APP_ID, + if (!autoDiscoveryInited && this.serviceRegistryConfig.isRegistryAutoDiscovery()) { + instanceCacheManager.getOrCreate(REGISTRY_APP_ID, REGISTRY_SERVICE_NAME, DefinitionConst.VERSION_RULE_LATEST); + autoDiscoveryInited = true; } } - public IpPort getAvailableAddress(boolean invalidate) { - int index; - if (invalidate) { - index = currentAvailableIndex.incrementAndGet(); - } else { - index = currentAvailableIndex.get(); + public IpPort getNextAvailableAddress(IpPort failedIpPort) { + IpPort current = getAvailableAddress(); + if (current.equals(failedIpPort)) { + currentAvailableIndex.incrementAndGet(); Review comment: multiple threads all run with "current.equals(failedIpPort) return true", then cause inc multiple times so we should record old index when enter "public IpPort getNextAvailableAddress(IpPort failedIpPort)", and then assign currentAvailableIndex = old + 1 or use compareAndSet ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Service registry not given proper instances > -------------------------------------------- > > Key: SCB-165 > URL: https://issues.apache.org/jira/browse/SCB-165 > Project: Apache ServiceComb > Issue Type: Bug > Components: Java-Chassis > Reporter: liubao > > 1. when calling DynamicSchemaLoader at start up, and when the dependent > service is not registered when making calls, service center will not notify > client when service is registered. > 2. when autodiscovery is enabled and service center is not started, > microservice will start fail. > 3. when retrying in service center , if one instance failed, and when a lots > of calls to service center is made, next fallback address may have many > choose again to the failed instance. If this takes too long, will cause > instance idle and unregistered by service center. -- This message was sent by Atlassian JIRA (v6.4.14#64029)