sarvekshayr commented on code in PR #11659:
URL: https://github.com/apache/ozone/pull/11659#discussion_r4335193345
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java:
##########
@@ -511,9 +511,12 @@ ContainerCommandResponseProto handleCreateContainer(
LOG.debug("Container already exists. container Id {}", containerID);
}
} catch (StorageContainerException ex) {
- newContainerData.releaseCommitSpace();
return ContainerUtils.logAndReturnError(LOG, ex, request);
} finally {
+ if (!created) {
+ // Release the space reserved when the volume was chosen, also on
unchecked exceptions.
+ newContainerData.releaseCommitSpace();
+ }
containerIdLock.unlock();
}
Review Comment:
Lock leak risk: `releaseCommitSpace()` now runs before
`containerIdLock.unlock()` in the same finally.
If it ever threw, the unlock would be skipped and later creates of that
container ID would block. It is unlikely to throw, but unlocking first, or a
nested try/finally, removes the risk.
--
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]