Michael Theroux created CASSANDRA-14539:
-------------------------------------------

             Summary: cql2 insert/update/batch statements don't function unless 
the keyspace is specified in the statement
                 Key: CASSANDRA-14539
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-14539
             Project: Cassandra
          Issue Type: Bug
          Components: CQL
            Reporter: Michael Theroux
             Fix For: 2.1.x
         Attachments: cql2.diff

If you perform a cql2 statement without a keyspace, the following assertion 
will occur:

java.lang.AssertionError: null
 at org.apache.cassandra.config.Schema.getCFMetaData(Schema.java:243) 
~[apache-cassandra-2.1.20.jar:2.1.20]
 at 
org.apache.cassandra.cql.Attributes.maybeApplyExpirationDateOverflowPolicy(Attributes.java:81)
 ~[apache-cassandra-2.1.20.jar:2.1.20]
 at 
org.apache.cassandra.cql.AbstractModification.getTimeToLive(AbstractModification.java:95)
 ~[apache-cassandra-2.1.20.jar:2.1.20]
 at 
org.apache.cassandra.cql.UpdateStatement.mutationForKey(UpdateStatement.java:201)
 ~[apache-cassandra-2.1.20.jar:2.1.20]
 at 
org.apache.cassandra.cql.UpdateStatement.prepareRowMutations(UpdateStatement.java:154)
 ~[apache-cassandra-2.1.20.jar:2.1.20]
 at 
org.apache.cassandra.cql.UpdateStatement.prepareRowMutations(UpdateStatement.java:125)
 ~[apache-cassandra-2.1.20.jar:2.1.20]
 at 
org.apache.cassandra.cql.QueryProcessor.processStatement(QueryProcessor.java:544)
 ~[apache-cassandra-2.1.20.jar:2.1.20]
 at org.apache.cassandra.cql.QueryProcessor.process(QueryProcessor.java:802) 
~[apache-cassandra-2.1.20.jar:2.1.20]
 at 
org.apache.cassandra.thrift.CassandraServer.execute_cql_query(CassandraServer.java:1962)
 ~[apache-cassandra-2.1.20.jar:2.1.20]
 at 
org.apache.cassandra.thrift.Cassandra$Processor$execute_cql_query.getResult(Cassandra.java:4558)
 ~[apache-cassandra-thrift-2.1.20.jar:2.1.20]
 at 
org.apache.cassandra.thrift.Cassandra$Processor$execute_cql_query.getResult(Cassandra.java:4542)
 ~[apache-cassandra-thrift-2.1.20.jar:2.1.20]
 at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39) 
~[libthrift-0.9.2.jar:0.9.2]
 at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39) 
~[libthrift-0.9.2.jar:0.9.2]
 at 
org.apache.cassandra.thrift.CustomTThreadPoolServer$WorkerProcess.run(CustomTThreadPoolServer.java:206)
 ~[apache-cassandra-2.1.20.jar:2.1.20]
 at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
~[na:1.8.0_151]
 at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
~[na:1.8.0_151]

 

It will fail with:

    use test;

    update users set 'test'='\{"d":1529683115340}' where 
key='c426f519100da4cb24417bc87c5bfbd6' ;

But will work fine with:

    update test.users set 'test'='\{"d":1529683115340}' where 
key='c426f519100da4cb24417bc87c5bfbd6' ;

 

Going through the code, looks like this was introduced with 
https://issues.apache.org/jira/browse/CASSANDRA-14092 in February 2018.

In org.apache.cassandra.cql.AbstractNotification.getTimeToLive(), and 
org.apache.cassandra.cql.BatchStatement.getTimeToLive()

cassandra is using the keyspace associated with the update statement, which is 
set to null if its not in the query itself.

I resolved this myself locally by changing the getTimeToLive() methods to take 
a default keyspace, and use that if it is unavailable on the statement.  The 
fix looked fairly simple.  I've attached my diff.

P.S. Yes, I realize that cql2 is deprecated, and no longer supported, however I 
wanted to get this in if someone else hits it as I was unable to find any other 
reports for this issue.

 

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to