Gargi-jais11 commented on PR #10109:
URL: https://github.com/apache/ozone/pull/10109#issuecomment-4349763866
> What is we instead updated the existing object in place under a lock?
Would that solve all these edge cases more simple? It sounds like these
problems all come from the disk balancer moving and replacing the container
object, so if we fix just that, it may be a cleaner solution to this whole
problem?
@sodonnel I believe your suggestion is correct and cleaner. **Updating
fields in-place wipes out the path to Disk1.**
So to resolve this what I can think of is we can save the old path in local
variables before acquiring the write lock and updating existing container
object. The lock only needs to protect the swap of the live in-memory fields;
path cleanup uses the saved local.
So according to this the new proposed diskbalancer flow will look something
like this:
```
Phase A: File-level copy (identical to today — no change here)
A1. container.readLock()
A2. copyContainer(Disk1 → tmp/) <--------------------
files copied
A3. atomic Files.move(tmp → Disk2/final) <--------------------
.container YAML on Disk2 is final
Phase B: In-place update (replaces current updateContainer call)
B1. Save: oldMeta = containerData.getMetadataPath()
oldChunks = containerData.getChunksPath()
oldVolume = containerData.getVolume()
oldDbFile = containerData.getDbFile()
B2. container.readUnlock()
B3. container.writeLock() <--------------------
escalate, blocks all concurrent readers/writers
B4. containerData.setVolume(destVolume)
containerData.setMetadataPath(newMetadataPath)
containerData.setChunksPath(newChunksPath)
containerData.setDbFile(newDbFile)
B5. container.writeUnlock()
Phase C: Disk1 cleanup (uses saved locals — no reference to Disk1 survives
in the container object)
C1. update volume space: destVolume.incrementUsed; oldVolume.decrementUsed
C2. markContainerForDelete on Disk1 using oldMeta/oldChunks/oldDbFile paths
C3. delete Disk1 files
```
cc: @ChenSammi
Please go through these steps and comment if any issue would be there as
part of diskbalancer if we update existing object.
--
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]