Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObservableScheduledExecutorService not shut down gracefully enough #33

Open
llehtinen opened this issue May 6, 2023 · 0 comments
Open

Comments

@llehtinen
Copy link
Contributor

llehtinen commented May 6, 2023

ObservableScheduledExecutorService from tw-observability-base gets shut down like any other executor service 1️⃣, which can cause noisy errors during shutdown: https://rollbar.com/Wise/fin/items/19353/ (relevant logs):

java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@1398b0cd[Not completed, task = java.util.concurrent.Executors$RunnableAdapter@1d07069f[Wrapped task = io.micrometer.core.instrument.Timer$$Lambda$2367/0x0000000801f77ae0@228d9ce7]] rejected from java.util.concurrent.ScheduledThreadPoolExecutor@3d42f7d2[Shutting down, pool size = 10, active threads = 2, queued tasks = 6, completed tasks = 764]
	at java.base/java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2065)
	at java.base/java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:833)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:340)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:562)
	at io.micrometer.core.instrument.internal.TimedScheduledExecutorService.schedule(TimedScheduledExecutorService.java:128)
	at com.transferwise.observability.base.internal.async.executor.ObservableScheduledExecutorService.schedule(ObservableScheduledExecutorService.java:20)

Ideally, the shutdown logic would find the delegate 2️⃣ in the screenshot, and apply the shutdownScheduledThreadPoolExecutor logic 3️⃣ to it:

    scheduledThreadPoolExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
    scheduledThreadPoolExecutor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
    scheduledThreadPoolExecutor.getQueue().clear();
    scheduledThreadPoolExecutor.shutdown();

Screenshot 2023-05-06 at 18 12 24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant