ChenSammi commented on code in PR #8693:
URL: https://github.com/apache/ozone/pull/8693#discussion_r2199837132
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/DiskBalancerService.java:
##########
@@ -507,13 +524,21 @@ public BackgroundTaskResult call() {
.incrementUsedSpace(containerSize);
destVolumeIncreased = true;
- // Update container for containerID
+ // Step 4: New Container state transition, C1-RECOVERING -> C1-CLOSING
+ newContainer.getContainerData().setState(
+ ContainerProtos.ContainerDataProto.State.CLOSED);
+ // The 'update' method persists the state change to the .container
file.
+ newContainer.update(newContainer.getContainerData().getMetadata(),
+ true);
+
+ // Step 5: Update container for containerID and delete old container.
Container oldContainer = ozoneContainer.getContainerSet()
.getContainer(containerId);
oldContainer.writeLock();
try {
ozoneContainer.getContainerSet().updateContainer(newContainer);
- oldContainer.delete();
+ KeyValueContainerUtil.removeContainer(
+ (KeyValueContainerData) oldContainer.getContainerData(), conf);
} finally {
Review Comment:
1. mark old container as deleted state in lock
2. call kvContainer.delete() after removeContainer()
3. if old container is marked as deleted, but removeContainer fails with
exception, generally we should treat it as success, and should not deleted
diskBalancerDestDir which is the new container replica. Please check if this
deleted container will be cleaned up during next DN restart.
--
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]