ptlrs commented on code in PR #12139:
URL: https://github.com/apache/ozone/pull/12139#discussion_r4699021953
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java:
##########
@@ -226,14 +259,30 @@ private boolean addContainer(Container<?> container,
boolean overwrite) throws
}
}
- private void updateContainerIdTable(long containerId, ContainerData
containerData) throws StorageContainerException {
+ /**
+ * Records the replica that is being added in the witnessed container DB.
The entry is written when:
+ * <ul>
+ * <li>there is none: this is the first replica of the container on this
datanode;</li>
+ * <li>it is DELETED: this datanode deleted its replica, and now loads one
from disk at startup or gets one through
+ * repair. An ordinary create does not get here for a DELETED entry,
KeyValueHandler refuses it;</li>
+ * <li>it has no replica index: it was written in the older table
format;</li>
+ * <li>{@code replaceReplicaIndex} is set and the replica has another
index than the entry: a repair replaces the
+ * replica that this datanode held.</li>
+ * </ul>
+ * In all other cases the entry is kept as it is.
+ */
+ private void updateContainerIdTable(long containerId, ContainerData
containerData, boolean replaceReplicaIndex)
+ throws StorageContainerException {
if (null != containerMetadataStore) {
try {
ContainerID containerIdObj = ContainerID.valueOf(containerId);
Table<ContainerID, ContainerCreateInfo> containerCreateInfoTable =
containerMetadataStore.getContainerCreateInfoTable();
ContainerCreateInfo containerCreateInfo =
containerCreateInfoTable.get(containerIdObj);
- if (containerCreateInfo == null ||
containerCreateInfo.getReplicaIndex() == INVALID_REPLICA_INDEX) {
+ if (containerCreateInfo == null
+ || containerCreateInfo.getState() == State.DELETED
Review Comment:
@sumitagrawl Are you referring to the check by calling
`ensureContainerNotWitnessed` in `KeyValueHandler.handleCreateContainer` ?
If so that is one path to the `updateContainerIdTable`, however, there are
other paths as well such as adding a container at startup time, importing or
recovering. Those will still need these checks and can't directly perform a put
call to the witness db.
--
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]