supratimdeka commented on a change in pull request #1364: HDDS-1843. Undetectable corruption after restart of a datanode. URL: https://github.com/apache/hadoop/pull/1364#discussion_r320287270
########## File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java ########## @@ -240,14 +240,37 @@ public ContainerReportsProto getContainerReport() throws IOException { } /** - * Builds the missing container set by taking a diff total no containers - * actually found and number of containers which actually got created. + * Builds the missing container set by taking a diff between total no + * containers actually found and number of containers which actually + * got created. It also validates the BCSID stored in the snapshot file + * for each container as against what is reported in containerScan. * This will only be called during the initialization of Datanode Service * when it still not a part of any write Pipeline. - * @param createdContainerSet ContainerId set persisted in the Ratis snapshot + * @param container2BCSIDMap Map of containerId to BCSID persisted in the + * Ratis snapshot */ - public void buildMissingContainerSet(Set<Long> createdContainerSet) { - missingContainerSet.addAll(createdContainerSet); - missingContainerSet.removeAll(containerMap.keySet()); + public void buildMissingContainerSetAndValidate( + Map<Long, Long> container2BCSIDMap) throws IOException { + for (Map.Entry<Long, Long> mapEntry : container2BCSIDMap.entrySet()) { + long id = mapEntry.getKey(); + if (!containerMap.containsKey(id)) { + LOG.warn("Adding container {} to missing container set.", id); + missingContainerSet.add(id); + } else { + Container container = containerMap.get(id); + long containerBCSID = container.getBlockCommitSequenceId(); + long snapshotBCSID = mapEntry.getValue(); + if (containerBCSID < snapshotBCSID) { + LOG.warn( + "Marking container {} unhealthy as reported BCSID {} is smaller" Review comment: argument appears to be missing. container not passed as the first argument. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org