siddhantsangwan commented on code in PR #8360: URL: https://github.com/apache/ozone/pull/8360#discussion_r2073204172
########## hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerReader.java: ########## @@ -202,50 +202,52 @@ public void verifyAndFixupContainerData(ContainerData containerData) throws IOException { switch (containerData.getContainerType()) { case KeyValueContainer: - if (containerData instanceof KeyValueContainerData) { - KeyValueContainerData kvContainerData = (KeyValueContainerData) - containerData; - containerData.setVolume(hddsVolume); - KeyValueContainerUtil.parseKVContainerData(kvContainerData, config); - KeyValueContainer kvContainer = new KeyValueContainer(kvContainerData, - config); - if (kvContainer.getContainerState() == RECOVERING) { - if (shouldDelete) { - // delete Ratis replicated RECOVERING containers - if (kvContainer.getContainerData().getReplicaIndex() == 0) { - cleanupContainer(hddsVolume, kvContainer); - } else { - kvContainer.markContainerUnhealthy(); - LOG.info("Stale recovering container {} marked UNHEALTHY", - kvContainerData.getContainerID()); - containerSet.addContainer(kvContainer); - } - } - return; - } - if (kvContainer.getContainerState() == DELETED) { - if (shouldDelete) { - cleanupContainer(hddsVolume, kvContainer); - } - return; - } - try { - containerSet.addContainer(kvContainer); - } catch (StorageContainerException e) { - if (e.getResult() != ContainerProtos.Result.CONTAINER_EXISTS) { - throw e; - } - if (shouldDelete) { - resolveDuplicate((KeyValueContainer) containerSet.getContainer( - kvContainer.getContainerData().getContainerID()), kvContainer); - } - } - } else { + if (!(containerData instanceof KeyValueContainerData)) { throw new StorageContainerException("Container File is corrupted. " + "ContainerType is KeyValueContainer but cast to " + "KeyValueContainerData failed. ", ContainerProtos.Result.CONTAINER_METADATA_ERROR); } + + KeyValueContainerData kvContainerData = (KeyValueContainerData) + containerData; + containerData.setVolume(hddsVolume); + KeyValueContainerUtil.parseKVContainerData(kvContainerData, config); + KeyValueContainer kvContainer = new KeyValueContainer(kvContainerData, + config); + if (kvContainer.getContainerState() == RECOVERING) { + if (shouldDelete) { + // delete Ratis replicated RECOVERING containers + if (kvContainer.getContainerData().getReplicaIndex() == 0) { + cleanupContainer(hddsVolume, kvContainer); + } else { + kvContainer.markContainerUnhealthy(); + LOG.info("Stale recovering container {} marked UNHEALTHY", + kvContainerData.getContainerID()); + containerSet.addContainer(kvContainer); + } + } + return; + } else if (kvContainer.getContainerState() == DELETED) { + if (shouldDelete) { + cleanupContainer(hddsVolume, kvContainer); + } + return; + } + + try { + containerData.commitSpace(); Review Comment: What's the logic behind writing to `RECOVERING` containers? AFAIK they shouldn't be written to. I think the current code in the PR is fine since the `commitSpace()` method already checks whether the container's state is `OPEN`. Maybe we can add a comment before line 239 that says this. -- 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: issues-unsubscr...@ozone.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org