summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-07-13 15:21:09 +0200
committerjonmv <venstad@gmail.com>2023-07-13 15:21:09 +0200
commit7c3c3476049c0629b79ad85af4ac583f68178910 (patch)
tree473a8d9d32940ddddc16aa884a8a5d9b52e59e30 /node-repository
parente2e7fc4f5c49451a210ca681416c848cb9ed7377 (diff)
Handle ZK node deleted after stat read, while updating cache
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDb.java10
1 files changed, 4 insertions, 6 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDb.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDb.java
index 92faacbca23..c388273b1a6 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDb.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDb.java
@@ -258,12 +258,10 @@ public class CuratorDb {
Pair<Integer, Node> cached = cachedNodes.getIfPresent(path);
if (cached != null && cached.getFirst().equals(stat)) return cached.getSecond();
cachedNodes.invalidate(path);
- try {
- return cachedNodes.get(path, () -> new Pair<>(stat, read(path, nodeSerializer::fromJson).get())).getSecond();
- }
- catch (ExecutionException e) {
- throw new UncheckedExecutionException(e.getCause());
- }
+ Optional<Node> node = session.getData(path).filter(data -> data.length > 0).map(nodeSerializer::fromJson);
+ if (node.isEmpty()) return null;
+ cachedNodes.put(path, new Pair<>(stat, node.get()));
+ return node.get();
});
}