diff options
author | gjoranv <gv@verizonmedia.com> | 2022-01-14 20:58:57 +0100 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2022-01-14 21:03:28 +0100 |
commit | 4516555a4cb1a533f8bb6627628cc414a33e3650 (patch) | |
tree | a9a22c583a0f7c4859aed444d3859793b2f25a60 /container-core/src | |
parent | 65dd293caa9e3ce30453ee0ae217ac2ee69c5385 (diff) |
Ensure that components configs are used
.. even if the subscriber got a newer generation than the
bootstrap subscriber for some reason.
Diffstat (limited to 'container-core/src')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/di/ConfigRetriever.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/di/ConfigRetriever.java b/container-core/src/main/java/com/yahoo/container/di/ConfigRetriever.java index aadaffe9acc..0817a87c506 100644 --- a/container-core/src/main/java/com/yahoo/container/di/ConfigRetriever.java +++ b/container-core/src/main/java/com/yahoo/container/di/ConfigRetriever.java @@ -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) { |