Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 12 commits into from
Oct 27, 2023

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Oct 24, 2023

Which issue does this PR close?

Closes #4879
Relates to #4754

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?

@github-actions github-actions bot added the object-store Object Store Interface label Oct 24, 2023
Comment on lines +860 to +871
/// Stores will use differing combinations of `e_tag` and `version` to provide conditional
/// updates, and it is therefore recommended applications preserve both
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

@@ -1406,14 +1472,66 @@ mod tests {
// Can retrieve previous version
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

@@ -444,24 +514,3 @@ impl ListClient for GoogleCloudStorageClient {
Ok((response.try_into()?, token))
}
}

#[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)


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

@@ -147,33 +155,6 @@ impl From<Error> for crate::Error {
}
}

#[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 merged commit e3cce56 into apache:master Oct 27, 2023
13 checks passed
@tustvold tustvold mentioned this pull request Oct 30, 2023
@alamb alamb mentioned this pull request Oct 31, 2023
2 tasks
@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
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 object-store Object Store Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conditional Put Support
2 participants