diff --git a/core/trino-main/src/main/java/io/trino/metadata/DiscoveryNodeManager.java b/core/trino-main/src/main/java/io/trino/metadata/DiscoveryNodeManager.java index ad5e834d83da..9fc9572e2b8a 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/DiscoveryNodeManager.java +++ b/core/trino-main/src/main/java/io/trino/metadata/DiscoveryNodeManager.java @@ -82,14 +82,11 @@ public final class DiscoveryNodeManager private final InternalNode currentNode; private final boolean allCatalogsOnAllNodes; - @GuardedBy("this") private Optional> activeNodesByCatalogHandle = Optional.empty(); - @GuardedBy("this") - private AllNodes allNodes; + private volatile AllNodes allNodes; - @GuardedBy("this") - private Set coordinators; + private volatile Set coordinators; @GuardedBy("this") private final List> listeners = new ArrayList<>(); @@ -305,7 +302,7 @@ private boolean isNodeShuttingDown(String nodeId) } @Override - public synchronized AllNodes getAllNodes() + public AllNodes getAllNodes() { return allNodes; } @@ -343,7 +340,7 @@ public Set getNodes(NodeState state) } @Override - public synchronized Set getActiveCatalogNodes(CatalogHandle catalogHandle) + public Set getActiveCatalogNodes(CatalogHandle catalogHandle) { // activeNodesByCatalogName is immutable return activeNodesByCatalogHandle @@ -352,7 +349,7 @@ public synchronized Set getActiveCatalogNodes(CatalogHandle catalo } @Override - public synchronized NodesSnapshot getActiveNodesSnapshot() + public NodesSnapshot getActiveNodesSnapshot() { return new NodesSnapshot(allNodes.getActiveNodes(), activeNodesByCatalogHandle); } @@ -364,7 +361,7 @@ public InternalNode getCurrentNode() } @Override - public synchronized Set getCoordinators() + public Set getCoordinators() { return coordinators; }