Use cachedThreadPool which uses SynchronousQueue instead of ArrayBlockingQueue.

When ArrayBlockingQueue is used (as in case of using Utilities.getListeningExecutorService) the maxPoolSize
has no effect. The pool creates never more threads than the core pool size.
Thus we have been limited to 15 threads for message sending and connection creation.
This was likely a reason why seed nodes are not accepting new connections if the pool is exhausted.
Slow message send can block a thread for 1-3 minutes.

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2022-12-13 17:33:16 -05:00
parent 071a352443
commit f90c4b8f6b
No known key found for this signature in database
GPG key ID: 02AA2BAE387C8307

View file

@ -439,11 +439,9 @@ public abstract class NetworkNode implements MessageListener {
///////////////////////////////////////////////////////////////////////////////////////////
void createExecutorService() {
if (executorService == null)
executorService = Utilities.getListeningExecutorService("NetworkNode-" + servicePort,
maxConnections * 2,
maxConnections * 4,
60);
if (executorService == null) {
executorService = MoreExecutors.listeningDecorator(Utilities.newCachedThreadPool(maxConnections * 4, 3, TimeUnit.MINUTES));
}
}
void startServer(ServerSocket serverSocket) {