hazelcast / hazelcast/hazelcast
Shutdown hook causes issues due to lack of dependency ordering
- Dominant language
- Java
- Stars
- 6.6k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
An issue was recently reported against https://github.com/mpilone/hazelcastmq where a `com.hazelcast.core.HazelcastInstanceNotActiveException` is raised during application shutdown. I tracked the issue down to the fact that Hazelcast registers a shutdown hook by default. This causes problems if the application depends on using a shutdown hook itself because the order of the hook execution by the JVM is not guaranteed which means Hazelcast could (and usually is) shutdown before the rest of the application.
I found a workaround of setting the property `config.setProperty(GroupProperties.PROP_SHUTDOWNHOOK_ENABLED, "false");` which disables the Hz shutdown hook.
It would be nice if this was a top level field on the Hz configuration or if Hz didn't register a shutdown hook by default and instead depended on the application to properly shut it down like most other server libraries. It seems like adding a shutdown hook should be an optional feature, not the default behavior. Maybe adding an `autoShutdown` option to the configuration with a default of false would make more sense.
The details of the issue reported to HzMq can be found here: https://github.com/mpilone/hazelcastmq/issues/4
Contributor guide
Research direction
Start by locating Hazelcast's configuration handling and the code that registers the JVM shutdown hook; compare the existing GroupProperties.PROP_SHUTDOWNHOOK_ENABLED workaround with the requested top-level configuration behavior. Review the linked HazelcastMQ issue for the failure context, then define and test one consistent opt-in or opt-out shutdown policy before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100