DataStax C# Driver: Default cluster name cache causes incorrect connections across Cassandra instances
10 views
Skip to first unread message
Andre Hofmeister
unread,
Apr 29, 2025, 12:02:26 PMApr 29
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DataStax C# Driver for Apache Cassandra User Mailing List
Hi,
we're running into a race-condition with the DataStax C# driver for Apache Cassandra, and I believe this is a general issue with the client implementation.
We're running multiple Apache Cassandra containers on the same host. It looks like the client caches connections based on the cluster name. If the connection string doesn't specify a cluster name, it uses the default cluster name.
Here's what happens:
Create an Apache Cassandra instance listening on localhost:51732 (container_1).
Create an Apache Cassandra instance listening on localhost:51742 (container_2).
Create a CqlConnection instance for container_1.
This creates a connection using the default cluster name: Cassandra Cluster.
Run tests against container_1, and tear it down afterwards.
Create a CqlConnection instance for container_2.
This is where the race-condition happens. It looks like the client implementation still tries to connect to container_1, even though the connection string is correctly set for container_2.
This could even lead to false assumptions. For example, if we didn't tear down container_1 beforehand, the client might end up connecting to the wrong instance.
From a quick look at the code, it seems like the cluster name is never removed from the internal dictionary during Close() or Dispose().
Is this desired? Any recommendations or guidance on how to deal with it?