alex-plekhanov commented on code in PR #11616: URL: https://github.com/apache/ignite/pull/11616#discussion_r1816489585
########## modules/core/src/main/java/org/apache/ignite/internal/processors/configuration/distributed/DistributedConfigurationProcessor.java: ########## @@ -94,12 +98,64 @@ public DistributedConfigurationProcessor(GridKernalContext ctx) { //Switch to cluster wide update action and do it on already registered properties. switchCurrentActionTo(CLUSTER_WIDE_UPDATE); - isp.getDistributedConfigurationListeners() - .forEach(DistributedConfigurationLifecycleListener::onReadyToWrite); + IgniteInternalFuture<Void> initFut = initDefaultPropertiesValues(); + + // Notify registered listeners only after propagation of default values. + // Can't wait for initFut in the current thread, since it can block discovery and deadlock is possible. + initFut.listen(fut -> isp.getDistributedConfigurationListeners() + .forEach(DistributedConfigurationLifecycleListener::onReadyToWrite)); } }); } + /** Init default values for distributed properties. */ + private IgniteInternalFuture<Void> initDefaultPropertiesValues() { + Map<String, ?> dfltVals = ctx.config().getDistributedPropertiesDefaultValues(); + + if (F.isEmpty(dfltVals)) + return new GridFinishedFuture<>(); + + GridCompoundFuture<Void, Void> compFut = new GridCompoundFuture<>() { + @Override protected boolean ignoreFailure(Throwable err) { + // Do not complete the entire compound future if any property failed. + return true; + } + }; + + for (Map.Entry<String, ?> entry : dfltVals.entrySet()) { + DistributedChangeableProperty<Serializable> prop = props.get(entry.getKey()); + + if (prop == null) { + log.warning("Cannot set default value for distributed property '" + entry.getKey() + + "', property is not registered"); + + continue; + } + + if (prop.get() != null) + continue; + + try { + Serializable val = entry.getValue() instanceof String ? prop.parse((String)entry.getValue()) : + (Serializable)entry.getValue(); + + IgniteInternalFuture<?> fut = prop.propagateAsync(null, val); + + fut.listen(f -> { + if (f.error() != null) + log.error("Cannot set default value for distributed property '" + prop.getName() + '\'', f.error()); + }); + + compFut.add((IgniteInternalFuture<Void>)fut); + } + catch (Exception e) { + log.error("Cannot initiate setting default value for distributed property '" + prop.getName() + '\'', e); Review Comment: It's a current behaviour for `DistributedConfigurationUtils#setDefaultValue`, which is used by some subsystems to set default values in `onReadyToWrite`. -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org