From d671e665009033031717beb7c31e746189a9020b Mon Sep 17 00:00:00 2001 From: Mukul Kumar Singh Date: Thu, 13 Sep 2018 11:29:31 +0530 Subject: [PATCH] HDDS-420. putKey failing with KEY_ALLOCATION_ERROR. Contributed by Shashikant Banerjee. (cherry picked from commit c6e19db197253b660c8b16854360fe95b1d7c43f) --- .../ozone/container/common/statemachine/StateContext.java | 2 +- .../common/transport/server/ratis/XceiverServerRatis.java | 3 +++ .../org/apache/hadoop/hdds/scm/node/StaleNodeHandler.java | 4 ++++ .../hdds/scm/pipelines/PipelineActionEventHandler.java | 2 ++ .../hadoop/hdds/scm/pipelines/ratis/RatisManagerImpl.java | 8 ++++---- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/StateContext.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/StateContext.java index c2d54213476..9d5a7781b03 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/StateContext.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/StateContext.java @@ -280,7 +280,7 @@ public class StateContext { && pipelineActionIter.hasClosePipeline() && pipelineAction .hasClosePipeline() && pipelineActionIter.getClosePipeline().getPipelineID() - == pipelineAction.getClosePipeline().getPipelineID()) { + .equals(pipelineAction.getClosePipeline().getPipelineID())) { return; } } diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java index f7753968ddb..38d826b3e28 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java @@ -397,6 +397,9 @@ public final class XceiverServerRatis implements XceiverServerSpi { .setAction(PipelineAction.Action.CLOSE) .build(); context.addPipelineActionIfAbsent(action); + LOG.debug( + "pipeline Action " + action.getAction() + " on pipeline " + pipelineID + + ".Reason : " + action.getClosePipeline().getDetailedReason()); } void handleNodeSlowness( diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StaleNodeHandler.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StaleNodeHandler.java index 0bd93395c31..b435e777aee 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StaleNodeHandler.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StaleNodeHandler.java @@ -25,6 +25,8 @@ import org.apache.hadoop.hdds.scm.events.SCMEvents; import org.apache.hadoop.hdds.scm.node.states.Node2ContainerMap; import org.apache.hadoop.hdds.server.events.EventHandler; import org.apache.hadoop.hdds.server.events.EventPublisher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Set; @@ -32,6 +34,7 @@ import java.util.Set; * Handles Stale node event. */ public class StaleNodeHandler implements EventHandler { + static final Logger LOG = LoggerFactory.getLogger(StaleNodeHandler.class); private final Node2ContainerMap node2ContainerMap; private final Mapping containerManager; @@ -48,6 +51,7 @@ public class StaleNodeHandler implements EventHandler { Set pipelineIDs = containerManager.getPipelineOnDatanode(datanodeDetails); for (PipelineID id : pipelineIDs) { + LOG.info("closing pipeline {}.", id); publisher.fireEvent(SCMEvents.PIPELINE_CLOSE, id); } } diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineActionEventHandler.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineActionEventHandler.java index 54c240037f9..1053149bba8 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineActionEventHandler.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineActionEventHandler.java @@ -50,6 +50,8 @@ public class PipelineActionEventHandler implements case CLOSE: PipelineID pipelineID = PipelineID. getFromProtobuf(action.getClosePipeline().getPipelineID()); + LOG.info("Closing pipeline " + pipelineID + " for reason:" + action + .getClosePipeline().getDetailedReason()); publisher.fireEvent(SCMEvents.PIPELINE_CLOSE, pipelineID); break; default: diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/ratis/RatisManagerImpl.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/ratis/RatisManagerImpl.java index 150802e2b18..0342e18c55a 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/ratis/RatisManagerImpl.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/ratis/RatisManagerImpl.java @@ -110,15 +110,15 @@ public class RatisManagerImpl extends PipelineManager { * Close the pipeline. */ public void closePipeline(Pipeline pipeline) throws IOException { + try (XceiverClientRatis client = + XceiverClientRatis.newXceiverClientRatis(pipeline, conf)) { + client.destroyPipeline(); + } super.closePipeline(pipeline); for (DatanodeDetails node : pipeline.getMachines()) { // A node should always be the in ratis members list. Preconditions.checkArgument(ratisMembers.remove(node)); } - try (XceiverClientRatis client = - XceiverClientRatis.newXceiverClientRatis(pipeline, conf)) { - client.destroyPipeline(); - } } /**