diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-12-12 11:52:09 +0100 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-12-12 11:52:09 +0100 |
commit | 1cc8aab2067235dea7e3e97e67797ec30a4430e5 (patch) | |
tree | 6a29ab358543ab967f94b2d0a94c17e0ac0e24ab /node-repository | |
parent | f454c77caea83aa8dd16e5a540493fca9cb6d014 (diff) |
Avoid writing a cache with an outdated counter from the start
Diffstat (limited to 'node-repository')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java index e8fb9781dcd..2ceffc54dd5 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabase.java @@ -116,11 +116,12 @@ public class CuratorDatabase { /** Invalidates the current cache if outdated. */ private CuratorDatabaseCache getCache() { - long generation = changeGenerationCounter.get(); - synchronized (cacheCreationLock) { - if (generation != cache.get().generation) - cache.set(newCache(generation)); - } + if (changeGenerationCounter.get() != cache.get().generation) + synchronized (cacheCreationLock) { + while (changeGenerationCounter.get() != cache.get().generation) + cache.set(newCache(changeGenerationCounter.get())); + } + return cache.get(); } |