cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject git commit: Scrub should not always clear out repaired status.
Date Mon, 24 Feb 2014 09:22:40 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 e30f11143 -> f0c9bd1c9


Scrub should not always clear out repaired status.

Patch by marcuse, reviewed by jbellis for CASSANDRA-5351


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

Branch: refs/heads/cassandra-2.1
Commit: f0c9bd1c9da8dcacf2e9268bb1855b92f5e05e61
Parents: e30f111
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Mon Feb 24 10:16:25 2014 +0100
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Mon Feb 24 10:21:33 2014 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +-
 .../cassandra/db/compaction/Scrubber.java       | 11 +++--
 .../cassandra/io/sstable/SSTableWriter.java     | 14 +++++-
 tools/bin/sstablerepairedset                    | 46 ++++++++++++++++++++
 4 files changed, 68 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0c9bd1c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index be2925a..cd58a74 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,7 +4,7 @@
  * Allow nodetool to use a file or prompt for password (CASSANDRA-6660)
  * Fix AIOOBE when concurrently accessing ABSC (CASSANDRA-6742)
  * Fix assertion error in ALTER TYPE RENAME (CASSANDRA-6705)
-
+ * Scrub should not always clear out repaired status (CASSANDRA-5351)
 
 2.1.0-beta1
  * Add flush directory distinct from compaction directories (CASSANDRA-6357)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0c9bd1c/src/java/org/apache/cassandra/db/compaction/Scrubber.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/Scrubber.java b/src/java/org/apache/cassandra/db/compaction/Scrubber.java
index 3a71136..0a1e8c4 100644
--- a/src/java/org/apache/cassandra/db/compaction/Scrubber.java
+++ b/src/java/org/apache/cassandra/db/compaction/Scrubber.java
@@ -114,7 +114,7 @@ public class Scrubber implements Closeable
             }
 
             // TODO errors when creating the writer may leave empty temp files.
-            writer = CompactionManager.createWriter(cfs, destination, expectedBloomFilterSize,
ActiveRepairService.UNREPAIRED_SSTABLE, sstable);
+            writer = CompactionManager.createWriter(cfs, destination, expectedBloomFilterSize,
sstable.getSSTableMetadata().repairedAt, sstable);
 
             DecoratedKey prevKey = null;
 
@@ -257,7 +257,10 @@ public class Scrubber implements Closeable
             }
 
             if (writer.getFilePointer() > 0)
-                newSstable = writer.closeAndOpenReader(sstable.maxDataAge);
+            {
+                long repairedAt = badRows > 0 ? ActiveRepairService.UNREPAIRED_SSTABLE
: sstable.getSSTableMetadata().repairedAt;
+                newSstable = writer.closeAndOpenReader(sstable.maxDataAge, repairedAt);
+            }
         }
         catch (Throwable t)
         {
@@ -272,7 +275,9 @@ public class Scrubber implements Closeable
 
         if (!outOfOrderRows.isEmpty())
         {
-            SSTableWriter inOrderWriter = CompactionManager.createWriter(cfs, destination,
expectedBloomFilterSize, ActiveRepairService.UNREPAIRED_SSTABLE, sstable);
+            // out of order rows, but no bad rows found - we can keep our repairedAt time
+            long repairedAt = badRows > 0 ? ActiveRepairService.UNREPAIRED_SSTABLE : sstable.getSSTableMetadata().repairedAt;
+            SSTableWriter inOrderWriter = CompactionManager.createWriter(cfs, destination,
expectedBloomFilterSize, repairedAt, sstable);
             for (Row row : outOfOrderRows)
                 inOrderWriter.append(row.key, row.cf);
             newInOrderSstable = inOrderWriter.closeAndOpenReader(sstable.maxDataAge);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0c9bd1c/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
index ab1fe49..2d1858f 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
@@ -330,7 +330,12 @@ public class SSTableWriter extends SSTable
 
     public SSTableReader closeAndOpenReader(long maxDataAge)
     {
-        Pair<Descriptor, StatsMetadata> p = close();
+        return closeAndOpenReader(maxDataAge, this.repairedAt);
+    }
+
+    public SSTableReader closeAndOpenReader(long maxDataAge, long repairedAt)
+    {
+        Pair<Descriptor, StatsMetadata> p = close(repairedAt);
         Descriptor newdesc = p.left;
         StatsMetadata sstableMetadata = p.right;
 
@@ -359,6 +364,11 @@ public class SSTableWriter extends SSTable
     // Close the writer and return the descriptor to the new sstable and it's metadata
     public Pair<Descriptor, StatsMetadata> close()
     {
+        return close(this.repairedAt);
+    }
+
+    private Pair<Descriptor, StatsMetadata> close(long repairedAt)
+    {
         // index and filter
         iwriter.close();
         // main data, close will truncate if necessary
@@ -375,8 +385,10 @@ public class SSTableWriter extends SSTable
 
         // remove the 'tmp' marker from all components
         return Pair.create(rename(descriptor, components), (StatsMetadata) metadataComponents.get(MetadataType.STATS));
+
     }
 
+
     private static void writeMetadata(Descriptor desc, Map<MetadataType, MetadataComponent>
components)
     {
         SequentialWriter out = SequentialWriter.open(new File(desc.filenameFor(Component.STATS)),
true);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f0c9bd1c/tools/bin/sstablerepairedset
----------------------------------------------------------------------
diff --git a/tools/bin/sstablerepairedset b/tools/bin/sstablerepairedset
new file mode 100755
index 0000000..73201ad
--- /dev/null
+++ b/tools/bin/sstablerepairedset
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if [ "x$CLASSPATH" = "x" ]; then
+    
+    # execute from the build dir.
+    if [ -d `dirname $0`/../../build/classes ]; then
+        for directory in `dirname $0`/../../build/classes/*; do
+            CLASSPATH=$CLASSPATH:$directory
+        done
+    else
+        if [ -f `dirname $0`/../lib/stress.jar ]; then
+            CLASSPATH=`dirname $0`/../lib/stress.jar
+        fi
+    fi
+
+    for jar in `dirname $0`/../../lib/*.jar; do
+        CLASSPATH=$CLASSPATH:$jar
+    done
+fi
+
+# Use JAVA_HOME if set, otherwise look for java in PATH
+if [ -x $JAVA_HOME/bin/java ]; then
+    JAVA=$JAVA_HOME/bin/java
+else
+    JAVA=`which java`
+fi
+
+$JAVA -cp $CLASSPATH \
+        -Dlogback.configurationFile=logback-tools.xml \
+        org.apache.cassandra.tools.SSTableRepairedAtSetter "$@"


Mime
View raw message