You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/11 14:00:39 UTC
[GitHub] [iotdb] CRZbulabula commented on a diff in pull request #5869: [IOTDB-3167] Add wait_leader_ready logic for RatisConsensus
CRZbulabula commented on code in PR #5869:
URL: https://github.com/apache/iotdb/pull/5869#discussion_r870339592
##########
consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java:
##########
@@ -149,36 +154,38 @@ public void stop() throws IOException {
*/
@Override
public ConsensusWriteResponse write(
- ConsensusGroupId groupId, IConsensusRequest IConsensusRequest) {
+ ConsensusGroupId consensusGroupId, IConsensusRequest IConsensusRequest) {
// pre-condition: group exists and myself server serves this group
- RaftGroupId raftGroupId = Utils.fromConsensusGroupIdToRaftGroupId(groupId);
+ RaftGroupId raftGroupId = Utils.fromConsensusGroupIdToRaftGroupId(consensusGroupId);
RaftGroup raftGroup = getGroupInfo(raftGroupId);
if (raftGroup == null || !raftGroup.getPeers().contains(myself)) {
- return failedWrite(new ConsensusGroupNotExistException(groupId));
+ return failedWrite(new ConsensusGroupNotExistException(consensusGroupId));
}
// serialize request into Message
Message message = new RequestMessage(IConsensusRequest);
// 1. first try the local server
RaftClientRequest clientRequest =
- buildRawRequest(groupId, message, RaftClientRequest.writeRequestType());
+ buildRawRequest(raftGroupId, message, RaftClientRequest.writeRequestType());
RaftClientReply localServerReply;
RaftPeer suggestedLeader = null;
- try {
- localServerReply = server.submitClientRequest(clientRequest);
- if (localServerReply.isSuccess()) {
- ResponseMessage responseMessage = (ResponseMessage) localServerReply.getMessage();
- TSStatus writeStatus = (TSStatus) responseMessage.getContentHolder();
- return ConsensusWriteResponse.newBuilder().setStatus(writeStatus).build();
+ if (isLeader(consensusGroupId) && waitUntilLeaderReady(raftGroupId)) {
Review Comment:
I have a quick question, if the current node is leader, but it is not ready after 20 seconds, will it affect the consensus write? If so, would it be better to print a log here?
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org