Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ public void handle(SCMCommand command, OzoneContainer ozoneContainer,
try {
XceiverServerSpi server = ozoneContainer.getWriteChannel();
if (server.isExist(pipelineIdProto)) {
server.removeGroup(pipelineIdProto);
if (server instanceof XceiverServerRatis) {
// TODO: Refactor Ratis logic to XceiverServerRatis
// Propagate the group remove to the other Raft peers in the pipeline
XceiverServerRatis ratisServer = (XceiverServerRatis) server;
final RaftGroupId raftGroupId = RaftGroupId.valueOf(pipelineID.getId());
final Collection<RaftPeer> peers = ratisServer.getRaftPeersInPipeline(pipelineID);
final boolean shouldDeleteRatisLogDirectory = ratisServer.getShouldDeleteRatisLogDirectory();
// This might throw GroupMismatchException if the Ratis group has been closed by other datanodes
final Collection<RaftPeer> peers = ratisServer.getRaftPeersInPipeline(pipelineID);
// Try to send remove group for the other datanodes first, ignoring GroupMismatchException
// if the Ratis group has been closed in the other datanodes
peers.stream()
.filter(peer -> !peer.getId().equals(ratisServer.getServer().getId()))
.forEach(peer -> {
Expand All @@ -122,17 +124,29 @@ public void handle(SCMCommand command, OzoneContainer ozoneContainer,
} catch (GroupMismatchException ae) {
// ignore silently since this means that the group has been closed by earlier close pipeline
// command in another datanode
LOG.debug("Failed to remove group {} for pipeline {} on peer {} since the group has " +
"been removed by earlier close pipeline command handled in another datanode", raftGroupId,
pipelineID, peer.getId());
} catch (IOException ioe) {
LOG.warn("Failed to remove group {} for peer {}", raftGroupId, peer.getId(), ioe);
LOG.warn("Failed to remove group {} of pipeline {} on peer {}",
raftGroupId, pipelineID, peer.getId(), ioe);
}
});
}
// Remove the Ratis group from the current datanode pipeline, might throw GroupMismatchException as
// well. It is a no-op for XceiverServerSpi implementations (e.g. XceiverServerGrpc)
server.removeGroup(pipelineIdProto);
LOG.info("Close Pipeline {} command on datanode {}.", pipelineID,
dn.getUuidString());
} else {
LOG.debug("Ignoring close pipeline command for pipeline {} " +
"as it does not exist", pipelineID);
LOG.debug("Ignoring close pipeline command for pipeline {} on datanode {} " +
"as it does not exist", pipelineID, dn.getUuidString());
}
} catch (GroupMismatchException gme) {
// ignore silently since this means that the group has been closed by earlier close pipeline
// command in another datanode
LOG.debug("The group for pipeline {} on datanode {} has been removed by earlier close " +
"pipeline command handled in another datanode", pipelineID, dn.getUuidString());
Copy link
Contributor

Choose a reason for hiding this comment

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

@ivandika3 , Since HddsClientUtils.containsException below will cover this case, let's remove catch (GroupMismatchException gme) {...}?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review. Updated.

} catch (IOException e) {
LOG.error("Can't close pipeline {}", pipelineID, e);
} finally {
Expand Down