yandrey321 commented on code in PR #12139:
URL: https://github.com/apache/ozone/pull/12139#discussion_r4688671932


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java:
##########
@@ -666,6 +734,10 @@ public <T> void buildMissingContainerSetAndValidate(Map<T, 
Long> container2BCSID
     container2BCSIDMap.entrySet().parallelStream().forEach((mapEntry) -> {
       final long id = getId.applyAsLong(mapEntry.getKey());
       if (!containerMap.containsKey(id)) {
+        if (isDeletedInContainerTable(id)) {

Review Comment:
     DELETED entries are never purged. At startup the whole key set goes into a 
`HashMap<ContainerID, Long>`, then `buildMissingContainerSetAndValidate` does a 
RocksDB point `get` per key missing from the map (every deleted container) on 
the common ForkJoin pool via `parallelStream`. With heavy delete churn 
(balancer, over-replication, small containers) that is about 64–80 MB of 
transient heap and N random gets per million deleted IDs, on every start.
   
   It would be better to iterate key+value in OzoneContainer and drop DELETED 
entries before building the map, with no second read.
   



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java:
##########
@@ -148,6 +148,31 @@ public void ensureContainerNotMissing(long containerId, 
State state) throws Stor
     }
   }
 
+  /**
+   * Fails if the witnessed container DB has an entry for the container: it 
was already created on this datanode,
+   * possibly deleted since, and must not be created again by an ordinary 
create.
+   * @param containerId ID of the container to be created
+   * @throws StorageContainerException with {@code CLOSED_CONTAINER_IO} if 
there is an entry, or with
+   *                                   {@code IO_EXCEPTION} if the entry 
cannot be read
+   */
+  public void ensureContainerNotWitnessed(long containerId) throws 
StorageContainerException {

Review Comment:
   The entry state is the state at creation (OPEN/RECOVERING), never updated on 
close. "witnessed state OPEN" in the error is misleading. Rejecting every state 
is fine in practice: a non-DELETED entry with no replica is already missing 
after startup. The javadoc at 262-272 ("ordinary create does not get here for a 
DELETED entry") should say the check rejects all states.



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java:
##########
@@ -208,7 +233,15 @@ private boolean addContainer(Container<?> container, 
boolean overwrite) throws
         LOG.debug("Container with container Id {} is added to containerMap",
             containerId);
       }
-      updateContainerIdTable(containerId, container.getContainerData());
+      try {
+        updateContainerIdTable(containerId, container.getContainerData(), 
overwrite);
+      } catch (StorageContainerException e) {

Review Comment:
   On a failed entry write, `addContainerByOverwriteMissingContainer` removes 
the container from the map. Plain `addContainer` leaves it registered (the PR's 
own test `testAddStaysRegisteredWhenEntryWriteFails`). For ContainerImporter 
(ContainerImporter.java:131-132), `incrementUsedSpace` has already run and the 
data dir is in place. After the rollback, used space leaks and the dir is 
orphaned until restart, when ContainerReader loads it anyway and rewrites the 
entry. Between `putIfAbsent` and `remove` the replica is visible to other 
threads.
   
   Drop the rollback to keep the PR minimal, or have the callers undo their 
side effects too.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to