This is an automated email from the ASF dual-hosted git repository.
sodonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new fc97293f29 HDDS-9550. Container report shows missing containers when
they actually appear empty (#5523)
fc97293f29 is described below
commit fc97293f29d0c66b94bc371a55b67f8f6a0b0944
Author: Stephen O'Donnell <[email protected]>
AuthorDate: Thu Nov 2 19:29:09 2023 +0000
HDDS-9550. Container report shows missing containers when they actually
appear empty (#5523)
---
.../replication/health/EmptyContainerHandler.java | 15 +++++++++++++++
.../health/TestEmptyContainerHandler.java | 22 ++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/EmptyContainerHandler.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/EmptyContainerHandler.java
index 29945a950d..69804698f2 100644
---
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/EmptyContainerHandler.java
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/EmptyContainerHandler.java
@@ -69,6 +69,21 @@ public class EmptyContainerHandler extends AbstractCheck {
replicationManager.updateContainerState(
containerInfo.containerID(), HddsProtos.LifeCycleEvent.DELETE);
return true;
+ } else if (containerInfo.getState() == HddsProtos.LifeCycleState.CLOSED
+ && containerInfo.getNumberOfKeys() == 0 && replicas.isEmpty()) {
+ // If the container is empty and has no replicas, it is possible it was
+ // a container which stuck in the closing state which never got any
+ // replicas created on the datanodes. In this case, we don't have enough
+ // information to delete the container, so we just log it as EMPTY,
+ // leaving it as CLOSED and return true, otherwise, it will end up marked
+ // as missing in the replication check handlers.
+ request.getReport()
+ .incrementAndSample(ReplicationManagerReport.HealthState.EMPTY,
+ containerInfo.containerID());
+ LOG.debug("Container {} appears empty and is closed, but cannot be " +
+ "deleted because it has no replicas. Marking as EMPTY.",
+ containerInfo);
+ return true;
}
return false;
diff --git
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/health/TestEmptyContainerHandler.java
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/health/TestEmptyContainerHandler.java
index 9585a1a230..760ec9b7d4 100644
---
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/health/TestEmptyContainerHandler.java
+++
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/health/TestEmptyContainerHandler.java
@@ -168,6 +168,28 @@ public class TestEmptyContainerHandler {
assertAndVerify(request, false, 0, 0);
}
+ /**
+ * This test exists to verify that the definition of an empty container is
+ * 0 key count. Number of used bytes are not considered.
+ */
+ @Test
+ public void testEmptyContainerWithNoReplicas()
+ throws IOException {
+ long keyCount = 0L;
+ long bytesUsed = 0L;
+ ContainerInfo containerInfo = ReplicationTestUtil.createContainerInfo(
+ ratisReplicationConfig, 1, CLOSED, keyCount, bytesUsed);
+
+ ContainerCheckRequest request = new ContainerCheckRequest.Builder()
+ .setPendingOps(Collections.emptyList())
+ .setReport(new ReplicationManagerReport())
+ .setContainerInfo(containerInfo)
+ .setContainerReplicas(Collections.emptySet())
+ .build();
+
+ assertAndVerify(request, true, 0, 1);
+ }
+
/**
* Handler should return false when there is a non-empty replica.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]