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

Unable to prepare statement with batch and delete from collection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 1.2.14
    • None
    • None
    • Low

    Description

      It is not possible to prepare statement with batch containing delete operation on one item of collection, e.g.:

      BEGIN BATCH
      DELETE colection[?] FROM table WHERE key = ?;
      APPLY BATCH
      

      Result of preparing such statement is:

      java.lang.ArrayStoreException: org.apache.cassandra.cql3.ColumnSpecification
      

      With stacktrace:

      ERROR 16:26:36,816 Unexpected exception during request
      java.lang.ArrayStoreException: org.apache.cassandra.cql3.ColumnSpecification
      	at org.apache.cassandra.cql3.AbstractMarker.collectMarkerSpecification(AbstractMarker.java:40)
      	at org.apache.cassandra.cql3.Operation.collectMarkerSpecification(Operation.java:75)
      	at org.apache.cassandra.cql3.statements.DeleteStatement.prepare(DeleteStatement.java:160)
      	at org.apache.cassandra.cql3.statements.BatchStatement.prepare(BatchStatement.java:125)
      	at org.apache.cassandra.cql3.statements.BatchStatement.prepare(BatchStatement.java:133)
      	at org.apache.cassandra.cql3.QueryProcessor.getStatement(QueryProcessor.java:273)
      	at org.apache.cassandra.cql3.QueryProcessor.prepare(QueryProcessor.java:201)
      	at org.apache.cassandra.transport.messages.PrepareMessage.execute(PrepareMessage.java:77)
      	at org.apache.cassandra.transport.Message$Dispatcher.messageReceived(Message.java:287)
      	at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
      	at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
      	at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
      	at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:43)
      	at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:67)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:724)
      

      This fix seems to help:

      diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
      index f93eb63..74c0a45 100644
      --- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
      +++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
      @@ -129,7 +129,7 @@ public class BatchStatement extends ModificationStatement
       
           public ParsedStatement.Prepared prepare() throws InvalidRequestException
           {
      -        CFDefinition.Name[] boundNames = new CFDefinition.Name[getBoundsTerms()];
      +        ColumnSpecification[] boundNames = new ColumnSpecification[getBoundsTerms()];
               return prepare(boundNames);
           }
      

      It is probably corrected in Cassandra 2.0 by commit e431fb722f80d8957a0a7fd2ecf80333e9275c53 (CASSANDRA-5443).
      We are facing this issue with Cassandra version 1.2.11.
      Would it be possible to fix this issue in branch 1.2?

      Attachments

        Activity

          People

            slebresne Sylvain Lebresne
            jan.chochol Jan Chochol
            Sylvain Lebresne
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: