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

NullPointerException when SELECTing token() on only one part of a two-part partition key

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Fixed
    • Fix Version/s: 4.0
    • Component/s: CQL/Interpreter
    • Labels:
      None
    • Environment:

      Using cqlsh 5.0.1 on a Mac OS X host system with Cassandra 3.11.3 running via Docker for Mac from the official cassandra:3.11.3 image.

    • Severity:
      Low

      Description

      I have the following schema:

      CREATE TABLE query_tests.cart_snapshots (
          cart_id uuid,
          realm text,
          snapshot_id timeuuid,
          state text,
          PRIMARY KEY ((cart_id, realm), snapshot_id)
      ) WITH CLUSTERING ORDER BY (snapshot_id DESC)
          AND bloom_filter_fp_chance = 0.01
          AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
          AND comment = ''
          AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
          AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
          AND crc_check_chance = 1.0
          AND dclocal_read_repair_chance = 0.1
          AND default_time_to_live = 0
          AND gc_grace_seconds = 864000
          AND max_index_interval = 2048
          AND memtable_flush_period_in_ms = 0
          AND min_index_interval = 128
          AND read_repair_chance = 0.0
          AND speculative_retry = '99PERCENTILE';
      

      In cqlsh, I try the following query:

      select token(cart_id) from cart_snapshots ;

      This results in cqlsh returning ServerError: java.lang.NullPointerException, and the following error in the server log:

      DC1N1_1  | ERROR [Native-Transport-Requests-1] 2019-01-16 12:17:52,075 QueryMessage.java:129 - Unexpected error during query
      DC1N1_1  | java.lang.NullPointerException: null
      DC1N1_1  |       at org.apache.cassandra.db.marshal.CompositeType.build(CompositeType.java:356) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.db.marshal.CompositeType.build(CompositeType.java:349) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.config.CFMetaData.serializePartitionKey(CFMetaData.java:805) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.functions.TokenFct.execute(TokenFct.java:59) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.selection.ScalarFunctionSelector.getOutput(ScalarFunctionSelector.java:61) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.selection.Selection$SelectionWithProcessing$1.getOutputRow(Selection.java:666) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.selection.Selection$ResultSetBuilder.getOutputRow(Selection.java:492) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.selection.Selection$ResultSetBuilder.newRow(Selection.java:458) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.processPartition(SelectStatement.java:860) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.process(SelectStatement.java:790) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.processResults(SelectStatement.java:438) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:416) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:289) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:117) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:224) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:255) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:240) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:116) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:517) [apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:410) [apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-all-4.0.44.Final.jar:4.0.44.Final]
      DC1N1_1  |       at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357) [netty-all-4.0.44.Final.jar:4.0.44.Final]
      DC1N1_1  |       at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:35) [netty-all-4.0.44.Final.jar:4.0.44.Final]
      DC1N1_1  |       at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:348) [netty-all-4.0.44.Final.jar:4.0.44.Final]
      DC1N1_1  |       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_181]
      DC1N1_1  |       at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run(AbstractLocalAwareExecutorService.java:162) [apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:109) [apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
      DC1N1_1  | ERROR [Native-Transport-Requests-1] 2019-01-16 12:17:52,076 ErrorMessage.java:384 - Unexpected exception during request
      DC1N1_1  | java.lang.NullPointerException: null
      DC1N1_1  |       at org.apache.cassandra.db.marshal.CompositeType.build(CompositeType.java:356) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.db.marshal.CompositeType.build(CompositeType.java:349) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.config.CFMetaData.serializePartitionKey(CFMetaData.java:805) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.functions.TokenFct.execute(TokenFct.java:59) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.selection.ScalarFunctionSelector.getOutput(ScalarFunctionSelector.java:61) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.selection.Selection$SelectionWithProcessing$1.getOutputRow(Selection.java:666) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.selection.Selection$ResultSetBuilder.getOutputRow(Selection.java:492) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.selection.Selection$ResultSetBuilder.newRow(Selection.java:458) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.processPartition(SelectStatement.java:860) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.process(SelectStatement.java:790) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.processResults(SelectStatement.java:438) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:416) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:289) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:117) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:224) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:255) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:240) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:116) ~[apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:517) [apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:410) [apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [netty-all-4.0.44.Final.jar:4.0.44.Final]
      DC1N1_1  |       at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:357) [netty-all-4.0.44.Final.jar:4.0.44.Final]
      DC1N1_1  |       at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:35) [netty-all-4.0.44.Final.jar:4.0.44.Final]
      DC1N1_1  |       at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:348) [netty-all-4.0.44.Final.jar:4.0.44.Final]
      DC1N1_1  |       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_181]
      DC1N1_1  |       at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run(AbstractLocalAwareExecutorService.java:162) [apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:109) [apache-cassandra-3.11.3.jar:3.11.3]
      DC1N1_1  |       at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
      

        Attachments

          Activity

            People

            • Assignee:
              djoshi3 Dinesh Joshi
              Reporter:
              manuelkiessling Manuel Kie├čling
              Authors:
              Dinesh Joshi
              Reviewers:
              Aleksey Yeschenko, Jon Meredith
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: