Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to create keyspace in cassandra-cli

Tags:

cassandra

I have a simple single node cassandra setup (1.1.0) (default settings). Whenever I try to create a keyspace in cassandra-cli, I get the error: [default@unknown] create keyspace tax; org.apache.thrift.transport.TTransportException

In cassandra server log, the exception stacktrace: ERROR 12:15:04,722 Exception in thread Thread[MigrationStage:1,5,main]

java.lang.AssertionError
    at org.apache.cassandra.db.DefsTable.updateKeyspace(DefsTable.java:441)
    at org.apache.cassandra.db.DefsTable.mergeKeyspaces(DefsTable.java:339)
    at org.apache.cassandra.db.DefsTable.mergeSchema(DefsTable.java:269)
    at org.apache.cassandra.service.MigrationManager$1.call(MigrationManager.java:214)

I tried deleting the contents in ./var/lib/cassandra/data and restarting the server and my mac, but still ending up with same issue.

like image 434
bschandramohan Avatar asked Feb 20 '23 06:02

bschandramohan


2 Answers

Looks like the system keyspace was corrupted. Removing the data files from

  • /var/lib/cassandra/data
  • /var/lib/cassandra/commitlog
  • /var/lib/cassandra/saved_caches

and restarting the cassandra server fixed the issue. (The above directories are defined in $CASSANDRA_HOME/conf/cassandra.yaml)

like image 93
bschandramohan Avatar answered Feb 27 '23 12:02

bschandramohan


Following is the flow while adding the keyspace to Cassandra.(As per comments in Cassandrda source code. Correct me if I am getting it wrong)

1) At first step it check if any new keyspaces were added.

2) At second step we check if there were any keyspaces re-created, in this context re-created means that they were previously deleted but still exist in the low-level schema as empty keys

3) At final step we updating modified keyspaces and saving keyspaces drop them later.

While modifying Keyspace it calls to function "updateKeyspace" and here it seems if the keyspace metadata is corrupt it throws assertion error.

SO in your case it might be that you have deleted the same Keyspace and trying to recreate which was causing this issue or as you mentioned It was a Metadata corruption.

like image 27
samarth Avatar answered Feb 27 '23 10:02

samarth