bunchesofdonald opened a new pull request, #8517:
URL: https://github.com/apache/opendal/pull/8517

   # Which issue does this PR close?
   
   Closes #8504.
   
   # Rationale for this change
   
   Since #8199, every conditional GCS write (`if_not_exists`, 
`if_version_match`, `if_version_not_match`) opens a resumable upload session, 
so a small conditional create costs two requests where it used to cost one. On 
one latency-sensitive create path, the second request adds about 35 ms at p50 
and 57 ms at p95.
   
   The resumable session is not needed for the precondition. GCS documents 
`ifGenerationMatch` and `ifGenerationNotMatch` as query parameters of 
`objects.insert` for every upload type, including single-request media and 
multipart uploads: 
https://cloud.google.com/storage/docs/json_api/v1/objects/insert. A body sent 
in one request also has no partially persisted chunk to resume.
   
   # What changes are included in this PR?
   
   `GcsConditionalWriter::close` sends the body as one insert request carrying 
the precondition when no resumable session has been opened and the buffered 
body is at most one resumable chunk (8 MiB). Larger writes, and writes that 
already flushed a chunk, keep the resumable path unchanged.
   
   A retried single-request write that gets 412 returns `ConditionNotMatch`, 
the same as 0.58 and the S3 writer. So a retried conditional create whose first 
attempt committed (with its response lost) reports `ConditionNotMatch`. The 
writer does not try to recognize its own earlier write: matching the stored 
object's hash cannot tell our lost success apart from another writer's create 
of identical bytes, and treating that as success would break the 
`if_not_exists` contract that an existing file fails with `ConditionNotMatch`.
   
   A retried `if_version_not_match` write whose first attempt committed gets no 
412; the retry succeeds and writes one extra generation with the same bytes, as 
in 0.58.
   
   Unit tests with the mock transport cover the single-request create (small, 
exactly one chunk, empty, with metadata as a multipart upload), 
`if_version_match` and `if_version_not_match` on the insert, a stale 
`if_version_match` returning `ConditionNotMatch`, a retried insert that gets 
412 returning `ConditionNotMatch`, and the unchanged multi-chunk resumable path.
   
   Behavior tests against a real GCS bucket (object versioning on, user 
credentials): all `if_not_exists` and version-condition tests pass, 23 of 23. 
The remaining full-suite failures match `main` on the same bucket: the presign 
tests (they need a service-account key) and large concurrent writes timing out 
on my upload bandwidth.
   
   # Are there any user-facing changes?
   
   Conditional GCS writes of up to 8 MiB send one request instead of two. No 
public API changes.
   
   # Breaking changes
   
   None.
   
   # AI Usage Statement
   
   - Harness: Claude Code 2.1.322
   - Model: claude-opus-5-5
   - Effort: medium
   - Role: Implemented the writer change and its unit tests under my direction, 
traced how a retried close reaches the writer through `RetryLayer`, and ran the 
behavior suite against a real bucket in my GCP project. I chose to drop the 
hash-based reconciliation after review, for the reason above.
   


-- 
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]

Reply via email to