From 790ec42ed0e706b4387e954dc9478b9a2eeedd94 Mon Sep 17 00:00:00 2001 From: Aldin Date: Tue, 24 Dec 2024 13:55:20 +0100 Subject: [PATCH] fix: command parsing and executing caused console dead lock (#1565) ### Motivation Executing a lot of commands while e.g. services are starting (printing messages to the console) can lead to dead locks. This issue was probably introduced with the cloud 2.0 migration. Prior to cloud 2.0 the framework used to run suggestions on the caller thread. With cloud 2.0 a shared thread pool for suggestion, parsing and executing can be used. This then leads to dead locks. ### Modification Explicitly set the thread pool for parsing & executing only. Suggestions are processed on the caller thread (thus restoring cloud 1.0 behavior. ### Result No dead-locks of the console. --- checkstyle.xml | 2 ++ .../node/command/defaults/DefaultCommandManager.java | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/checkstyle.xml b/checkstyle.xml index 99ecceb069..30eeafd672 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -36,6 +36,8 @@ + + diff --git a/node/src/main/java/eu/cloudnetservice/node/command/defaults/DefaultCommandManager.java b/node/src/main/java/eu/cloudnetservice/node/command/defaults/DefaultCommandManager.java index f58b23fbc1..7e91128f6d 100644 --- a/node/src/main/java/eu/cloudnetservice/node/command/defaults/DefaultCommandManager.java +++ b/node/src/main/java/eu/cloudnetservice/node/command/defaults/DefaultCommandManager.java @@ -38,8 +38,12 @@ final class DefaultCommandManager extends CommandManager { * a thread pool with 4 threads. */ private DefaultCommandManager() { + var executor = Executors.newFixedThreadPool(4); super( - ExecutionCoordinator.builder().executor(Executors.newFixedThreadPool(4)).build(), + ExecutionCoordinator.builder() + .parsingExecutor(executor) + .executionSchedulingExecutor(executor) + .build(), CommandRegistrationHandler.nullCommandRegistrationHandler()); this.registerCapability(CloudCapability.StandardCapabilities.ROOT_COMMAND_DELETION); }