twosoy commented on issue #22214: URL: https://github.com/apache/shardingsphere/issues/22214#issuecomment-1319364237
@caqhy Nacos Repository still throws 'Wait value availability timeout exceeded' Exception!!!!! ``` yaml retryIntervalMilliseconds:2000 maxRetries:5 ``` > There are three steps to persist '/metadata/logic_db/active_version' s1: persist /metadata s2: /metadata/logic_db s3: /metadata/logic_db/active_version But,After persist,only ‘/metadata/logic_db/active_version’ in service。 The subsequent persistence operation overwrites the previous value。 The service meta of 'PERSISTENT' is ``` +08:00=1668726902989 /metadata/logic_db/active_version=0 ``` <img width="1324" height = "159" alt="image" src="https://user-images.githubusercontent.com/26370775/202583836-59865d1f-062a-4758-b7dc-6938192f6334.png"> waitValue method throws 'NacosException',because of There are three pieces of data for generation persistence, but actually there is only one piece。 *NacosRepository.java* ``` java @SneakyThrows(InterruptedException.class) private void waitValue(final Collection<KeyValue> keyValues) throws NacosException { if (!isAvailable(keyValues)) { long retryIntervalMilliseconds = nacosProps.getValue(NacosPropertyKey.RETRY_INTERVAL_MILLISECONDS); int maxRetries = nacosProps.getValue(NacosPropertyKey.MAX_RETRIES); for (int retry = 0; retry < maxRetries; retry++) { Thread.sleep(getSleepTimeMs(retry, retryIntervalMilliseconds)); if (isAvailable(keyValues)) { return; } } throw new NacosException(NacosException.RESOURCE_NOT_FOUND, "Wait value availability timeout exceeded"); } } private boolean isAvailable(final Collection<KeyValue> keyValues) throws NacosException { Map<Boolean, List<KeyValue>> keyValueMap = keyValues.stream().collect(Collectors.groupingBy(KeyValue::isEphemeral)); for (Entry<Boolean, List<KeyValue>> entry : keyValueMap.entrySet()) { ServiceMetadata service = serviceController.getService(entry.getKey()); Map<String, List<Instance>> instanceMap = client.getAllInstances(service.getServiceName(), false).stream().collect(Collectors.groupingBy(NacosMetaDataUtil::getKey)); keyValues.removeIf(keyValue -> { Collection<Instance> instances = instanceMap.get(keyValue.getKey()); String value = keyValue.getValue(); return CollectionUtils.isNotEmpty(instances) ? instances.stream().anyMatch(instance -> StringUtils.equals(NacosMetaDataUtil.getValue(instance), value)) : Objects.isNull(value); }); } return keyValues.isEmpty(); } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
