cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/9] cassandra git commit: Follow up to avoid mutating row while read repair is happening
Date Tue, 25 Aug 2015 15:03:54 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 90a95582a -> f90a61191


Follow up to avoid mutating row while read repair is happening

Patch by tjake; reviewed by Stefania for CASSANDRA-9460


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

Branch: refs/heads/trunk
Commit: 147fe6d69d2efac8db47da9058e9a19f8ddc99fd
Parents: 978660d
Author: T Jake Luciani <jake@apache.org>
Authored: Mon Aug 24 15:49:18 2015 -0400
Committer: T Jake Luciani <jake@apache.org>
Committed: Tue Aug 25 09:19:52 2015 -0400

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/db/ReadCommand.java    |  4 ++--
 .../cassandra/db/SliceFromReadCommand.java      |  6 +++---
 .../cassandra/db/filter/SliceQueryFilter.java   | 20 ++++++++++++--------
 .../apache/cassandra/service/StorageProxy.java  |  4 ++--
 5 files changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/147fe6d6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d6a0af9..dcae493 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.9
+ * Avoid race condition during read repair (CASSANDRA-9460)
  * (cqlsh) default load-from-file encoding to utf-8 (CASSANDRA-9898)
  * Avoid returning Permission.NONE when failing to query users table (CASSANDRA-10168)
  * (cqlsh) Allow encoding to be set through command line (CASSANDRA-10004)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/147fe6d6/src/java/org/apache/cassandra/db/ReadCommand.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ReadCommand.java b/src/java/org/apache/cassandra/db/ReadCommand.java
index dedff6f..cd86336 100644
--- a/src/java/org/apache/cassandra/db/ReadCommand.java
+++ b/src/java/org/apache/cassandra/db/ReadCommand.java
@@ -118,9 +118,9 @@ public abstract class ReadCommand implements IReadCommand, Pageable
     }
 
     // maybeTrim removes columns from a response that is too long
-    public void maybeTrim(Row row)
+    public Row maybeTrim(Row row)
     {
-        // noop
+        return row;
     }
 
     public long getTimeout()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/147fe6d6/src/java/org/apache/cassandra/db/SliceFromReadCommand.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SliceFromReadCommand.java b/src/java/org/apache/cassandra/db/SliceFromReadCommand.java
index 6995193..461a3a1 100644
--- a/src/java/org/apache/cassandra/db/SliceFromReadCommand.java
+++ b/src/java/org/apache/cassandra/db/SliceFromReadCommand.java
@@ -113,12 +113,12 @@ public class SliceFromReadCommand extends ReadCommand
     }
 
     @Override
-    public void maybeTrim(Row row)
+    public Row maybeTrim(Row row)
     {
         if ((row == null) || (row.cf == null))
-            return;
+            return row;
 
-        filter.trim(row.cf, getOriginalRequestedCount(), timestamp);
+        return new Row(row.key, filter.trim(row.cf, getOriginalRequestedCount(), timestamp));
     }
 
     public IDiskAtomFilter filter()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/147fe6d6/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
index 65925b1..973477f 100644
--- a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
@@ -342,14 +342,17 @@ public class SliceQueryFilter implements IDiskAtomFilter
             return new ColumnCounter.GroupByPrefix(now, comparator, compositesToGroup);
     }
 
-    public void trim(ColumnFamily cf, int trimTo, long now)
+    public ColumnFamily trim(ColumnFamily cf, int trimTo, long now)
     {
         // each cell can increment the count by at most one, so if we have fewer cells than
trimTo, we can skip trimming
         if (cf.getColumnCount() < trimTo)
-            return;
+            return cf;
 
         ColumnCounter counter = columnCounter(cf.getComparator(), now);
 
+        ColumnFamily trimmedCf = cf.getFactory().create(cf.metadata(), reversed, trimTo);
+        trimmedCf.delete(cf);
+
         Collection<Cell> cells = reversed
                                    ? cf.getReverseSortedColumns()
                                    : cf.getSortedColumns();
@@ -363,14 +366,15 @@ public class SliceQueryFilter implements IDiskAtomFilter
 
             if (counter.live() > trimTo)
             {
-                iter.remove();
-                while (iter.hasNext())
-                {
-                    iter.next();
-                    iter.remove();
-                }
+                break;
+            }
+            else
+            {
+                trimmedCf.addColumn(cell);
             }
         }
+
+        return trimmedCf;
     }
 
     public Composite start()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/147fe6d6/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index 1536427..161bec8 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -1347,7 +1347,7 @@ public class StorageProxy implements StorageProxyMBean
                     Row row = exec.get();
                     if (row != null)
                     {
-                        exec.command.maybeTrim(row);
+                        row = exec.command.maybeTrim(row);
                         rows.add(row);
                     }
 
@@ -1466,7 +1466,7 @@ public class StorageProxy implements StorageProxyMBean
 
                     if (row != null)
                     {
-                        command.maybeTrim(row);
+                        row = command.maybeTrim(row);
                         rows.add(row);
                     }
                 }


Mime
View raw message