apache / cassandra-gocql-driver

GoCQL Driver for Apache Cassandra®
https://cassandra.apache.org/
Apache License 2.0
2.58k stars 620 forks source link

AWS Keyspaces, gocql trying to insert into another keyspace #1472

Open antimack opened 4 years ago

antimack commented 4 years ago

Please answer these questions before submitting your issue. Thanks!

What version of Cassandra are you using?

AWS Keyspaces

What version of Gocql are you using?

github.com/gocql/gocql v0.0.0-20200526081602-cd04bd7f22a7

What did you do?

We are trying to run Cortex project which is using gocql library for Cassandra backend

What did you expect to see?

Application inserting rows into backend(AWS Keyspaces Cassandra) successfully without any errors

What did you see instead?

We have 2 keyspaces(development and staging) in the same region and two separate users with permissions for each keyspace. We can see that from time to time Cortex in staging environment is trying to insert rows in development keyspace.

In order to debug the issue we added a QueryObserver to understand what is going on, this is the ObservedQuery object that the observer receives:

{Keyspace: uswest2_staging_cortex Statement:INSERT INTO cortex_index_2638 (hash, range, value) VALUES (?, ?, ?) 
Start:2020-07-28 10:45:55.843311191 +0000 UTC m=+2531.820026503 End:2020-07-28 10:45:55.844599847 +0000 UTC 
m=+2531.821315142 Rows:0 Host:[HostInfo hostname="44.234.22.153" connectAddress="44.234.22.153" 
peer="44.234.22.153" rpc_address="44.234.22.153" broadcast_address="<nil>" preferred_ip="44.234.22.153" 
connect_addr="44.234.22.153" connect_addr_source="connect_address" port=9142 data_centre="us-west-2" 
rack="us-west-2" host_id="962eaeb8-1686-3633-a5f5-4623f49f5f15" version="v3.11.2" state=UP num_tokens=1] 
Metrics:0xc042b5ad50 Err:unconfigured table uswest2_development_cortex.cortex_index_2638 Attempt:0}

From the output we can see that keyspace is uswest2_staging_cortex but in the Err field we can see that it's complaining about uswest2_development_cortex keyspace.

martin-sucha commented 2 years ago

Hmm. Interesting issue. How do you set the keyspace? Do you use ClusterConfig.Keyspace? It would help to see network capture of the request in this case to see what the driver sent.