errose28 commented on PR #7065:
URL: https://github.com/apache/ozone/pull/7065#issuecomment-2307780382
I put some more thought into where we are generating the tree. Currently the
PR does this before the state change, but this may have some problems:
- For a container moving from open to unhealthy, writes may still be coming
in while we generate the tree since the container is not in a closing state
before this. The tree will be generated fine but it might miss the last chunk
or two.
- For unhealthy containers we will still try to generate the tree even if
the volume has failed. Tree generation should still fail cleanly, but its not
ideal.
I think it would be best to generate the tree after the container changes
state but before the ICR is sent. If a restart happens between those two
actions the tree may not be generated when the container is closed. This is ok
for corner cases because datanodes will report the checksum as 0 and tree
generation will be triggered with reconciliation. However most reconciliation
commands will still not have to wait for tree generation.
Ideally we would not generate the tree under the write lock for the
container file either. We can move the ICR trigger and container log out of
there as well. I think it would look something like this:
```java
@Override
public void quasiCloseContainer(Container container, String reason)
throws IOException {
container.writeLock();
try {
final State state = container.getContainerState();
// Quasi close call is idempotent.
if (state == State.QUASI_CLOSED) {
return;
}
// The container has to be in CLOSING state.
if (state != State.CLOSING) {
ContainerProtos.Result error =
state == State.INVALID ? INVALID_CONTAINER_STATE :
CONTAINER_INTERNAL_ERROR;
throw new StorageContainerException(
"Cannot quasi close container #" + container.getContainerData()
.getContainerID() + " while in " + state + " state.", error);
}
container.quasiClose();
} finally {
container.writeUnlock();
}
createContainerMerkleTree(container);
ContainerLogger.logQuasiClosed(container.getContainerData(), reason);
sendICR(container);
}
```
--
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]