feat(services/cos): support copy_with_if_not_exists via x-cos-forbid-…#7526
Merged
Conversation
…overwrite Currently the COS backend declares write_with_if_not_exists but the COPY path silently drops OpCopy.if_not_exists: the copy() impl annotates the arg as `_args`, and cos_copy_object() does not even take an OpCopy. This is observable when frameworks such as object_store use the default rename_if_not_exists implementation (copy_if_not_exists + delete) for commit-style atomicity (Lance, Iceberg, Delta, etc.). Without the x-cos-forbid-overwrite header, concurrent committers all win the COPY and silently overwrite each others manifests. Changes: * backend.rs: declare copy_with_if_not_exists capability (gated on enable_versioning, mirroring write_with_if_not_exists). * backend.rs: stop dropping OpCopy and forward it to the core. * core.rs: cos_copy_object now accepts &OpCopy and emits x-cos-forbid-overwrite: true when args.if_not_exists() is set. Tested: * cargo check / cargo test --lib -p opendal-service-cos pass. * End-to-end verified against ap-guangzhou COS using the patched build: single-writer T1/T2 scenarios behave correctly (200 / 409 FileAlreadyExists). Highly-concurrent races on the same fresh key still show non-atomic behavior on the server side, but that is a separate server-level issue and out of scope for this PR. Refs: https://www.tencentcloud.com/document/product/436/7749 Signed-off-by: arrowbowang <arrowbowang@tencent.com>
7a5416e to
f6a9cc0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…overwrite
Currently the COS backend declares write_with_if_not_exists but the COPY path silently drops OpCopy.if_not_exists: the copy() impl annotates the arg as
_args, and cos_copy_object() does not even take an OpCopy.This is observable when frameworks such as object_store use the default rename_if_not_exists implementation (copy_if_not_exists + delete) for commit-style atomicity (Lance, Iceberg, Delta, etc.). Without the x-cos-forbid-overwrite header, concurrent committers all win the COPY and silently overwrite each others manifests.
Changes:
Tested:
Refs: https://www.tencentcloud.com/document/product/436/7749
Which issue does this PR close?
Closes #.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?
AI Usage Statement