You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2020/08/24 11:16:10 UTC
[cassandra] branch trunk updated: Initialize sstables earlier to
avoid NPE in CompactionIterator
This is an automated email from the ASF dual-hosted git repository.
marcuse pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 219eb86 Initialize sstables earlier to avoid NPE in CompactionIterator
219eb86 is described below
commit 219eb86fd22805d419667c791af4419cd2b3d00a
Author: Marcus Eriksson <ma...@apache.org>
AuthorDate: Thu Aug 20 08:51:29 2020 +0200
Initialize sstables earlier to avoid NPE in CompactionIterator
Patch by marcuse; reviewed by Brandon Williams and Jon Meredith for CASSANDRA-16062
---
src/java/org/apache/cassandra/db/compaction/CompactionIterator.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionIterator.java b/src/java/org/apache/cassandra/db/compaction/CompactionIterator.java
index 78bdfb0..ec6a4d4 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionIterator.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionIterator.java
@@ -99,6 +99,9 @@ public class CompactionIterator extends CompactionInfo.Holder implements Unfilte
bytes += scanner.getLengthInBytes();
this.totalBytes = bytes;
this.mergeCounters = new long[scanners.size()];
+ // note that we leak `this` from the constructor when calling beginCompaction below, this means we have to get the sstables before
+ // calling that to avoid a NPE.
+ sstables = scanners.stream().map(ISSTableScanner::getBackingSSTables).flatMap(Collection::stream).collect(ImmutableSet.toImmutableSet());
this.activeCompactions = activeCompactions == null ? ActiveCompactionsTracker.NOOP : activeCompactions;
this.activeCompactions.beginCompaction(this); // note that CompactionTask also calls this, but CT only creates CompactionIterator with a NOOP ActiveCompactions
@@ -109,7 +112,6 @@ public class CompactionIterator extends CompactionInfo.Holder implements Unfilte
merged = Transformation.apply(merged, new Purger(controller, nowInSec));
merged = DuplicateRowChecker.duringCompaction(merged, type);
compacted = Transformation.apply(merged, new AbortableUnfilteredPartitionTransformation(this));
- sstables = scanners.stream().map(ISSTableScanner::getBackingSSTables).flatMap(Collection::stream).collect(ImmutableSet.toImmutableSet());
}
public TableMetadata metadata()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org