Phillippko commented on code in PR #4433: URL: https://github.com/apache/ignite-3/pull/4433#discussion_r1774653070
########## modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageLearnerManager.java: ########## @@ -62,6 +64,10 @@ CompletableFuture<Void> updateLearners(long term) { } CompletableFuture<Void> addLearner(RaftGroupService raftService, ClusterNode learner) { + if (!learnersAdditionEnabled) { Review Comment: Something like `newLearnersAllowed` and consequently `forbidNewLearners`? ########## modules/raft/src/test/java/org/apache/ignite/internal/raft/server/DontHijackAfterGroupResetTest.java: ########## @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.raft.server; + +import static java.util.stream.Collectors.toSet; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Set; +import org.apache.ignite.raft.jraft.conf.Configuration; +import org.apache.ignite.raft.jraft.conf.ConfigurationEntry; +import org.apache.ignite.raft.jraft.entity.LogId; +import org.apache.ignite.raft.jraft.entity.PeerId; +import org.junit.jupiter.api.Test; + +class DontHijackAfterGroupResetTest { Review Comment: ```suggestion class DontHijackLeadershipAfterGroupResetTest { ``` ########## modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java: ########## @@ -3498,6 +3538,7 @@ public Status resetPeers(final Configuration newPeers) { LOG.info("Node {} set peers from {} to {}.", getNodeId(), this.conf.getConf(), newPeers); this.conf.setConf(newConf); this.conf.getOldConf().reset(); + stopAbstainingFromBecomingLeader(); Review Comment: let's add some breathing space for these code blocks, it became quite congested ########## modules/raft/src/main/java/org/apache/ignite/internal/raft/server/DontHijackAfterGroupReset.java: ########## @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.raft.server; + +import java.util.Set; +import org.apache.ignite.internal.tostring.IgniteToStringInclude; +import org.apache.ignite.internal.tostring.S; +import org.apache.ignite.raft.jraft.conf.ConfigurationEntry; +import org.apache.ignite.raft.jraft.entity.PeerId; + +/** + * Whether a Raft node should abstain from becoming a leader if it's a voting member but not one of the current Metastorage nodes + * (from the CMG). + */ +public class DontHijackAfterGroupReset implements LeadershipAbstaining { Review Comment: ```suggestion public class DontHijackLeadershipAfterGroupReset implements LeadershipAbstaining { ``` ########## modules/raft/src/test/java/org/apache/ignite/internal/raft/server/NeverAbstainTest.java: ########## @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.raft.server; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +import org.apache.ignite.raft.jraft.conf.ConfigurationEntry; +import org.apache.ignite.raft.jraft.entity.PeerId; +import org.junit.jupiter.api.Test; + +class NeverAbstainTest { Review Comment: I suggest unifying these test classes ########## modules/raft/src/main/java/org/apache/ignite/internal/raft/server/DontHijackAfterGroupReset.java: ########## @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.raft.server; + +import java.util.Set; +import org.apache.ignite.internal.tostring.IgniteToStringInclude; +import org.apache.ignite.internal.tostring.S; +import org.apache.ignite.raft.jraft.conf.ConfigurationEntry; +import org.apache.ignite.raft.jraft.entity.PeerId; + +/** + * Whether a Raft node should abstain from becoming a leader if it's a voting member but not one of the current Metastorage nodes + * (from the CMG). Review Comment: ```suggestion * Raft node abstains from becoming a leader if it's a voting member but not one of the current Metastorage nodes (from the CMG). Effective until any configuration change it gets. ``` ########## modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/NodeImpl.java: ########## @@ -231,6 +231,15 @@ public class NodeImpl implements Node, RaftServerService { /** Configuration of own striped disruptor for FSMCaller service of raft node, {@code null} means use shared disruptor. */ private final @Nullable RaftNodeDisruptorConfiguration ownFsmCallerExecutorDisruptorConfig; + /** + * This is set to {@code true} when the node realizes during its init that it must abstain from becoming a leader. + * This state will switch to {@code false} on any configuration update. + * + * <p>This allows to implement a protection from old Metastorage voting set (that did not see Metastorage repair [that is, group reset]) + * highjacking the leadership. + */ + private boolean abstainingFromBecomingLeader = false; Review Comment: ```suggestion private boolean leadershipForbidden = false; ``` Not insisting, but it could be more descriptive then stopAbstaining... will become `allowBecomingLeader` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org