diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java index 084f9f56d8..1dac2d1c63 100644 --- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java +++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java @@ -729,19 +729,19 @@ public static void removeUnfinishedCompactionLeftovers(CFMetaData metadata, Map< } // remove old sstables from compactions that did complete - for (Map.Entry> sstableFiles : directories.sstableLister().list().entrySet()) - { - Descriptor desc = sstableFiles.getKey(); - if (completedAncestors.contains(desc.generation)) - { - // if any of the ancestors were participating in a compaction, finish that compaction - logger.info("Going to delete leftover compaction ancestor {}", desc); - SSTable.delete(desc, sstableFiles.getValue()); - UUID compactionTaskID = unfinishedCompactions.get(desc.generation); - if (compactionTaskID != null) - SystemKeyspace.finishCompaction(unfinishedCompactions.get(desc.generation)); - } - } +// for (Map.Entry> sstableFiles : directories.sstableLister().list().entrySet()) +// { +// Descriptor desc = sstableFiles.getKey(); +// if (completedAncestors.contains(desc.generation)) +// { +// // if any of the ancestors were participating in a compaction, finish that compaction +// logger.info("Going to delete leftover compaction ancestor {}", desc); +// SSTable.delete(desc, sstableFiles.getValue()); +// UUID compactionTaskID = unfinishedCompactions.get(desc.generation); +// if (compactionTaskID != null) +// SystemKeyspace.finishCompaction(unfinishedCompactions.get(desc.generation)); +// } +// } } /** diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java b/src/java/org/apache/cassandra/service/CassandraDaemon.java index b0ff5c0a11..558afa0416 100644 --- a/src/java/org/apache/cassandra/service/CassandraDaemon.java +++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java @@ -54,7 +54,6 @@ import com.codahale.metrics.jvm.GarbageCollectorMetricSet; import com.codahale.metrics.jvm.MemoryUsageGaugeSet; import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.Uninterruptibles; @@ -260,21 +259,27 @@ private void completeSetupMayThrowSstableException() { // load schema from disk Schema.instance.loadFromDisk(); + // clean up compaction leftovers Map, Map> unfinishedCompactions = SystemKeyspace.getUnfinishedCompactions(); + for (Pair kscf : unfinishedCompactions.keySet()) + { + CFMetaData cfm = Schema.instance.getCFMetaData(kscf.left, kscf.right); + // CFMetaData can be null if CF is already dropped + if (cfm != null) + ColumnFamilyStore.removeUnfinishedCompactionLeftovers(cfm, unfinishedCompactions.get(kscf)); + } + SystemKeyspace.discardCompactionsInProgress(); + // clean up debris in the rest of the keyspaces for (String keyspaceName : Schema.instance.getKeyspaces()) { - // Skip system as we'll already clean it after the other tables + // Skip system as we've already cleaned it if (keyspaceName.equals(SystemKeyspace.NAME)) continue; for (CFMetaData cfm : Schema.instance.getKeyspaceMetaData(keyspaceName).values()) - { - ColumnFamilyStore.removeUnfinishedCompactionLeftovers(cfm, unfinishedCompactions.getOrDefault(cfm.ksAndCFName, ImmutableMap.of())); ColumnFamilyStore.scrubDataDirectories(cfm); - } } - SystemKeyspace.discardCompactionsInProgress(); Keyspace.setInitialized();