You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update S3 conditional requests documentation to reflect error code changes and ETag validation logic
- Change error code from `KEY_ALREADY_EXISTS` to `KEY_GENERATION_MISMATCH` for concurrent key creation failures.
- Modify ETag validation logic to allow operations to proceed when no ETag metadata is present, ensuring compatibility with mixed access patterns.
- Update error mapping to include `ETAG_MISMATCH` for ETag comparison failures.
- Add note regarding the upcoming addition of atomic create-if-not-exists capability linked to HDDS-13963.
Copy file name to clipboardExpand all lines: hadoop-hdds/docs/content/design/s3-conditional-requests.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,13 +119,15 @@ public static final long EXPECTED_DATA_GENERATION_CREATE_IF_NOT_EXISTS = -1L;
119
119
##### OM Commit Phase (Atomicity)
120
120
121
121
1. During the commit phase (or strict atomic create), the OM validates that the key still does not exist.
122
-
2. If a concurrent client created the key between the Create and Commit phases, the transaction fails with `KEY_ALREADY_EXISTS`.
122
+
2. If a concurrent client created the key between the Create and Commit phases, the transaction fails with `KET_GENERATION_MISMATCH`.
123
123
124
124
##### Race Condition Handling
125
125
126
126
Using `OzoneConsts.EXPECTED_DATA_GENERATION_CREATE_IF_NOT_EXISTS = -1` ensures atomicity. If a concurrent write (Client B) commits between Client A's Create and Commit,
127
127
Client A's commit fails the `CREATE IF NOT EXISTS` validation check, preserving strict create-if-not-exists semantics.
128
128
129
+
> **Note**: This ability will be added along with [HDDS-13963](https://issues.apache.org/jira/browse/HDDS-13963) (Atomic Create-If-Not-Exists).
130
+
129
131
#### If-Match Implementation
130
132
131
133
To optimize performance and reduce latency, we avoid a pre-flight check (GetS3KeyDetails) and instead validate the ETag during the OM Write operation.
@@ -147,8 +149,8 @@ Validation is performed within the `validateAndUpdateCache` method to ensure ato
147
149
3.**Validation**:
148
150
149
151
-**Key Not Found**: If the key does not exist, throw `KEY_NOT_FOUND` (maps to S3 412).
150
-
-**No ETag Metadata**: If the existing key (e.g., uploaded via OFS) does not have an ETag property, validation fails. We do **not** calculate ETag on the spot to avoid performance overhead on the applier thread. Throws `PRECONDITION_FAILED`.
151
-
-**ETag Mismatch**: Compare `existingKey.ETag` with `expectedETag`. If they do not match, throw `PRECONDITION_FAILED` (maps to S3 412).
152
+
-**No ETag Metadata**: If the existing key (e.g., uploaded via OFS) does not have an ETag property, skip ETag validation and allow the operation to proceed. This ensures compatibility with mixed access patterns (OFS and S3A) where S3 Conditional Writes are primarily intended for pure S3 use cases. We do **not** calculate ETag on the spot to avoid performance overhead on the applier thread.
153
+
-**ETag Mismatch**: Compare `existingKey.ETag` with `expectedETag`. If they do not match, throw `ETAG_MISMATCH` (maps to S3 412).
152
154
153
155
4.**Execution**: If validation passes, proceed with the operation (adding to OpenKeyTable).
154
156
@@ -157,10 +159,9 @@ Validation is performed within the `validateAndUpdateCache` method to ensure ato
0 commit comments