cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r999142 - in /cassandra/trunk: ./ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/commitlog/ test/unit/org/apache/cassandra/db/
Date Mon, 20 Sep 2010 22:15:35 GMT
Author: jbellis
Date: Mon Sep 20 22:15:34 2010
New Revision: 999142

URL: http://svn.apache.org/viewvc?rev=999142&view=rev
Log:
fix replaying the last mutation in a commitlog unnecessarily.  patch by jbellis; reviewed
by gdusbabek for CASSANDRA-1512

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/CommitLogTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=999142&r1=999141&r2=999142&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Mon Sep 20 22:15:34 2010
@@ -79,6 +79,7 @@
  * make contrib CassandraServiceDataCleaner recursive (CASSANDRA-1509)
  * min, max compaction threshold are configurable and persistent 
    per-ColumnFamily (CASSANDRA-1468)
+ * fix replaying the last mutation in a commitlog unnecessarily (CASSANDRA-1512)
 
 
 0.7-beta1

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=999142&r1=999141&r2=999142&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Mon Sep 20 22:15:34
2010
@@ -450,7 +450,6 @@ public class ColumnFamilyStore implement
                     {
                         // if we're not writing to the commit log, we are replaying the log,
so marking
                         // the log header with "you can discard anything written before the
context" is not valid
-                        logger.debug("Discarding {}", metadata.cfId);
                         CommitLog.instance().discardCompletedSegments(metadata.cfId, ctx);
                     }
                 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java?rev=999142&r1=999141&r2=999142&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java Mon Sep 20 22:15:34
2010
@@ -302,7 +302,7 @@ public class CommitLog
                                     // null means the cf has been dropped
                                     continue;
 
-                                if (finalHeader == null || (finalHeader.isDirty(columnFamily.id())
&& entryLocation >= finalHeader.getPosition(columnFamily.id())))
+                                if (finalHeader == null || (finalHeader.isDirty(columnFamily.id())
&& entryLocation > finalHeader.getPosition(columnFamily.id())))
                                     newRm.add(columnFamily);
                             }
                             if (!newRm.isEmpty())
@@ -338,7 +338,6 @@ public class CommitLog
         for (Table table : tablesRecovered)
             futures.addAll(table.flush());
         FBUtilities.waitOnFutures(futures);
-        logger.info("Recovery complete");
     }
 
     private CommitLogSegment currentSegment()

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/CommitLogTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/CommitLogTest.java?rev=999142&r1=999141&r2=999142&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/CommitLogTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/CommitLogTest.java Mon Sep 20 22:15:34
2010
@@ -34,42 +34,6 @@ import org.apache.cassandra.utils.Pair;
 public class CommitLogTest extends CleanupHelper
 {
     @Test
-    public void testCleanup() throws Exception
-    {
-        int segmentCount = CommitLog.instance().getSegmentCount();
-        assert segmentCount == 1 : segmentCount + " != 1";
-
-        //must me large enough to hold persistent_stats
-        CommitLog.setSegmentSize(10000);
-
-        Table table = Table.open("Keyspace1");
-        ColumnFamilyStore store1 = table.getColumnFamilyStore("Standard1");
-        ColumnFamilyStore store2 = table.getColumnFamilyStore("Standard2");
-        RowMutation rm;
-        byte[] value = new byte[5001];
-
-        // add data, one each of Standard1/Standard2 per segment
-        for (int i = 0; i < 10; i++)
-        {
-            rm = new RowMutation("Keyspace1", "key1".getBytes());
-            rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), value, new TimestampClock(0));
-            rm.add(new QueryPath("Standard2", null, "Column1".getBytes()), value, new TimestampClock(0));
-            rm.apply();
-        }
-        assert CommitLog.instance().getSegmentCount() > 1;
-
-        // nothing should get removed after flushing just Standard1
-        store1.forceBlockingFlush();
-        segmentCount = CommitLog.instance().getSegmentCount();
-        assert segmentCount > 1 : segmentCount + " !> 1";
-
-        // after flushing Standard2 we should be able to clean out all segments
-        store2.forceBlockingFlush();
-        segmentCount = CommitLog.instance().getSegmentCount();
-        assert segmentCount == 1 : segmentCount + " != 1";
-    }
-
-    @Test
     public void testRecoveryWithEmptyHeader() throws Exception
     {
         testRecovery(new byte[0], new byte[10]);

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java?rev=999142&r1=999141&r2=999142&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java Mon Sep 20
22:15:34 2010
@@ -25,6 +25,9 @@ import java.io.IOException;
 
 import org.junit.Test;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import static org.apache.cassandra.Util.column;
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.Util;
@@ -32,25 +35,32 @@ import org.apache.cassandra.db.commitlog
 
 public class RecoveryManager2Test extends CleanupHelper
 {
+    private static Logger logger = LoggerFactory.getLogger(RecoveryManager2Test.class);
+
     @Test
     /* test that commit logs do not replay flushed data */
     public void testWithFlush() throws Exception
     {
         CompactionManager.instance.disableAutoCompaction();
 
+        // add a row to another CF so we test skipping mutations within a not-entirely-flushed
CF
+        insertRow("Standard2", "key");
+
         for (int i = 0; i < 100; i++)
         {
             String key = "key" + i;
-            insertRow(key);
+            insertRow("Standard1", key);
         }
 
         Table table1 = Table.open("Keyspace1");
         ColumnFamilyStore cfs = table1.getColumnFamilyStore("Standard1");
+        logger.debug("forcing flush");
         cfs.forceBlockingFlush();
 
-        // remove all SSTable/MemTables
+        // remove Standard1 SSTable/MemTables
         cfs.clearUnsafe();
 
+        logger.debug("begin manual replay");
         // replay the commit log (nothing should be replayed since everything was flushed)
         CommitLog.recover();
 
@@ -59,10 +69,10 @@ public class RecoveryManager2Test extend
         assert Util.getRangeSlice(cfs).isEmpty();
     }
 
-    private void insertRow(String key) throws IOException
+    private void insertRow(String cfname, String key) throws IOException
     {
         RowMutation rm = new RowMutation("Keyspace1", key.getBytes());
-        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
+        ColumnFamily cf = ColumnFamily.create("Keyspace1", cfname);
         cf.addColumn(column("col1", "val1", new TimestampClock(1L)));
         rm.add(cf);
         rm.apply();



Mime
View raw message