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

Node Initialization order is wrong #11681

Closed
Glamdring opened this issue Oct 27, 2017 · 6 comments
Closed

Node Initialization order is wrong #11681

Glamdring opened this issue Oct 27, 2017 · 6 comments

Comments

@Glamdring
Copy link

@Glamdring Glamdring commented Oct 27, 2017

While trying to setup Hazelcast on AWS I got a strange NullPointerException:

Caused by: java.lang.NullPointerException: null
        at com.hazelcast.partition.membergroup.SPIAwareMemberGroupFactory.createInternalMemberGroups(SPIAwareMemberGroupFactory.java:59)

Digging a little bit lead me to the Node class, line 209. There the PartitionService is initialized with the yet-uninitialized node. A few calls up the stack, through PartitionStateManager, there's a call to node.getDiscoveryService() which at this stage returns null and hence the SPIAwareMemberGroupFactory is initialized with a null discovery service. This is rather unfortunate, as it means practically Hazelcast is not working in this setup (SPI discovery).

@jerrinot jerrinot added this to the 3.9.1 milestone Oct 27, 2017
@jerrinot
Copy link
Contributor

@jerrinot jerrinot commented Oct 27, 2017

@Glamdring: thanks for reporting this, much appreciated!
just to double-check: what's Hazelcast version is this?

@Glamdring
Copy link
Author

@Glamdring Glamdring commented Oct 28, 2017

@jerrinot 3.8.6

@jerrinot jerrinot self-assigned this Oct 30, 2017
@jerrinot
Copy link
Contributor

@jerrinot jerrinot commented Oct 30, 2017

@Glamdring: you are right, it's a bug, once again thanks for reporting it! Let me see what we can do about it.

What discovery implementation are you using? I have yet to write a test for this but I reckon as a workaround you could just change your PartitionGroupConfig not use use the SPI for creating member groups. The SPI will be still use for discovery, but it won't be used for creating member groups. You could use e.g. the PER_MEMBER strategy.

jerrinot added a commit to jerrinot/hazelcast that referenced this issue Oct 30, 2017
Fixes hazelcast#11681

InternalPartitionServiceImpl uses Discovery Service which was not initialized
properly at the time when InternalPartitionServiceImpl used it.

This changes is fixing this.
@Glamdring
Copy link
Author

@Glamdring Glamdring commented Oct 30, 2017

@jerrinot I'm using hazelcast-aws (https://github.com/hazelcast/hazelcast-aws) as follows:

       config.getPartitionGroupConfig()
                .setGroupType(PartitionGroupConfig.MemberGroupType.SPI)
                .setEnabled(true);
        config.getProperties().put("hazelcast.discovery.enabled", true);
        JoinConfig joinConfig = config.getNetworkConfig().getJoin();
        joinConfig.getTcpIpConfig().setEnabled(false);
        joinConfig.getMulticastConfig().setEnabled(false);
        DiscoveryStrategyConfig discoveryStrategy = new DiscoveryStrategyConfig(new AwsDiscoveryStrategyFactory());
        joinConfig.getDiscoveryConfig().getDiscoveryStrategyConfigs().add(discoveryStrategy);
        joinConfig.getDiscoveryConfig().setDiscoveryServiceProvider(new DefaultDiscoveryServiceProvider());
        discoveryStrategy.addProperty("iam-role", iamRole);
        discoveryStrategy.addProperty("region", new DefaultAwsRegionProviderChain().getRegion());
        discoveryStrategy.addProperty("host-header", "ec2.amazonaws.com");
        discoveryStrategy.addProperty("security-group-name", hazelcastSecurityGroup);
@Glamdring
Copy link
Author

@Glamdring Glamdring commented Oct 30, 2017

btw you may spot a slight issue with my config - config.getProperties().put("...", true) is putting a boolean and not a string. And that check later fails silently. What's the reason for exposing the properties? You are allowing users of the API to violate the restrictions that the config.setProperty(..) has imposed

@Glamdring
Copy link
Author

@Glamdring Glamdring commented Oct 30, 2017

Switching to ZONE_AWARE worked; previously it failed because of the boolean vs string property

jerrinot added a commit to jerrinot/hazelcast that referenced this issue Oct 31, 2017
Fixes hazelcast#11681

InternalPartitionServiceImpl uses Discovery Service which was not initialized
properly at the time when InternalPartitionServiceImpl used it.

This changes is fixing this.

(cherry picked from commit e655267)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.