Skip to content

Comments

Add ObjectStore::put_opts / Conditional Put (#4879) #4984

Merged
tustvold merged 12 commits intoapache:masterfrom
tustvold:conditional-put
Oct 27, 2023
Merged

Add ObjectStore::put_opts / Conditional Put (#4879) #4984
tustvold merged 12 commits intoapache:masterfrom
tustvold:conditional-put

Conversation

@tustvold
Copy link
Contributor

@tustvold tustvold commented Oct 24, 2023

Which issue does this PR close?

Closes apache/arrow-rs-object-store#129
Relates to apache/arrow-rs-object-store#145

Rationale for this change

Allows optimistic concurrency control based transactions against object storage

What changes are included in this PR?

Are there any user-facing changes?

Comment on lines +860 to +871
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is kind of annoying, but is necessary because GCS doesn't support etag-based preconditions on put, only ifGenerationMatch

let get_opts = storage.get_opts(&path, options).await.unwrap();
let old = get_opts.bytes().await.unwrap();
assert_eq!(old, b"foo".as_slice());
assert_eq!(old, b"test".as_slice());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a merge conflict from #4935

Comment on lines +445 to +447
if let Some(version) = &options.version {
request = request.query(&[("generation", version)]);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a merge conflict from #4935

}
}

#[derive(serde::Deserialize, Debug)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are moved to be shared with S3 (as they are the same)

})?;
.context(CompleteMultipartRequestSnafu)?;

let etag = get_etag(result.headers()).context(MetadataSnafu)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a mistake introduced in #4971, this needs to extract the etag from the XML payload

}
}

#[derive(Debug, Deserialize)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are moved to be shared with GCS

async fn put(&self, location: &Path, bytes: Bytes) -> Result<PutResult> {
async fn put_opts(&self, location: &Path, bytes: Bytes, opts: PutOptions) -> Result<PutResult> {
if opts.mode != PutMode::Overwrite {
// TODO: Add support for If header - https://datatracker.ietf.org/doc/html/rfc2518#section-9.4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't actually find an easy to run WebDav implementation that respected this header, I don't have a use-case for this currently so punted on this

@tustvold tustvold marked this pull request as ready for review October 25, 2023 22:37
async fn put(&self, location: &Path, bytes: Bytes) -> Result<PutResult> {
async fn put_opts(&self, location: &Path, bytes: Bytes, opts: PutOptions) -> Result<PutResult> {
if matches!(opts.mode, PutMode::Update(_)) {
return Err(crate::Error::NotImplemented);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intend to add support for this as a follow up PR

@tustvold tustvold mentioned this pull request Oct 26, 2023
@tustvold tustvold added the api-change Changes to the arrow API label Nov 10, 2023
@tustvold tustvold changed the title Conditional Put (#4879) Add ObjectStore::put_opts / Conditional Put (#4879) Nov 10, 2023
alamb pushed a commit to alamb/arrow-rs that referenced this pull request Mar 20, 2025
* Add version to PutResult

* Conditional Put (#4879)

* Don't support HttpStore

* Add R2 Support

* Update Azure StatusCode

* Fixes

* Clippy

* Clippy

* PutRequestBuilder

* Clippy

* Add stress test

* Clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change Changes to the arrow API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conditional Put Support

2 participants