Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-8451

NPE when writetime() or ttl() are nested inside function call

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 2.0.12, 2.1.3
    • None
    • None
    • Low

    Description

      When the writetime() or ttl() functions are nested inside another function, the query will result in a NullPointerException:

      cqlsh> select bigintAsBlob(writetime(durable_writes)) from system.schema_keyspaces;
      <ErrorMessage code=0000 [Server error] message="java.lang.NullPointerException">
      

      Here's the stacktrace:

      ERROR 00:14:56 Unexpected exception during request
      java.lang.NullPointerException: null
      	at org.apache.cassandra.cql3.statements.Selection$WritetimeOrTTLSelector.compute(Selection.java:538) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.Selection$FunctionSelector.compute(Selection.java:462) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.Selection$SelectionWithProcessing.handleRow(Selection.java:434) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.Selection$ResultSetBuilder.newRow(Selection.java:331) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.SelectStatement.processColumnFamily(SelectStatement.java:1243) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.SelectStatement.process(SelectStatement.java:1177) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.SelectStatement.processResults(SelectStatement.java:274) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:213) ~[main/:na]
      	at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:62) ~[main/:na]
      	at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:238) ~[main/:na]
      	at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:260) ~[main/:na]
      	at org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:119) ~[main/:na]
      	at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:439) [main/:na]
      	at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:335) [main/:na]
      	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-all-4.0.23.Final.jar:4.0.23.Final]
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [netty-all-4.0.23.Final.jar:4.0.23.Final]
      	at io.netty.channel.AbstractChannelHandlerContext.access$700(AbstractChannelHandlerContext.java:32) [netty-all-4.0.23.Final.jar:4.0.23.Final]
      	at io.netty.channel.AbstractChannelHandlerContext$8.run(AbstractChannelHandlerContext.java:324) [netty-all-4.0.23.Final.jar:4.0.23.Final]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_40]
      	at org.apache.cassandra.concurrent.AbstractTracingAwareExecutorService$FutureTask.run(AbstractTracingAwareExecutorService.java:164) [main/:na]
      	at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:105) [main/:na]
      	at java.lang.Thread.run(Thread.java:724) [na:1.7.0_40]
      

      Basically, it's failing to collect timestamps (or TTLs) when the function is wrapped. A similar query that additionally selects writetime() directly will succeed (because the timestamps will get collected):

      cqlsh> select bigintAsBlob(writetime(durable_writes)), writetime(durable_writes) from system.schema_keyspaces ;
      
       bigintAsBlob(writetime(durable_writes)) | writetime(durable_writes)
      -----------------------------------------+---------------------------
                            0x000509d1865c67f9 |          1418170390571001
                            0x0000000000000000 |                         0
      

      Attachments

        1. 8451-2.0.txt
          3 kB
          Tom Hobbs

        Activity

          People

            thobbs Tom Hobbs
            thobbs Tom Hobbs
            Tom Hobbs
            Benjamin Lerer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: