errose28 commented on code in PR #12139:
URL: https://github.com/apache/ozone/pull/12139#discussion_r4685952486
##########
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 {
+ if (containerMetadataStore == null) {
+ return;
+ }
+ final ContainerCreateInfo info;
+ try {
+ info =
containerMetadataStore.getContainerCreateInfoTable().get(ContainerID.valueOf(containerId));
+ } catch (IOException e) {
+ throw new StorageContainerException("Failed to read the witnessed
container DB for container " + containerId,
+ e, ContainerProtos.Result.IO_EXCEPTION);
+ }
+ if (info != null) {
+ throw new StorageContainerException("Container " + containerId + " was
already created on this datanode"
+ + " (witnessed state " + info.getState() + ") and cannot be created
again",
+ ContainerProtos.Result.CLOSED_CONTAINER_IO);
Review Comment:
`CLOSED_CONTAINER_IO` is used to prevent the pipeline from being closed. See
[this
comment](https://github.com/apache/ozone/pull/12139#discussion_r4673947109).
IMO it is close enough to the situations we may encounter:
- If the container is open and still present we will not hit this message
- If the container is lost due to volume failure we don't know its state,
but it should be closed soon if not already.
- If the container was deleted, it must have been closed before that.
--
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]