Skip to content

Commit

Permalink
Add some additional logging to StorageService#drain (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuffy authored Nov 21, 2024
1 parent 47abc3b commit afa0513
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/java/org/apache/cassandra/service/StorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4635,18 +4635,18 @@ private synchronized void drainInternal() throws IOException, InterruptedExcepti
ScheduledExecutors.optionalTasks.shutdown();
Gossiper.instance.stop();

setMode(Mode.DRAINING, "shutting down MessageService", false);
setMode(Mode.DRAINING, "shutting down MessageService", true);
MessagingService.instance().shutdown();

setMode(Mode.DRAINING, "clearing mutation stage", false);
setMode(Mode.DRAINING, "clearing mutation stage", true);
counterMutationStage.shutdown();
mutationStage.shutdown();
counterMutationStage.awaitTermination(3600, TimeUnit.SECONDS);
mutationStage.awaitTermination(3600, TimeUnit.SECONDS);

StorageProxy.instance.verifyNoHintsInProgress();

setMode(Mode.DRAINING, "flushing column families", false);
setMode(Mode.DRAINING, "flushing column families", true);
// count CFs first, since forceFlush could block for the flushWriter to get a queue slot empty
totalCFs = 0;
for (Keyspace keyspace : Keyspace.nonSystem())
Expand All @@ -4668,6 +4668,7 @@ private synchronized void drainInternal() throws IOException, InterruptedExcepti
remainingCFs--;
}

setMode(Mode.DRAINING, "shutdown BatchlogManager", true);
try
{
/* not clear this is reasonable time, but propagated from prior embedded behaviour */
Expand All @@ -4678,6 +4679,7 @@ private synchronized void drainInternal() throws IOException, InterruptedExcepti
logger.error("Batchlog manager timed out shutting down", t);
}

setMode(Mode.DRAINING, "shutdown CompactionManager", true);
// Interrupt on going compaction and shutdown to prevent further compaction
CompactionManager.instance.forceShutdown();

Expand All @@ -4686,6 +4688,7 @@ private synchronized void drainInternal() throws IOException, InterruptedExcepti
// Flush system tables after stopping the batchlog manager and compactions since they both modify
// system tables (for example compactions can obsolete sstables and the tidiers in SSTableReader update
// system tables, see SSTableReader.GlobalTidy)
setMode(Mode.DRAINING, "flush system tables", true);
flushes.clear();
for (Keyspace keyspace : Keyspace.system())
{
Expand All @@ -4694,12 +4697,14 @@ private synchronized void drainInternal() throws IOException, InterruptedExcepti
}
FBUtilities.waitOnFutures(flushes);

setMode(Mode.DRAINING, "shutdown Commitlog", true);
// whilst we've flushed all the CFs, which will have recycled all completed segments, we want to ensure
// there are no segments to replay, so we force the recycling of any remaining (should be at most one)
CommitLog.instance.forceRecycleAllSegments("Drain");

CommitLog.instance.shutdownBlocking();

setMode(Mode.DRAINING, "shutdown non-periodic tasks", true);
// wait for miscellaneous tasks like sstable and commitlog segment deletion
ScheduledExecutors.nonPeriodicTasks.shutdown();
if (!ScheduledExecutors.nonPeriodicTasks.awaitTermination(1, MINUTES))
Expand Down

0 comments on commit afa0513

Please sign in to comment.