peterxcli commented on code in PR #9332:
URL: https://github.com/apache/ozone/pull/9332#discussion_r2986973103
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCommitRequest.java:
##########
@@ -616,14 +616,23 @@ protected void validateAtomicRewrite(OmKeyInfo existing,
OmKeyInfo toCommit, Map
if (toCommit.getExpectedDataGeneration() != null) {
// These values are not passed in the request keyArgs, so add them into
the auditMap if they are present
// in the open key entry.
- auditMap.put(OzoneConsts.REWRITE_GENERATION,
String.valueOf(toCommit.getExpectedDataGeneration()));
- if (existing == null) {
- throw new OMException("Atomic rewrite is not allowed for a new key",
KEY_NOT_FOUND);
- }
- if
(!toCommit.getExpectedDataGeneration().equals(existing.getUpdateID())) {
- throw new OMException("Cannot commit as current generation (" +
existing.getUpdateID() +
- ") does not match the expected generation to rewrite (" +
toCommit.getExpectedDataGeneration() + ")",
- KEY_NOT_FOUND);
+ Long expectedGen = toCommit.getExpectedDataGeneration();
Review Comment:
The original purpose of this field was to support atomic key rewrite/create
using optimistic concurrency. The client sends the generation it observed for
the existing key, and OM only allows the write to proceed if the key still has
that same generation at open and commit time. In practice, this generation is
currently the key’s updateID, so the field is used for fencing against
concurrent modification, rather than as a generic resource epoch.
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneConsts.java:
##########
@@ -315,6 +315,7 @@ public final class OzoneConsts {
public static final String TENANT = "tenant";
public static final String USER_PREFIX = "userPrefix";
public static final String REWRITE_GENERATION = "rewriteGeneration";
+ public static final long EXPECTED_GEN_CREATE_IF_NOT_EXISTS = -1L;
Review Comment:
sure.
--
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]