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

Appending/Prepending items to list using BATCH

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 1.2.0 beta 2
    • None
    • None
    • Low

    Description

      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:

      BEGIN BATCH
       UPDATE... list_name = list_name + [ '1' ]  
       UPDATE... list_name = list_name + [ '2' ]
       UPDATE... list_name = list_name + [ '3' ] 
      APPLY BATCH;

      always results in [ '1', '2', '3' ],
      but this code:

      BEGIN BATCH
       UPDATE... list_name = [ '1' ] + list_name   
       UPDATE... list_name = [ '2' ] + list_name
       UPDATE... list_name = [ '3' ] + list_name
      APPLY BATCH;

      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.

      Attachments

        1. 0001-Fix-prepends-within-same-millis.txt
          3 kB
          Sylvain Lebresne
        2. 0002-Ensure-same-timestamp-in-batches.txt
          8 kB
          Sylvain Lebresne

        Activity

          People

            slebresne Sylvain Lebresne
            krzysztof cieslinski Krzysztof Cieslinski Cognitum
            Sylvain Lebresne
            Jonathan Ellis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: