Requesting help for incorrect connected nodes metric when session is closed and re-initted.
Setup
Java 8
Java Driver Version: 4.15.0
Cassandra Server: 4.X
3 nodes in Azure West
Steps to reproduce the issue
1. Init the CQLSession succesfully.
2. Observe the connected nodes metric is 3.
3. Stop the session gracefully by calling: session.closeAsync() and wait for few seconds for close.
4. Reinit the CQLSession and monitor the connected nodes metric. It goes down to 1.
On Cassandra Server side, we are able to observe connections made to all 3 nodes. Upon further debugging by putting some log statements, it appears the NodeStateManager updates its open connection count to 3, however MetaDataManager does not show all 3 nodes have active connections. The code below in MetaDatamanager gives count as 1. Please let me know if more info is needed.
protected int connectedNodes() {
int count = 0;
for (Node node : context.getMetadataManager().getMetadata().getNodes().values()) {
node.hashCode());
if (node.getOpenConnections() > 0) {
count++;
}
}
return count;
}