Skip to content

Commit

Permalink
SAMZA-2795: Set thread to daemon thread for operator executor service (
Browse files Browse the repository at this point in the history
…#1690)

Description
As part of SAMZA-2781, we introduced operator executors to manage operator handoff execution. However, the threads created by the executor service are non-daemon and hence prevent the JVM from shutting down.

For context, we don't have a clean way to shutdown the executor due to lack of clean lifecycle management of the factory. Hence shutting down the executor service within TaskInstance is not an option and the fix is to make it daemon threads.

Changes
Make the threads spawned by the operator executor to be non-daemon

Tests
None

API Changes
None

Upgrade Instructions
None

Usage Instructions
None
  • Loading branch information
mynameborat authored Nov 8, 2023
1 parent 24e530d commit 2e91dfe
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public ExecutorService getOperatorExecutor(TaskName taskName, Config config) {
} else {
LOG.info("Using single threaded thread pool as operator thread pool for task {}", key.getTaskName());
operatorExecutor = Executors.newSingleThreadExecutor(
new ThreadFactoryBuilder().setNameFormat("Samza " + key.getTaskName() + " Thread-%d").build());
new ThreadFactoryBuilder().setNameFormat("Samza " + key.getTaskName() + " Thread-%d")
.setDaemon(true)
.build());
}

return operatorExecutor;
Expand Down

0 comments on commit 2e91dfe

Please sign in to comment.