improve CL logging

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

Branch: refs/heads/trunk
Commit: 374524b5b3932e73cd78054d9c57ad9f6828ffe3
Parents: 5262098
Author: Jonathan Ellis <jbel...@apache.org>
Authored: Fri Jan 11 17:45:01 2013 -0600
Committer: Jonathan Ellis <jbel...@apache.org>
Committed: Fri Jan 11 17:45:01 2013 -0600

----------------------------------------------------------------------
 .../apache/cassandra/db/commitlog/CommitLog.java   |   18 ++++++++++-----
 .../cassandra/db/commitlog/CommitLogReplayer.java  |   15 +++++------
 2 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/374524b5/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLog.java 
b/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
index e806d08..e4e9881 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
@@ -225,16 +225,22 @@ public class CommitLog implements CommitLogMBean
                     // If the segment is no longer needed, and we have another 
spare segment in the hopper
                     // (to keep the last segment from getting discarded), 
pursue either recycling or deleting
                     // this segment file.
-                    if (segment.isUnused() && iter.hasNext())
+                    if (iter.hasNext())
                     {
-                        logger.debug("Commit log segment {} is unused", 
segment);
-                        allocator.recycleSegment(segment);
+                        if (segment.isUnused())
+                        {
+                            logger.debug("Commit log segment {} is unused", 
segment);
+                            allocator.recycleSegment(segment);
+                        }
+                        else
+                        {
+                            logger.debug("Not safe to delete commit log 
segment {}; dirty is {}",
+                                         segment, segment.dirtyString());
+                        }
                     }
                     else
                     {
-                        if (logger.isDebugEnabled())
-                            logger.debug(String.format("Not safe to delete 
commit log %s; dirty is %s; hasNext: %s",
-                                                       segment, 
segment.dirtyString(), iter.hasNext()));
+                        logger.debug("Not deleting active commitlog segment 
{}", segment);
                     }
 
                     // Don't mark or try to delete any newer segments once 
we've reached the one containing the

http://git-wip-us.apache.org/repos/asf/cassandra/blob/374524b5/src/java/org/apache/cassandra/db/commitlog/CommitLogReplayer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLogReplayer.java 
b/src/java/org/apache/cassandra/db/commitlog/CommitLogReplayer.java
index 9f949d0..2728970 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLogReplayer.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogReplayer.java
@@ -89,6 +89,7 @@ public class CommitLogReplayer
             cfPositions.put(cfs.metadata.cfId, rp);
         }
         globalPosition = replayPositionOrdering.min(cfPositions.values());
+        logger.debug("Global replay position is {} from columnfamilies {}", 
globalPosition, FBUtilities.toString(cfPositions));
     }
 
     public void recover(File[] clogs) throws IOException
@@ -126,24 +127,22 @@ public class CommitLogReplayer
             assert reader.length() <= Integer.MAX_VALUE;
             int replayPosition;
             if (globalPosition.segment < segment)
+            {
                 replayPosition = 0;
+            }
             else if (globalPosition.segment == segment)
+            {
                 replayPosition = globalPosition.position;
+            }
             else
-                replayPosition = (int) reader.length();
-
-            if (replayPosition < 0 || replayPosition >= reader.length())
             {
-                // replayPosition > reader.length() can happen if some data 
gets flushed before it is written to the commitlog
-                // (see https://issues.apache.org/jira/browse/CASSANDRA-2285)
                 logger.debug("skipping replay of fully-flushed {}", file);
                 return;
             }
 
-            reader.seek(replayPosition);
-
             if (logger.isDebugEnabled())
-                logger.debug("Replaying " + file + " starting at " + 
reader.getFilePointer());
+                logger.debug("Replaying " + file + " starting at " + 
replayPosition);
+            reader.seek(replayPosition);
 
             /* read the logs populate RowMutation and apply */
             while (!reader.isEOF())

Reply via email to