diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLogAllocator.java b/src/java/org/apache/cassandra/db/commitlog/CommitLogAllocator.java index 963e41e83c..0359c5817a 100644 --- a/src/java/org/apache/cassandra/db/commitlog/CommitLogAllocator.java +++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogAllocator.java @@ -101,6 +101,7 @@ public class CommitLogAllocator // almost always a segment available when it's needed. if (availableSegments.isEmpty() && (activeSegments.isEmpty() || createReserveSegments)) { + logger.debug("No segments in reserve; creating a fresh one"); createFreshSegment(); } } @@ -156,6 +157,8 @@ public class CommitLogAllocator discardSegment(segment, true); return; } + + logger.debug("Recycling {}", segment); queue.add(new Runnable() { public void run() @@ -205,6 +208,7 @@ public class CommitLogAllocator */ private void discardSegment(final CommitLogSegment segment, final boolean deleteFile) { + logger.debug("Segment {} is no longer active and will be deleted {}", segment, deleteFile ? "now" : "by the archive script"); size.addAndGet(-DatabaseDescriptor.getCommitLogSegmentSize()); queue.add(new Runnable() diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java index 2ee90adf86..0449c47941 100644 --- a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java +++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java @@ -100,8 +100,9 @@ public class CommitLogSegment if (oldFile.exists()) { - logger.debug("Re-using discarded CommitLog segment for " + id + " from " + filePath); - oldFile.renameTo(logFile); + logger.debug("Re-using discarded CommitLog segment for {} from {}", id, filePath); + if (!oldFile.renameTo(logFile)) + throw new IOException("Rename from " + filePath + " to " + id + " failed"); isCreating = false; } } @@ -110,9 +111,7 @@ public class CommitLogSegment logFileAccessor = new RandomAccessFile(logFile, "rw"); if (isCreating) - { - logger.debug("Creating new commit log segment " + logFile.getPath()); - } + logger.debug("Creating new commit log segment {}", logFile.getPath()); // Map the segment, extending or truncating it to the standard segment size logFileAccessor.setLength(DatabaseDescriptor.getCommitLogSegmentSize());