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

Prevent addons from shutting down shared thread pools #2465

Closed
janvyb opened this issue Aug 26, 2021 · 2 comments
Closed

Prevent addons from shutting down shared thread pools #2465

janvyb opened this issue Aug 26, 2021 · 2 comments

Comments

@janvyb
Copy link
Contributor

janvyb commented Aug 26, 2021

openHAB provides addons with API for obtaining shared thread pools (ThreadPoolManager), which is also used to obtain scheduler property in BaseThingHandler. It's a good thing so that everyone isn't spawning their own threads and most addons use it.

The problem is that nothing stops any addon from shutting down this shared pool, which has catastrophic consequences. When that happens, all addons/services which use that shared pool stop working, throwing java.util.concurrent.RejectedExecutionException when they try to schedule new jobs. There's no way to recover from that other than restarting openHAB, and it's also hard to diagnose since lots of things keeps working fine.

I've recently encountered this problem with miio binding, but forum seems to be full of similar problems (like this or this, and I'm certaint that I encountered this problem a few times myself before) and it's pretty much impossible from logs to find out what happened, because the exception is thrown from first addon that tries to use that shared pool after it was shut down.

I'd propose overriding shutdown() and shutdownNow() methods on WrappedScheduledExecutorService (and maybe also on QueueingThreadPoolExecutor) to either do nothing, or at least log some warning with stack trace when someone calls them. It shouldn't cause any issues since ThreadPoolManager isn't shutting them down and noone else should either since they are supposed to be shared.

@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/solved-task-java-util-concurrent-scheduledthreadpoolexecutor-scheduledfuturetask-not-completed-errors/124629/7

@wborn
Copy link
Member

wborn commented Oct 13, 2021

This issue seems to duplicate #760.

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

No branches or pull requests

3 participants