C# driver keyspace already exists exception

Hi. I moved from cassandra to yugabyte. This code was worked with latest cassandra c# driver, but generates exception with latest yugabyte c# driver:

 _cluster = Cluster.Builder()
                        .AddContactPoints(seeds)
                        .WithQueryOptions(new QueryOptions().SetConsistencyLevel(ConsistencyLevel.One))
                        .WithDefaultKeyspace("mykeyspace").Build(); 
Session = _cluster.ConnectAndCreateDefaultKeyspaceIfNotExists(ReplicationStrategies
                        .CreateSimpleStrategyReplicationProperty(replicationFactor));
------------
Cassandra.InvalidQueryException: 'Keyspace Already Exists. Keyspace 'mykeyspace' already exists
CREATE KEYSPACE "mykeyspace" 
^^^^^^
  WITH replication = {'class' : 'SimpleStrategy', 'replication_factor' : '1'} 
   AND durable_writes = true
 (ql error -307)'

Hi @victor,

Adding a few folks to see if they have any idea. cc @Oleg @mihnea @kannan

ConnectAndCreateDefaultKeyspaceIfNotExists function calls CreateKeyspaceIfNotExists which tries to create a keyspace and capture the exception. I think we fail on capturing the exception ?

Yugabyte response:

cqlsh> CREATE KEYSPACE e_xists WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;
cqlsh> CREATE KEYSPACE e_xists WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Keyspace Already Exists. Keyspace 'e_xists' already exists
CREATE KEYSPACE e_xists WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;
^^^^^^
 (ql error -307)"

Cassandra response:

cqlsh> CREATE KEYSPACE e_xists WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;
cqlsh> CREATE KEYSPACE e_xists WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;
AlreadyExists: Keyspace 'e_xists' already exists

@victor
For the meantime, can you execute connect to the cluster without creating a default keyspace ?
And issue a create keyspace "mykeyspace" if not exists ... and not

  1. “can you execute connect to the cluster without creating a default keyspace” - exception on connect because I defined default keyspace in cluster build.
  2. comment cluster build default keyspace definition:
    _cluster = Cluster.Builder()
    .AddContactPoints(seeds)
    .WithQueryOptions(new QueryOptions().SetConsistencyLevel(ConsistencyLevel.LocalQuorum))
    /*.WithDefaultKeyspace(“e_xists”)**/.Build();
  3. without “IF NOT EXISTS” - first connect: ok, second connect: exception “Keyspace Already Exists. Keyspace ‘e_xists’ already exists”
  4. with “IF NOT EXISTS” - first connect and next are ok.