Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip ancestor deletion on startup #537

Open
wants to merge 4 commits into
base: palantir-cassandra-2.2.18
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -729,19 +729,19 @@ public static void removeUnfinishedCompactionLeftovers(CFMetaData metadata, Map<
}

// remove old sstables from compactions that did complete
for (Map.Entry<Descriptor, Set<Component>> 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<Descriptor, Set<Component>> 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));
// }
// }
}

/**
Expand Down
17 changes: 11 additions & 6 deletions src/java/org/apache/cassandra/service/CassandraDaemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -260,21 +259,27 @@ private void completeSetupMayThrowSstableException() {
// load schema from disk
Schema.instance.loadFromDisk();

// clean up compaction leftovers
Map<Pair<String, String>, Map<Integer, UUID>> unfinishedCompactions = SystemKeyspace.getUnfinishedCompactions();
for (Pair<String, String> 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();

Expand Down