diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2023-07-13 15:21:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-13 15:21:24 +0200 |
commit | 22200b2167b991a2092ef56411c9086a5027f9e2 (patch) | |
tree | c43d27e6b081acd74fc0d6e4df68905e5ac2ce48 /node-repository | |
parent | 3c1db11cae9f0723b164b19cdb0ac17c6170c671 (diff) | |
parent | 7c3c3476049c0629b79ad85af4ac583f68178910 (diff) |
Merge pull request #27763 from vespa-engine/jonmv/handle-nodes-disappearing-after-stat-read
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.java | 10 |
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(); }); } |