Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix exception during cleanup for Leveled compaction

patch by jbellis & slebresne; reviewed by jbellis & slebresne for CASSANDRA-4112
  • Loading branch information...
commit 3fd0fb6aa0038f0c8aaf34f98f2ceed2f308a501 1 parent 67e88da
@pcmanus pcmanus authored
View
2  CHANGES.txt
@@ -9,7 +9,7 @@
* Avoid NPE during repair when a keyspace has no CFs (CASSANDRA-3988)
* Fix division-by-zero error on get_slice (CASSANDRA-4000)
* don't change manifest level for cleanup, scrub, and upgradesstables
- operations under LeveledCompactionStrategy (CASSANDRA-3989)
+ operations under LeveledCompactionStrategy (CASSANDRA-3989, 4112)
* fix race leading to super columns assertion failure (CASSANDRA-3957)
* ensure that directory is selected for compaction for user-defined
tasks and upgradesstables (CASSANDRA-3985)
View
18 src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
@@ -188,17 +188,17 @@ public synchronized void promote(Iterable<SSTableReader> removed, Iterable<SSTab
public synchronized void replace(Iterable<SSTableReader> removed, Iterable<SSTableReader> added)
{
- // replace is for compaction operation that don't really change the
- // content of a sstable (cleanup, scrub) and much replace one sstable by another
- assert Iterables.size(removed) == 1;
- assert Iterables.size(added) == 1;
- SSTableReader toRemove = removed.iterator().next();
- SSTableReader toAdd = added.iterator().next();
+ // replace is for compaction operation that operate on exactly one sstable, with no merging.
+ // Thus, removed will be exactly one sstable, and added will be 0 or 1.
+ assert Iterables.size(removed) == 1 : Iterables.size(removed);
+ assert Iterables.size(added) <= 1 : Iterables.size(added);
logDistribution();
- if (logger.isDebugEnabled())
- logger.debug("Replacing " + removed + " by " + toAdd);
+ logger.debug("Replacing {} with {}", removed, added);
+
+ int level = remove(removed.iterator().next());
+ if (!Iterables.isEmpty(added))
+ add(added.iterator().next(), level);
- add(toAdd, remove(toRemove));
serialize();
}
Please sign in to comment.
Something went wrong with that request. Please try again.