Skip to content

Commit

Permalink
chore: upgrade to the latest dynamodb-lock crate
Browse files Browse the repository at this point in the history
The new version of this crate properly sets a lease duration such that the locks
can actually expire
  • Loading branch information
rtyler authored and Jan-Schweizer committed Nov 9, 2023
1 parent e59bb34 commit 90b7741
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/deltalake-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ sqlparser = { version = "0.38", optional = true }
fs_extra = { version = "1.3.0", optional = true }
tempdir = { version = "0", optional = true }

dynamodb_lock = { version = "0", default-features = false, optional = true }
dynamodb_lock = { version = "0.6.0", default-features = false, optional = true }

[dev-dependencies]
dotenvy = "0"
Expand Down
12 changes: 7 additions & 5 deletions crates/deltalake-core/src/storage/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use super::utils::str_is_truthy;
use crate::table::builder::{s3_storage_options, str_option};
use bytes::Bytes;
use dynamodb_lock::{DynamoError, LockClient, LockItem, DEFAULT_MAX_RETRY_ACQUIRE_LOCK_ATTEMPTS};
use dynamodb_lock::{DynamoError, LockClient, LockItem};
use futures::stream::BoxStream;
use object_store::path::Path;
use object_store::{
Expand All @@ -23,6 +23,7 @@ use std::time::Duration;
use tokio::io::AsyncWrite;

const STORE_NAME: &str = "DeltaS3ObjectStore";
const DEFAULT_MAX_RETRY_ACQUIRE_LOCK_ATTEMPTS: u32 = 1_000;

/// Error raised by storage lock client
#[derive(thiserror::Error, Debug)]
Expand Down Expand Up @@ -535,10 +536,11 @@ fn try_create_lock_client(options: &S3StorageOptions) -> Result<Option<S3LockCli
),
false => rusoto_dynamodb::DynamoDbClient::new(options.region.clone()),
};
let lock_client = dynamodb_lock::DynamoDbLockClient::new(
dynamodb_client,
dynamodb_lock::DynamoDbOptions::from_map(options.extra_opts.clone()),
);
let lock_client = dynamodb_lock::DynamoDbLockClient::for_region(options.region.clone())
.with_client(dynamodb_client)
.with_options(dynamodb_lock::DynamoDbOptions::from_map(
options.extra_opts.clone(),
));
Ok(Some(S3LockClient {
lock_client: Box::new(lock_client),
}))
Expand Down

0 comments on commit 90b7741

Please sign in to comment.