Ensure that components configs are used
.. even if the subscriber got a newer generation than the
bootstrap subscriber for some reason.
@@ -81,7 +81,21 @@ public final class ConfigRetriever {
if (newestBootstrapGeneration < leastGeneration) {
return Optional.empty();
}
- return bootstrapConfigIfChanged();
+ return bootstrapConfigIfChanged()
+ // At this point, we normally assume that the bootstrap subscriber is one generation ahead
+ // of the component subscriber, but this is not always the case in practice.
+ .or(this::componentsSnapshotReceivedBeforeBootstrap);
+ }
+
+ private Optional<ConfigSnapshot> componentsSnapshotReceivedBeforeBootstrap() {
+ if (componentSubscriber.generation() == bootstrapSubscriber.generation()) {
+ // The component subscriber originally had a newer config generation than the bootstrap subscriber.
+ // Ensure that this generation is applied if it contains changed configs.
+ // The root cause is probably that the component subscriber skipped a generation and got
+ // one ahead of the bootstrap subscriber.
+ return componentsConfigIfChanged();
+ }
+ return Optional.empty();
}
private Optional<ConfigSnapshot> getComponentsSnapshot(long leastGeneration, boolean isInitializing) {
