diff options
author | gjoranv <gv@verizonmedia.com> | 2020-07-13 16:50:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-13 16:50:35 +0200 |
commit | 45d1f3b8fd0b527b89f48f2f81c67d52df313d7b (patch) | |
tree | 74c7c555bd266fb4923b85c695647a9db327a4fd /configserver | |
parent | 7a1321a57a1e557d71c551b28ac03d29c32740c4 (diff) | |
parent | 709996b75fc18ceec01495658eff55ffedc750ee (diff) |
Merge pull request #13871 from vespa-engine/hmusum/handle-exceptions-when-notifying-completion
Handle notifyCompletion being called more than once for a session
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java index c520094e294..23300239d17 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java @@ -15,6 +15,7 @@ import org.apache.zookeeper.KeeperException; import java.time.Clock; import java.util.Optional; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -91,15 +92,22 @@ public class RemoteSession extends Session { try { completionWaiter.notifyCompletion(); } catch (RuntimeException e) { - // Throw only if we get something else than NoNodeException -- NoNodeException might happen when - // the session is no longer in use (e.g. the app using this session has been deleted) and this method - // has not been called yet for the previous session operation - // on a minority of the config servers (see awaitInternal() method in this class) - if (e.getCause().getClass() != KeeperException.NoNodeException.class) { + // Throw only if we get something else than NoNodeException or NodeExistsException. + // NoNodeException might happen when the session is no longer in use (e.g. the app using this session + // has been deleted) and this method has not been called yet for the previous session operation on a + // minority of the config servers. + // NodeExistsException might happen if an event for this node is delivered more than once, in that case + // this is a no-op + Set<Class<? extends KeeperException>> acceptedExceptions = Set.of(KeeperException.NoNodeException.class, + KeeperException.NodeExistsException.class); + Class<? extends Throwable> exceptionClass = e.getCause().getClass(); + if (acceptedExceptions.contains(exceptionClass)) + log.log(Level.INFO, "Not able to notify completion for session: " + getSessionId() + ", node " + + (exceptionClass.equals(KeeperException.NoNodeException.class) + ? "has been deleted" + : "already exists")); + else throw e; - } else { - log.log(Level.INFO, "Not able to notify completion for session: " + getSessionId() + ", node has been deleted"); - } } } |