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

maxwellguo edited comment on CASSANDRA-15343 at 10/8/19 7:57 AM:
-----------------------------------------------------------------

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

{
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

{
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. 
 





was (Author: maxwellguo):
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
{
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

{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-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to