Clean up ScheduledExecutors, CommitLog, and MessagingService shutdown for in-JVM dtests

patch by Caleb Rackliffe; reviewed by David Capwell for CASSANDRA-17731
This commit is contained in:
Caleb Rackliffe 2022-07-12 12:06:56 -05:00
parent ec476e0e25
commit d51f90201b
3 changed files with 12 additions and 11 deletions

View File

@ -1,4 +1,5 @@
4.0.5
* Clean up ScheduledExecutors, CommitLog, and MessagingService shutdown for in-JVM dtests (CASSANDRA-17731)
* Utilise BTree improvements to reduce garbage and improve throughput (CASSANDRA-15511)
* Make sure existing delayed tasks in StreamTransferTask cannot prevent clean shutdown (CASSANDRA-17706)
* SSL storage port in sstableloader is deprecated (CASSANDRA-17602)

View File

@ -787,27 +787,29 @@ public class Instance extends IsolatedExecutor implements IInvokableInstance
() -> Ref.shutdownReferenceReaper(1L, MINUTES),
() -> Memtable.MEMORY_POOL.shutdownAndWait(1L, MINUTES),
() -> DiagnosticSnapshotService.instance.shutdownAndWait(1L, MINUTES),
() -> ScheduledExecutors.shutdownAndWait(1L, MINUTES),
() -> SSTableReader.shutdownBlocking(1L, MINUTES),
() -> shutdownAndWait(Collections.singletonList(ActiveRepairService.repairCommandExecutor()))
);
error = parallelRun(error, executor, () -> ScheduledExecutors.shutdownAndWait(1L, MINUTES));
internodeMessagingStarted = false;
error = parallelRun(error, executor,
CommitLog.instance::shutdownBlocking,
// can only shutdown message once, so if the test shutsdown an instance, then ignore the failure
(IgnoreThrowingRunnable) () -> MessagingService.instance().shutdown(1L, MINUTES, false, true)
);
error = parallelRun(error, executor,
() -> GlobalEventExecutor.INSTANCE.awaitInactivity(1l, MINUTES),
() -> GlobalEventExecutor.INSTANCE.awaitInactivity(1L, MINUTES),
() -> Stage.shutdownAndWait(1L, MINUTES),
() -> SharedExecutorPool.SHARED.shutdownAndWait(1L, MINUTES)
);
error = parallelRun(error, executor,
() -> shutdownAndWait(Collections.singletonList(JMXBroadcastExecutor.executor))
);
// CommitLog must shut down after Stage, or threads from the latter may attempt to use the former.
// (ex. A Mutation stage thread may attempt to add a mutation to the CommitLog.)
error = parallelRun(error, executor, CommitLog.instance::shutdownBlocking);
error = parallelRun(error, executor, () -> shutdownAndWait(Collections.singletonList(JMXBroadcastExecutor.executor)));
// ScheduledExecutors shuts down after MessagingService, as MessagingService may issue tasks to it.
error = parallelRun(error, executor, () -> ScheduledExecutors.shutdownAndWait(1L, MINUTES));
Throwables.maybeFail(error);
}).apply(isolatedExecutor);

View File

@ -145,9 +145,7 @@ public class RepairErrorsTest extends TestBaseImpl
@SuppressWarnings("Convert2MethodRef")
private void assertNoActiveRepairSessions(IInvokableInstance instance)
{
// Make sure we've cleaned up sessions and parent sessions:
Integer parents = instance.callOnInstance(() -> ActiveRepairService.instance.parentRepairSessionCount());
assertEquals(0, parents.intValue());
// Make sure we've cleaned up local sessions:
Integer sessions = instance.callOnInstance(() -> ActiveRepairService.instance.sessionCount());
assertEquals(0, sessions.intValue());
}