Merge branch 'cassandra-3.0' into cassandra-3.9

* cassandra-3.0:
  Lost counter writes in compact table and static columns


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f0fd9ad6
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f0fd9ad6
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f0fd9ad6

Branch: refs/heads/trunk
Commit: f0fd9ad6c57fa21b145896c32c53540406e40a7d
Parents: d22e390 a11f210
Author: Sylvain Lebresne <sylv...@datastax.com>
Authored: Thu Jul 28 10:21:58 2016 +0200
Committer: Sylvain Lebresne <sylv...@datastax.com>
Committed: Thu Jul 28 10:21:58 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/cql3/UpdateParameters.java | 17 +++++++++--------
 .../apache/cassandra/db/CounterMutation.java    |  3 ++-
 .../db/partitions/PartitionUpdate.java          | 20 ++++++++++++--------
 4 files changed, 24 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0fd9ad6/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 6ef9655,b966078..5740ca7
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,7 -1,5 +1,8 @@@
 -3.0.9
 +3.9
 + * cqlsh: Fix handling of $$-escaped strings (CASSANDRA-12189)
 + * Fix SSL JMX requiring truststore containing server cert (CASSANDRA-12109)
 +Merged from 3.0:
+  * Lost counter writes in compact table and static columns (CASSANDRA-12219)
   * AssertionError with MVs on updating a row that isn't indexed due to a null 
value (CASSANDRA-12247)
   * Disable RR and speculative retry with EACH_QUORUM reads (CASSANDRA-11980)
   * Add option to override compaction space check (CASSANDRA-12180)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0fd9ad6/src/java/org/apache/cassandra/cql3/UpdateParameters.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/UpdateParameters.java
index 6b0ed59,0c58097..d2c01c8
--- a/src/java/org/apache/cassandra/cql3/UpdateParameters.java
+++ b/src/java/org/apache/cassandra/cql3/UpdateParameters.java
@@@ -158,15 -158,16 +158,16 @@@ public class UpdateParameter
      {
          assert ttl == LivenessInfo.NO_TTL;
  
-         // In practice, the actual CounterId (and clock really) that we use 
doesn't matter, because we will
-         // ignore it in CounterMutation when we do the read-before-write to 
create the actual value that is
-         // applied. In other words, this is not the actual value that will be 
written to the memtable
-         // because this will be replaced in 
CounterMutation.updateWithCurrentValue().
-         // As an aside, since we don't care about the CounterId/clock, we 
used to only send the incremement,
-         // but that makes things a bit more complex as this means we need to 
be able to distinguish inside
-         // PartitionUpdate between counter updates that has been processed by 
CounterMutation and those that
-         // haven't.
+         // Because column is a counter, we need the value to be a 
CounterContext. However, we're only creating a
+         // "counter update", which is a temporary state until we run into 
'CounterMutation.updateWithCurrentValue()'
+         // which does the read-before-write and sets the proper CounterId, 
clock and updated value.
+         //
+         // We thus create a "fake" local shard here. The CounterId/clock used 
don't matter as this is just a temporary
+         // state that will be replaced when processing the mutation in 
CounterMutation, but the reason we use a 'local'
+         // shard is due to the merging rules: if a user includes multiple 
updates to the same counter in a batch, those
+         // multiple updates will be merged in the PartitionUpdate *before* 
they even reach CounterMutation. So we need
+         // such update to be added together, and that's what a local shard 
gives us.
 -        builder.addCell(BufferCell.live(metadata, column, timestamp, 
CounterContext.instance().createLocal(increment)));
 +        builder.addCell(BufferCell.live(column, timestamp, 
CounterContext.instance().createLocal(increment)));
      }
  
      public void setComplexDeletionTime(ColumnDefinition column)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0fd9ad6/src/java/org/apache/cassandra/db/CounterMutation.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0fd9ad6/src/java/org/apache/cassandra/db/partitions/PartitionUpdate.java
----------------------------------------------------------------------

Reply via email to