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

3.6: DiscoveryStrategy destroy() not being called on shutdown #7545

Closed
simon-temple opened this issue Feb 18, 2016 · 9 comments

Comments

Projects
None yet
3 participants
@simon-temple
Copy link

commented Feb 18, 2016

I have a custom DiscoveryStrategy and I can't seem to get destroy() to be called on shutdown.

I'm assuming the hz.ShutdownThread will call destroy() on all enabled DiscoveryStrategies.

Am I doing something wrong?

@simon-temple

This comment has been minimized.

Copy link
Author

commented Feb 18, 2016

I'm not using a service registration file. Instead I add it directly:
join.getDiscoveryConfig().addDiscoveryStrategyConfig( new DiscoveryStrategyConfig( myFactory ) );

@simon-temple

This comment has been minimized.

Copy link
Author

commented Feb 18, 2016

ouch! removeShutdownHook() throws

        try {
            if(this.groupProperties.getBoolean(GroupProperty.SHUTDOWNHOOK_ENABLED)) {
                Runtime.getRuntime().removeShutdownHook(this.shutdownHookThread);
            }

            this.discoveryService.destroy();
        } catch (Throwable var10) {
            ;
        }

Node.java:389

@simon-temple

This comment has been minimized.

Copy link
Author

commented Feb 18, 2016

Workaround

config.setProperty( "hazelcast.shutdownhook.enabled", "false" );

@noctarius

This comment has been minimized.

Copy link
Contributor

commented Feb 18, 2016

What's the exception thrown? Maybe the discovery shutdown should be moved to a finally block

@simon-temple

This comment has been minimized.

Copy link
Author

commented Feb 18, 2016

IllegalStateException - If the virtual machine is already in the process of shutting down

Java 8

@noctarius

This comment has been minimized.

Copy link
Contributor

commented Feb 18, 2016

Possible to provide a full blown stacktrace? Doesn’t sounds like it's supposed to happen.

@simon-temple

This comment has been minimized.

Copy link
Author

commented Feb 18, 2016

I can confirm that is thrown from here:

if(hooks == null)
            throw new IllegalStateException("Shutdown in progress");

in ApplicationShutdownHooks: 82

The exception is ignored so it's hard to get you the stack trace

catch (Throwable ignored)

@emrahkocaman

This comment has been minimized.

Copy link
Contributor

commented Feb 22, 2016

I'll move discoveryService.destroy(); to it's own try-catch block and this'll solve the problem but I didn't understand why there is an exception while removing shutdown hook and I'm not able to reproduce the problem.

@simon-temple A simple project or test case that reproduces the problem would be great.

@emrahkocaman

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2016

@simon-temple Any luck to provide a test case?

@emrahkocaman emrahkocaman added this to the 3.6.2 milestone Mar 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.