Skip to content

Commit 6841f29

Browse files
inespotines potier
and
ines potier
committed
More commit log logs (#664)
Co-authored-by: ines potier <[email protected]>
1 parent facaac7 commit 6841f29

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

src/java/org/apache/cassandra/db/commitlog/CommitLog.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
import java.nio.ByteBuffer;
2222
import java.nio.file.Paths;
2323
import java.util.*;
24+
import java.util.stream.Collectors;
2425

2526
import javax.annotation.Nullable;
2627

2728
import com.google.common.annotations.VisibleForTesting;
2829
import com.google.common.collect.ImmutableMap;
2930

31+
import com.palantir.logsafe.SafeArg;
3032
import org.slf4j.Logger;
3133
import org.slf4j.LoggerFactory;
3234

@@ -163,7 +165,8 @@ public boolean accept(File dir, String name)
163165
else
164166
{
165167
Arrays.sort(files, new CommitLogSegmentFileComparator());
166-
logger.info("Replaying {}", StringUtils.join(files, ", "));
168+
logger.info("Replaying {}",
169+
SafeArg.of("commitLogFiles", Arrays.stream(files).map(File::getName).collect(Collectors.toSet())));
167170
replayed = recover(files);
168171
logger.info("Log replay complete, {} replayed mutations", replayed);
169172

src/java/org/apache/cassandra/db/commitlog/CommitLogReplayer.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.concurrent.atomic.AtomicInteger;
3232

3333
import com.palantir.logsafe.SafeArg;
34+
import com.palantir.logsafe.UnsafeArg;
3435
import com.google.common.base.Predicate;
3536
import com.google.common.collect.HashMultimap;
3637
import com.google.common.collect.Iterables;
@@ -103,6 +104,7 @@ public static CommitLogReplayer construct(CommitLog commitLog)
103104
{
104105
// compute per-CF and global replay positions
105106
Map<UUID, ReplayPosition.ReplayFilter> cfPersisted = new HashMap<>();
107+
Set<UUID> cfWithoutFilter = new HashSet<>();
106108
ReplayFilter replayFilter = ReplayFilter.create();
107109
ReplayPosition globalPosition = null;
108110
for (ColumnFamilyStore cfs : ColumnFamilyStore.all())
@@ -133,13 +135,18 @@ public static CommitLogReplayer construct(CommitLog commitLog)
133135
if (!filter.isEmpty())
134136
cfPersisted.put(cfs.metadata.cfId, filter);
135137
else
138+
{
136139
globalPosition = ReplayPosition.NONE; // if we have no ranges for this CF, we must replay everything and filter
140+
cfWithoutFilter.add(cfs.metadata.cfId);
141+
}
137142
}
138143
if (globalPosition == null)
139144
globalPosition = ReplayPosition.firstNotCovered(cfPersisted.values());
145+
140146
logger.debug("Global replay position {} is from columnfamilies {}",
141147
SafeArg.of("globalPosition", globalPosition),
142-
SafeArg.of("columnFamilies", FBUtilities.toString(cfPersisted)));
148+
SafeArg.of("columnFamiliesWithReplayFilters", cfPersisted.keySet()),
149+
SafeArg.of("columnFamiliesWithoutReplayFilters", cfWithoutFilter));
143150
return new CommitLogReplayer(commitLog, globalPosition, cfPersisted, replayFilter);
144151
}
145152

@@ -464,17 +471,18 @@ public void recover(File file, boolean tolerateTruncation) throws IOException
464471
finally
465472
{
466473
FileUtils.closeQuietly(reader);
467-
logger.debug("Finished reading {}", file);
474+
logger.debug("Finished reading {}",
475+
SafeArg.of("file", file.getName()));
468476
}
469477
}
470478

471479
public boolean logAndCheckIfShouldSkip(File file, CommitLogDescriptor desc)
472480
{
473481
logger.debug("Replaying {} (CL version {}, messaging version {}, compression {})",
474-
file.getPath(),
475-
desc.version,
476-
desc.getMessagingVersion(),
477-
desc.compression);
482+
SafeArg.of("file", file.getName()),
483+
SafeArg.of("version", desc.version),
484+
SafeArg.of("messagingVersion", desc.getMessagingVersion()),
485+
UnsafeArg.of("compression", desc.compression));
478486

479487
if (globalPosition.segment > desc.id)
480488
{

src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void runMayThrow() throws Exception
122122
// TODO : some error handling in case we fail to create a new segment
123123
CommitLogSegment newSegment = CommitLogSegment.createSegment(commitLog);
124124
availableSegments.add(newSegment);
125-
logger.info("No segments in reserve; created a fresh one",
125+
logger.debug("No segments in reserve; created a fresh one",
126126
SafeArg.of("segment", newSegment.id));
127127
hasAvailableSegments.signalAll();
128128
}
@@ -228,6 +228,9 @@ private void advanceAllocatingFrom(CommitLogSegment old)
228228
{
229229
allocatingFrom = next;
230230
activeSegments.add(next);
231+
logger.debug("Advanced allocating segment from {} to {}",
232+
SafeArg.of("old", old == null ? "null" : old.id),
233+
SafeArg.of("new", next.id));
231234
}
232235
}
233236

@@ -353,7 +356,8 @@ void recycleSegment(final CommitLogSegment segment)
353356
}
354357
else
355358
{
356-
logger.warn("segment {} not found in activeSegments queue", segment);
359+
logger.warn("Segment {} not found in activeSegments queue",
360+
SafeArg.of("segment", segment.id));
357361
}
358362
}
359363

0 commit comments

Comments
 (0)