Fix exception during cleanup for Leveled compaction

patch by jbellis & slebresne; reviewed by jbellis & slebresne for CASSANDRA-4112
This commit is contained in:
Sylvain Lebresne 2012-04-03 16:32:58 +02:00
parent 67e88da62e
commit 3fd0fb6aa0
2 changed files with 10 additions and 10 deletions

View File

@ -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 File

@ -188,17 +188,17 @@ public class LeveledManifest
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();
}