You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Jonathan Ellis (JIRA)" <ji...@apache.org> on 2012/10/19 16:12:12 UTC

[jira] [Resolved] (CASSANDRA-4835) Appending/Prepending items to list using BATCH

     [ https://issues.apache.org/jira/browse/CASSANDRA-4835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jonathan Ellis resolved CASSANDRA-4835.
---------------------------------------

    Resolution: Not A Problem

You should think of multiple prepends in a batch as guaranteed to be prepended before any existing data, but not ordered among themselves.  Otherwise we could not parallelize within the batch.  (It's random chance that your appends appear to maintain batch order.)

If you want to retain order you should combine into one update: {{list = [3, 2, 1] + list}}, which will also be more performant.
                
> Appending/Prepending items to list using BATCH
> ----------------------------------------------
>
>                 Key: CASSANDRA-4835
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-4835
>             Project: Cassandra
>          Issue Type: Bug
>    Affects Versions: 1.2.0 beta 1
>            Reporter: Krzysztof Cieslinski
>            Priority: Minor
>
> As I know, there is no any guarantee that commands that are inside BATCH block will execute in same order, as they are stored in the BATCH block. But...
> I have made two tests:
> First appends some items to the empty list, and the second one, prepends items, also to the empty list. Both of them are using UPDATE commands stored in the BATCH block. 
> Results of those tests are as follow:
> First:
>       When appending new items to list, USING commands are executed in the same order as they are stored i BATCH.
> Second:
>       When prepending new items to list, USING commands are executed in random order.  
> So, in other words below code:
> {code:xml}
> BEGIN BATCH
>  UPDATE... list_name = list_name + [ '1' ]  
>  UPDATE... list_name = list_name + [ '2' ]
>  UPDATE... list_name = list_name + [ '3' ] 
> APPLY BATCH;{code}
>  always results in [ '1', '2', '3' ],
>  but this code:
> {code:xml}
> BEGIN BATCH
>  UPDATE... list_name = [ '1' ] + list_name   
>  UPDATE... list_name = [ '2' ] + list_name
>  UPDATE... list_name = [ '3' ] + list_name
> APPLY BATCH;{code}
> results in randomly ordered list, like [ '2', '1', '3' ]    (expected result is [ '3', '2', '1' ])
> So somehow, when appending items to list, commands from BATCH are executed in order as they are stored, but when prepending, the order is random.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira