Skip to content

HDDS-15167. Broaden commit conflict detection for conditional writes#10183

Open
peterxcli wants to merge 6 commits intoapache:masterfrom
peterxcli:feat/concurrent-conflict-detection-for-conditional-mpu-complete
Open

HDDS-15167. Broaden commit conflict detection for conditional writes#10183
peterxcli wants to merge 6 commits intoapache:masterfrom
peterxcli:feat/concurrent-conflict-detection-for-conditional-mpu-complete

Conversation

@peterxcli
Copy link
Copy Markdown
Member

@peterxcli peterxcli commented May 4, 2026

What changes were proposed in this pull request?

Relates to: #10164

This patch broadens the conditional write conflict handling from conditional CompleteMultipartUpload to the shared conditional write flow used by conditional PutObject and the existing atomic key rewrite path.

The main change is to split conditional write handling into two phases:

  • admission-time validation returns precondition-style failures (412 PreconditionFailed) when the caller's condition is already false, such as an existing destination for If-None-Match: *, a missing destination for If-Match, a missing ETag, or an ETag mismatch;
  • commit-time revalidation returns 409 ConditionalRequestConflict when an admitted conditional write loses a concurrent commit race before it becomes visible.

Concretely, this patch:

  • moves atomic rewrite validation into shared admission and commit helpers;
  • updates conditional CommitKey handling, including FSO, so stale admitted generations fail with ATOMIC_WRITE_CONFLICT at commit time;
  • resolves conditional MPU complete requests at admission and revalidates the resolved generation during the serialized complete transaction;
  • maps admitted conditional write conflicts to S3 ConditionalRequestConflict while keeping admission failures as PreconditionFailed;
  • updates the S3 conditional request design doc and adds unit/integration coverage for conditional PUT/rewrite and MPU complete conflict cases.

After a 409 ConditionalRequestConflict, clients should fetch the latest object ETag, start a new write or multipart upload as needed, and retry using a condition based on the latest object view.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15167

How was this patch tested?

UT/IT

https://github.com/peterxcli/ozone/actions/runs/25326550113

Signed-off-by: peterxcli <peterxcli@gmail.com>
@peterxcli peterxcli changed the title HDDS-15167 Concurrent Conflict Detection for Conditional MPU Complete HDDS-15167. Concurrent Conflict Detection for Conditional MPU Complete May 4, 2026
@peterxcli peterxcli added om s3 S3 Gateway AI-gen labels May 4, 2026
@peterxcli peterxcli marked this pull request as ready for review May 4, 2026 16:23
@peterxcli
Copy link
Copy Markdown
Member Author

cc @YutaLin

…ction

Signed-off-by: peterxcli <peterxcli@gmail.com>
Copy link
Copy Markdown
Contributor

@chungen0126 chungen0126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @peterxcli for the patch. Left some comments.

Comment on lines +1354 to +1375
protected void validateAtomicRewriteAtCommit(OmKeyInfo existing,
OmKeyInfo toCommit, Map<String, String> auditMap) throws OMException {
validateAtomicRewriteAtCommit(existing,
toCommit.getExpectedDataGeneration(), auditMap);
}

/**
* Validates an already admitted condition at serialized commit time.
*
* This form is for callers that must check the admitted generation before
* building the final key info to commit.
*/
protected void validateAtomicRewriteAtCommit(OmKeyInfo existing,
Long expectedGen, Map<String, String> auditMap) throws OMException {
if (expectedGen == null) {
return;
}
validateExpectedDataGeneration(existing, expectedGen, auditMap,
AtomicRewritePhase.COMMIT);
}

private void validateExpectedDataGeneration(OmKeyInfo existing,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like splitting the validation logic into these three methods might be a bit of over-engineering. Could we simplify it?

Comment on lines +1323 to +1328
KeyArgs resolvedKeyArgs = validateAndRewriteIfMatchAsExpectedGeneration(
keyArgs, dbKeyInfo);
if (resolvedKeyArgs.hasExpectedDataGeneration()) {
addRewriteGenerationToAuditMap(
resolvedKeyArgs.getExpectedDataGeneration(), auditMap);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few quick suggestions to streamline the logic:

  1. Could we make validateAndRewriteIfMatchAsExpectedGeneration private if it's not used elsewhere?
  2. The keyArgs.hasExpectedDataGeneration() check inside validateAndRewriteIfMatchAsExpectedGeneration is redundant, as the caller already filters it out.
  3. Consider moving addRewriteGenerationToAuditMap into validateAndRewriteIfMatchAsExpectedGeneration. This will make the logic much cleaner.

@peterxcli
Copy link
Copy Markdown
Member Author

peterxcli commented May 5, 2026

And I think we should apply this concept to conditional put, too.

  • CreateKey.preExecute -> admission preparation
  • CreateKey.validateAndUpdateCache -> serialized admission
  • CommitKey.preExecute -> commit-request admission preparation / best-effort precondition check
  • CommitKey.validateAndUpdateCache -> serialized commit revalidation

cc @ivandika3

@peterxcli peterxcli self-assigned this May 5, 2026
peterxcli added 2 commits May 6, 2026 17:29
…, only commit validate as commit

Signed-off-by: peterxcli <peterxcli@gmail.com>
Signed-off-by: peterxcli <peterxcli@gmail.com>
@peterxcli peterxcli changed the title HDDS-15167. Concurrent Conflict Detection for Conditional MPU Complete HDDS-15167. Detect commit conflicts for conditional writes May 6, 2026
@peterxcli peterxcli changed the title HDDS-15167. Detect commit conflicts for conditional writes HDDS-15167. Broaden commit conflict detection for conditional writes May 6, 2026
peterxcli added 2 commits May 7, 2026 01:31
…ditional-mpu-complete

Signed-off-by: peterxcli <peterxcli@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants