Skip to content

[IOTDB-4114] Add safety check for createPeer#7133

Closed
SzyWilliam wants to merge 1 commit intoapache:masterfrom
SzyWilliam:ratis_idempotent_create
Closed

[IOTDB-4114] Add safety check for createPeer#7133
SzyWilliam wants to merge 1 commit intoapache:masterfrom
SzyWilliam:ratis_idempotent_create

Conversation

@SzyWilliam
Copy link
Copy Markdown
Member

When ConfigNode or DataNode calls Consensus.createPeer twice with exact groupID, RatisConsensus will allow the second createPeer to be executed. This will cause unexpected errors, as overlapping files could interfere each other.
In this PR I propose to add a pre-condition check in createPeer so that the same Peer will not be created twice on one node.

Comment on lines +260 to +265
RaftGroupId raftGroupId = Utils.fromConsensusGroupIdToRaftGroupId(groupId);
RaftGroup existGroup = getGroupInfo(raftGroupId);
// pre-conditions: the new group not exists
if (existGroup != null) {
return failed(new ConsensusGroupAlreadyExistException(groupId));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that even if you do this check, it could not totally prevent this problem because this checking and creating are not atomically.

@SzyWilliam
Copy link
Copy Markdown
Member Author

This Pr should be close because the issue4114 is caused by starting confignode twice on one single machine.

@SzyWilliam SzyWilliam closed this Aug 30, 2022
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

Successfully merging this pull request may close these issues.

2 participants