Skip to content

Commit e47b268

Browse files
authored
feat(transaction): Add retry logic to transaction (#1484)
1 parent b6a6f6d commit e47b268

File tree

7 files changed

+356
-6
lines changed

7 files changed

+356
-6
lines changed

Cargo.lock

Lines changed: 74 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ async-std = "1.12"
5555
async-trait = "0.1.88"
5656
aws-config = "1.6.1"
5757
aws-sdk-glue = "1.39"
58+
backon = "1.5.1"
5859
base64 = "0.22.1"
5960
bimap = "0.6"
6061
bytes = "1.10"
@@ -82,6 +83,7 @@ itertools = "0.13"
8283
linkedbytes = "0.1.8"
8384
metainfo = "0.7.14"
8485
mimalloc = "0.1.46"
86+
mockall = "0.13.1"
8587
mockito = "1"
8688
motore-macros = "0.4.3"
8789
murmur3 = "0.5.2"

crates/iceberg/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ arrow-string = { workspace = true }
5757
as-any = { workspace = true }
5858
async-std = { workspace = true, optional = true, features = ["attributes"] }
5959
async-trait = { workspace = true }
60+
backon = { workspace = true }
6061
base64 = { workspace = true }
6162
bimap = { workspace = true }
6263
bytes = { workspace = true }
@@ -66,6 +67,7 @@ expect-test = { workspace = true }
6667
fnv = { workspace = true }
6768
futures = { workspace = true }
6869
itertools = { workspace = true }
70+
mockall = { workspace = true }
6971
moka = { version = "0.12.10", features = ["future"] }
7072
murmur3 = { workspace = true }
7173
num-bigint = { workspace = true }

crates/iceberg/src/catalog/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use std::sync::Arc;
2929
use _serde::deserialize_snapshot;
3030
use async_trait::async_trait;
3131
pub use memory::MemoryCatalog;
32+
use mockall::automock;
3233
use serde_derive::{Deserialize, Serialize};
3334
use typed_builder::TypedBuilder;
3435
use uuid::Uuid;
@@ -43,6 +44,7 @@ use crate::{Error, ErrorKind, Result};
4344

4445
/// The catalog API for Iceberg Rust.
4546
#[async_trait]
47+
#[automock]
4648
pub trait Catalog: Debug + Sync + Send {
4749
/// List namespaces inside the catalog.
4850
async fn list_namespaces(&self, parent: Option<&NamespaceIdent>)

crates/iceberg/src/error.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ impl Error {
320320
self.kind
321321
}
322322

323+
/// Return error's retryable status
324+
pub fn retryable(&self) -> bool {
325+
self.retryable
326+
}
327+
323328
/// Return error's message.
324329
#[inline]
325330
pub fn message(&self) -> &str {

crates/iceberg/src/spec/table_metadata.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,26 @@ pub const RESERVED_PROPERTIES: [&str; 9] = [
9898
PROPERTY_DEFAULT_SORT_ORDER,
9999
];
100100

101+
/// Property key for number of commit retries.
102+
pub const PROPERTY_COMMIT_NUM_RETRIES: &str = "commit.retry.num-retries";
103+
/// Default value for number of commit retries.
104+
pub const PROPERTY_COMMIT_NUM_RETRIES_DEFAULT: usize = 4;
105+
106+
/// Property key for minimum wait time (ms) between retries.
107+
pub const PROPERTY_COMMIT_MIN_RETRY_WAIT_MS: &str = "commit.retry.min-wait-ms";
108+
/// Default value for minimum wait time (ms) between retries.
109+
pub const PROPERTY_COMMIT_MIN_RETRY_WAIT_MS_DEFAULT: u64 = 100;
110+
111+
/// Property key for maximum wait time (ms) between retries.
112+
pub const PROPERTY_COMMIT_MAX_RETRY_WAIT_MS: &str = "commit.retry.max-wait-ms";
113+
/// Default value for maximum wait time (ms) between retries.
114+
pub const PROPERTY_COMMIT_MAX_RETRY_WAIT_MS_DEFAULT: u64 = 60 * 1000; // 1 minute
115+
116+
/// Property key for total maximum retry time (ms).
117+
pub const PROPERTY_COMMIT_TOTAL_RETRY_TIME_MS: &str = "commit.retry.total-timeout-ms";
118+
/// Default value for total maximum retry time (ms).
119+
pub const PROPERTY_COMMIT_TOTAL_RETRY_TIME_MS_DEFAULT: u64 = 30 * 60 * 1000; // 30 minutes
120+
101121
/// Reference to [`TableMetadata`].
102122
pub type TableMetadataRef = Arc<TableMetadata>;
103123

0 commit comments

Comments
 (0)