bitflicker64 commented on code in PR #3376:
URL: https://github.com/apache/hugegraph/pull/3376#discussion_r4328671905
##########
hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/raft/RaftEngine.java:
##########
@@ -650,6 +668,74 @@ public Node getRaftNode() {
return raftNode;
}
+ /**
+ * The last index of this node's raft log when the node started. After a
restart jraft
+ * applies the log after the last snapshot again, and every entry at or
below this index
+ * is such a replay; an entry above it is new in this run. Long.MAX_VALUE
while no node
+ * runs or the index could not be read, so every entry counts as a replay
then.
+ */
+ public long getLastLogIndexAtStart() {
+ return this.lastLogIndexAtStart;
+ }
+
+ /**
+ * Fails when a peer of the current configuration is not confirmed to
apply the TXN
+ * entry, see {@link TxnPeerGate}; does nothing without a node
+ *
+ * @throws PDException TXN_NOT_PROPOSED
+ */
+ public void checkTxnPeers() throws PDException {
+ TxnPeerGate gate = this.txnPeerGate;
+ if (gate != null) {
+ gate.check();
+ }
+ }
+
+ /**
+ * Fails when a peer of a configuration about to be installed is not
confirmed to apply
+ * the TXN entry: a peer that joins replays the log, TXN entries included.
Called before
+ * every membership change; does nothing without a node
+ *
+ * @throws PDException TXN_NOT_PROPOSED, naming the peer
+ */
+ public void checkTxnPeers(Configuration next) throws PDException {
+ TxnPeerGate gate = this.txnPeerGate;
+ if (gate == null) {
+ return;
+ }
+ PeerId self = this.config == null ? null :
JRaftUtils.getPeerId(this.config.getAddress());
+ List<String> endpoints = new ArrayList<>();
+ List<PeerId> peers = new ArrayList<>(next.getPeers());
+ peers.addAll(next.getLearners());
+ for (PeerId peer : peers) {
+ if (!PeerUtil.isPeerEquals(peer, self)) {
+ endpoints.add(peer.getEndpoint().toString());
+ }
+ }
+ gate.confirm(endpoints);
Review Comment:
Fixed in 8a1a8369b. `RaftEngine.checkTxnPeers(Configuration)` now confirms
only the peers the change adds: a peer of `next` that is already in
`listPeers()` or `listLearners()` is left out, since the check before every txn
covers it. Both of your cases now pass: a kept member that is silent or answers
`maxKvOp` 0 does not stop `changePeerList`, and `updatePdRaft` goes through the
same method. Test:
`RaftEngineIpAuthIntegrationTest.testChangePeerListIgnoresKeptMembers` (an old
and a silent kept voter, a kept learner, one added peer, which alone is
probed); the added-peer refusal test stays. The api-reference paragraph and the
rollout note now say "every peer it adds".
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]