You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "maxwellguo (Jira)" <ji...@apache.org> on 2019/10/08 07:57:00 UTC

[jira] [Commented] (CASSANDRA-15343) Java internal exception on empty partition key range and conditions

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

maxwellguo commented on CASSANDRA-15343:
----------------------------------------

I got to know that this is because token condication "token(a) > 0 and token(a)< 0" and restrictions condication "a=1" just merge and result a in to an empty arraylist . see code
{code:java}
 private List<ByteBuffer> filter(List<ByteBuffer> values, QueryOptions options) throws InvalidRequestException
    {
        RangeSet<Token> rangeSet = tokenRestriction.hasSlice() ? toRangeSet(tokenRestriction, options)
                                                               : toRangeSet(tokenRestriction.values(options));

        return filterWithRangeSet(rangeSet, values);
    }
{version : cassandra-3.11.4->TokenFilter.java -> line : 150 }
Then  the exception occurs at class : ModificationStatement
{ModificationStatement.java }
List<ByteBuffer> keys = buildPartitionKeyNames(options);
        // We don't support IN for CAS operation so far
        checkFalse(restrictions.keyIsInRelation(),
                   "IN on the partition key is not supported with conditional %s",
                   type.isUpdate()? "updates" : "deletions");

        DecoratedKey key = cfm.decorateKey(keys.get(0));
        long now = options.getTimestamp(queryState);
{cassandra-3.11.4 -> ModificationStatement.java -> code line :470  }

the keys got an empty list ,so, method get(0) got an exception . 

so I think we should test the bondary , and output exception message to tell user to use right. 
 




> Java internal exception on empty partition key range and conditions
> -------------------------------------------------------------------
>
>                 Key: CASSANDRA-15343
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15343
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL/Semantics
>            Reporter: Konstantin
>            Priority: Normal
>
> {code}
> sandra@cqlsh> create keyspace test with replication = \{ 'class': 'SimpleStrategy', 'replication_factor': 1} and DURABLE_WRITES=true ;
> cassandra@cqlsh> use test;
> cassandra@cqlsh:test> create table lwt (a int primary key, b int);
> cassandra@cqlsh:test> update lwt set b = 1 where a = 1 and token(a) > 0 and token(a)< 0;
> cassandra@cqlsh:test> update lwt set b = 1 where a = 1 and token(a) > 0 and token(a)< 0 if b = 1;
> ServerError: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
> {code}
> {code}
> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
>         at java.util.ArrayList.rangeCheck(ArrayList.java:657)
>         at java.util.ArrayList.get(ArrayList.java:433)
>         at org.apache.cassandra.cql3.statements.ModificationStatement.makeCasRequest(ModificationStatement.java:506)
>         at org.apache.cassandra.cql3.statements.ModificationStatement.executeWithCondition(ModificationStatement.java:482)
>         at org.apache.cassandra.cql3.statements.ModificationStatement.execute(ModificationStatement.java:452)
>         at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:216)
>         at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:247)
>         at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:233)
>         at org.apache.cassandra.transport.messages.QueryMessage.execute(QueryMessage.java:108)
>         at org.apache.cassandra.transport.Message$Request.execute(Message.java:246)
>         at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:612)
>         at org.apache.cassandra.transport.Message$Dispatcher.channelRead0(Message.java:455)
>         at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
>         at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
>         at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:38)
>         at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:353)
>         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>         at org.apache.cassandra.concurrent.AbstractLocalAwareExecutorService$FutureTask.run(AbstractLocalAwareExecutorService.java:162)
>         at org.apache.cassandra.concurrent.SEPWorker.run(SEPWorker.java:115)
>         at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
>         at java.lang.Thread.run(Thread.java:748)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org