Skip to content

Commit 6794c38

Browse files
authored
JAVA-2057: Do not create pool when SUGGEST_UP topology event received (apache#1149)
Motivation: There is a small window where a NEW_NODE event may be sent over the control connection while a pool is initializing. This is more likely to happen in testing, where a cluster is brought up and the driver connects to it immediately. In this case, the driver would erroneously create another pool, which would create additional connections. The first pool created between the currently initializing one and the new one being created would be untracked with its connections remanining open even after the Session is closed. Modifications: Change onTopologyEvent to no longer call createOrReconnectPool, instead only call reconnectNow() if there is an already established pool. initializing pool future present in the pending map. Result: SUGGEST_UP events now only trigger reconnect on existing pool, and will no longer create a new pool.
1 parent 0037cd3 commit 6794c38

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### 4.0.0-beta3 (in progress)
66

7+
- [bug] JAVA-2057: Do not create pool when SUGGEST\_UP topology event received
78
- [improvement] JAVA-2049: Add shorthand method to SessionBuilder to specify local DC
89
- [bug] JAVA-2037: Fix NPE when preparing statement with no bound variables
910
- [improvement] JAVA-2014: Schedule timeouts on a separate Timer

core/src/main/java/com/datastax/oss/driver/internal/core/session/PoolManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ private void onTopologyEvent(TopologyEvent event) {
340340
if (node.getDistance() != NodeDistance.IGNORED) {
341341
LOG.debug(
342342
"[{}] Received a SUGGEST_UP event for {}, reconnecting pool now", logPrefix, node);
343-
createOrReconnectPool(node);
343+
ChannelPool pool = pools.get(node);
344+
if (pool != null) {
345+
pool.reconnectNow();
346+
}
344347
}
345348
}
346349
}

0 commit comments

Comments
 (0)