Author: jbellis
Date: Fri Dec  2 22:09:54 2011
New Revision: 1209724

URL: http://svn.apache.org/viewvc?rev=1209724&view=rev
Log:
enableReserveSegmentCreation even when there is nothing to replay
patch by Rick Branson; reviewed by jbellis for CASSANDRA-3543

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java

Modified: cassandra/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1209724&r1=1209723&r2=1209724&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Fri Dec  2 22:09:54 2011
@@ -1,6 +1,6 @@
 1.1-dev
  * "defragment" rows for name-based queries under STCS, again (CASSANDRA-2503)
- * Recycle commitlog segments for improved performance (CASSANDRA-3411)
+ * Recycle commitlog segments for improved performance (CASSANDRA-3411, 3543)
  * update size-tiered compaction to prioritize small tiers (CASSANDRA-2407)
  * add message expiration logic to OutboundTcpConnection (CASSANDRA-3005)
  * off-heap cache to use sun.misc.Unsafe instead of JNA (CASSANDRA-3271)

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=1209724&r1=1209723&r2=1209724&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 
Fri Dec  2 22:09:54 2011
@@ -130,19 +130,23 @@ public class CommitLog implements Commit
             }
         });
 
+        int replayed = 0;
         if (files.length == 0)
         {
             logger.info("No commitlog files found; skipping replay");
-            return 0;
         }
-        
-        Arrays.sort(files, new FileUtils.FileComparator());
-        logger.info("Replaying " + StringUtils.join(files, ", "));
-        int replayed = recover(files);
-        logger.info("Log replay complete, " + replayed + " replayed 
mutations");
+        else
+        {
+            Arrays.sort(files, new FileUtils.FileComparator());
+            logger.info("Replaying " + StringUtils.join(files, ", "));
+            replayed = recover(files);
+            logger.info("Log replay complete, " + replayed + " replayed 
mutations");
+
+            for (File f : files)
+                CommitLog.instance.allocator.recycleSegment(f);
+        }
 
-        for (File f : files)
-            CommitLog.instance.allocator.recycleSegment(f);
+        allocator.enableReserveSegmentCreation();
         return replayed;
     }
 
@@ -348,8 +352,6 @@ public class CommitLog implements Commit
             futures.addAll(table.flush());
         FBUtilities.waitOnFutures(futures);
 
-        allocator.enableReserveSegmentCreation();
-
         return replayedCount.get();
     }
 


Reply via email to