[ 
https://issues.apache.org/jira/browse/CASSANDRA-10363?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14957009#comment-14957009
 ] 

Sam Tunnicliffe edited comment on CASSANDRA-10363 at 10/15/15 10:44 AM:
------------------------------------------------------------------------

I've attached a patch backporting this to 2.0, not for actually committing but 
so those unable to upgrade just yet can patch their own systems if necessary. 
The test changes the expectations for a few scenarios from the 2.1+ version 
because CASSANDRA-4911 isn't in 2.0 & so {{ORDER BY}} can only contain columns 
in the selection.

[branch|https://github.com/beobal/cassandra/tree/10363-2.0], 
[testall|http://cassci.datastax.com/view/Dev/view/beobal/job/beobal-10363-2.0-testall/],
 
[dtests|http://cassci.datastax.com/view/Dev/view/beobal/job/beobal-10363-2.0-dtest/]
 (test runs pending)

Edit: there are a few dtest failures in the run above, but checking these 
against 2.0 there aren't any new failures.


was (Author: beobal):
I've attached a patch backporting this to 2.0, not for actually committing but 
so those unable to upgrade just yet can patch their own systems if necessary. 
The test changes the expectations for a few scenarios from the 2.1+ version 
because CASSANDRA-4911 isn't in 2.0 & so {{ORDER BY}} can only contain columns 
in the selection.

[branch|https://github.com/beobal/cassandra/tree/10363-2.0], 
[testall|http://cassci.datastax.com/view/Dev/view/beobal/job/beobal-10363-2.0-testall/],
 
[dtests|http://cassci.datastax.com/view/Dev/view/beobal/job/beobal-10363-2.0-dtest/]
 (test runs pending)

> NullPointerException returned with select ttl(value), IN, ORDER BY and paging 
> off
> ---------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-10363
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10363
>             Project: Cassandra
>          Issue Type: Bug
>         Environment: Apache Cassandra 2.1.8.689
>            Reporter: Sucwinder Bassi
>            Assignee: Benjamin Lerer
>            Priority: Minor
>             Fix For: 2.1.x, 2.2.x, 3.0.x
>
>         Attachments: 10363-2.0-c4de752.txt
>
>
> Running this query with paging off returns a NullPointerException:
> cqlsh:test> SELECT value, ttl(value), last_modified FROM test where 
> useruid='userid1' AND direction IN ('out','in') ORDER BY last_modified; 
> ServerError: <ErrorMessage code=0000 [Server error] 
> message="java.lang.NullPointerException">
> Here's the stack trace from the system.log:
> ERROR [SharedPool-Worker-1] 2015-09-17 13:11:03,937  ErrorMessage.java:251 - 
> Unexpected exception during request
> java.lang.NullPointerException: null
>         at 
> org.apache.cassandra.db.marshal.LongType.compareLongs(LongType.java:41) 
> ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.db.marshal.TimestampType.compare(TimestampType.java:48) 
> ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.db.marshal.TimestampType.compare(TimestampType.java:38) 
> ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement$SingleColumnComparator.compare(SelectStatement.java:2419)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement$SingleColumnComparator.compare(SelectStatement.java:2406)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at java.util.TimSort.countRunAndMakeAscending(TimSort.java:351) 
> ~[na:1.8.0_40]
>         at java.util.TimSort.sort(TimSort.java:216) ~[na:1.8.0_40]
>         at java.util.Arrays.sort(Arrays.java:1512) ~[na:1.8.0_40]
>         at java.util.ArrayList.sort(ArrayList.java:1454) ~[na:1.8.0_40]
>         at java.util.Collections.sort(Collections.java:175) ~[na:1.8.0_40]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.orderResults(SelectStatement.java:1400)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.process(SelectStatement.java:1255)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.processResults(SelectStatement.java:299)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:276)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:224)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:67)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:238)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> com.datastax.bdp.cassandra.cql3.DseQueryHandler$StatementExecution.execute(DseQueryHandler.java:291)
>  ~[dse.jar:4.7.3]
>         at 
> com.datastax.bdp.cassandra.cql3.DseQueryHandler$Operation.executeWithTiming(DseQueryHandler.java:223)
>  ~[dse.jar:4.7.3]
>         at 
> com.datastax.bdp.cassandra.cql3.DseQueryHandler$Operation.executeWithAuditLogging(DseQueryHandler.java:259)
>  ~[dse.jar:4.7.3]
>         at 
> com.datastax.bdp.cassandra.cql3.DseQueryHandler.process(DseQueryHandler.java:94)
>  ~[dse.jar:4.7.3]
>         at 
> org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:122)
>  ~[cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:439)
>  [cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at 
> org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:335)
>  [cassandra-all-2.1.8.689.jar:2.1.8.689]
>         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:511) 
> [na:1.8.0_40]
>         at 
> org.apache.cassandra.concurrent.AbstractTracingAwareExecutorService$FutureTask.run(AbstractTracingAwareExecutorService.java:164)
>  [cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:105) 
> [cassandra-all-2.1.8.689.jar:2.1.8.689]
>         at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40]
> Here's the full reproduction:
> CREATE KEYSPACE TEST 
> WITH replication = {'class': 'SimpleStrategy', 'replication_factor':3} 
> AND durable_writes = true;
> USE test;
> CREATE TABLE test ( 
> useruid varchar, 
> direction varchar, 
> last_modified timestamp, 
> value varchar, 
> PRIMARY KEY ((useruid, direction), last_modified) 
> );
> //insert 4 entries in the table 
> INSERT INTO test (useruid,direction,last_modified,value) VALUES ('userid1', 
> 'out', '2013-05-13 15:18:51', 'a value1'); 
> INSERT INTO test (useruid,direction,last_modified,value) VALUES ('userid1', 
> 'out', '2013-05-13 15:12:51', 'a value2'); 
> INSERT INTO test (useruid,direction,last_modified,value) VALUES ('userid1', 
> 'none', '2013-05-13 15:20:51', 'a value3'); 
> INSERT INTO test (useruid,direction,last_modified,value) VALUES ('userid1', 
> 'in', '2013-05-13 15:34:51', 'a value4');
> First query to check the value in the table, and its results : 
> SELECT value, ttl(value), last_modified FROM test; 
> value | ttl(value) | last_modified
> ----------+------------+--------------------------
> a value4 | null | 2013-05-13 15:34:51+0000
> a value2 | null | 2013-05-13 15:12:51+0000
> a value1 | null | 2013-05-13 15:18:51+0000
> a value3 | null | 2013-05-13 15:20:51+0000
> (4 rows)
> Run this query using the IN clause and the ORDER BY clause, but it fails with 
> an error:
> SELECT value, ttl(value), last_modified FROM test where useruid='userid1' AND 
> direction IN ('out','in') ORDER BY last_modified; 
> InvalidRequest: code=2200 [Invalid query] message="Cannot page queries with 
> both ORDER BY and a IN restriction on the partition key; you must either 
> remove the ORDER BY or the IN and sort client side, or disable paging for 
> this query"
> If you run the same query without the ttl(value) in the SELECT part, it also 
> shows the same error:
>  
> SELECT value, last_modified FROM test where useruid='userid1' AND direction 
> IN ('out','in') ORDER BY last_modified; 
> InvalidRequest: code=2200 [Invalid query] message="Cannot page queries with 
> both ORDER BY and a IN restriction on the partition key; you must either 
> remove the ORDER BY or the IN and sort client side, or disable paging for 
> this query"
> This message suggests these JIRAs are the reason for this message:
> https://issues.apache.org/jira/browse/CASSANDRA-7853 select . . . in . . . 
> order by regression
> Resolution: Duplicate of CASSANDRA-7514
> Fix Version/s: None
> https://issues.apache.org/jira/browse/CASSANDRA-7514 Support paging in cqlsh
> Resolution: Fixed
> Fix Version/s: 2.1.1
> https://issues.apache.org/jira/browse/CASSANDRA-6722 cross-partition ordering 
> should have warning or be disallowed when paging
> Resolution: Fixed
> Fix Version/s: 2.0.6
> If I turn off paging:
> cqlsh:test> paging off;
> Disabled Query paging.
> Then re-run the query without the ttl(value) I see the results:
> cqlsh:test> SELECT value, last_modified FROM test where useruid='userid1' AND 
> direction IN ('out','in') ORDER BY last_modified;
> value | last_modified
> ----------+--------------------------
> a value2 | 2013-05-13 15:12:51+0000
> a value1 | 2013-05-13 15:18:51+0000
> a value4 | 2013-05-13 15:34:51+0000
> (3 rows)
> However, if you now re-run this query with the ttl(value) you get a 
> NullPointerException:
> cqlsh:test> SELECT value, ttl(value), last_modified FROM test where 
> useruid='userid1' AND direction IN ('out','in') ORDER BY last_modified; 
> ServerError: <ErrorMessage code=0000 [Server error] 
> message="java.lang.NullPointerException">



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to