Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c3f8bc8
fix(mongodb): retry an unconditional PutItem that loses the create race
LeeroyHannigan Oct 22, 2026
db082ab
fix(mongodb): retry an unconditional PutItem that conflicts on a GSI …
LeeroyHannigan Oct 23, 2026
544103c
fix(mongodb): give the commit retry and the create race their own bud…
LeeroyHannigan Oct 23, 2026
7692c47
Merge remote-tracking branch 'origin/main' into fix/mongodb-putitem-g…
LeeroyHannigan Oct 23, 2026
b013ec6
fix(mongodb): set the restore fields in the scratch test engine
LeeroyHannigan Oct 23, 2026
b0c45f4
fix(mongodb): stop retrying a contended write after 10 s
LeeroyHannigan Oct 24, 2026
a15e401
fix(mongodb): make the contention deadline a value a test can set
LeeroyHannigan Oct 24, 2026
f7d9114
test(contention): hold the contended puts to the contract the backend…
LeeroyHannigan Oct 24, 2026
2b799c5
Merge branch 'main' into fix/mongodb-upsert-duplicate-key
LeeroyHannigan Nov 3, 2026
ac1f3b4
Merge branch 'main' into fix/mongodb-putitem-gsi-conflict
LeeroyHannigan Nov 3, 2026
09d6bf9
test(mongodb): run the create-race tests as live data engine tests
LeeroyHannigan Nov 3, 2026
0d3f76d
docs(mongodb): say a create race in a transaction is a write conflict
LeeroyHannigan Nov 3, 2026
08c4995
test(put-item): give each create race writer its own client
LeeroyHannigan Nov 3, 2026
3727a0e
Merge branch 'fix/mongodb-upsert-duplicate-key' into fix/mongodb-puti…
LeeroyHannigan Nov 3, 2026
9212328
test(mongodb): build every test engine through one constructor
LeeroyHannigan Nov 3, 2026
6c36c14
fix(mongodb): give the requests of one BatchWriteItem one contention …
LeeroyHannigan Nov 3, 2026
d9e3299
test(put-item): require most contended puts to commit and pin the att…
LeeroyHannigan Nov 3, 2026
efe8bc9
docs(mongodb): bring the contention comments and docs up to date
LeeroyHannigan Nov 3, 2026
b7c9258
docs(mongodb): describe the duplicate-key arm the same way everywhere
LeeroyHannigan Nov 3, 2026
63df25e
Merge branch 'fix/mongodb-upsert-duplicate-key' into fix/mongodb-puti…
LeeroyHannigan Nov 3, 2026
ed4fb62
docs(mongodb): state the measured CPU cost of a hot key
LeeroyHannigan Nov 3, 2026
31f7c6e
Merge branch 'main' into fix/mongodb-putitem-gsi-conflict
LeeroyHannigan Nov 3, 2026
88420dd
fix(mongodb): count UpdateItem's native upsert create race against CR…
LeeroyHannigan Nov 3, 2026
f367f0a
Merge branch 'main' into fix/mongodb-upsert-duplicate-key
LeeroyHannigan Nov 3, 2026
59c467b
test(put-item): skip the GSI hot-key test on Cassandra (#802)
LeeroyHannigan Nov 3, 2026
c8de131
Merge branch 'main' into fix/mongodb-upsert-duplicate-key
LeeroyHannigan Nov 3, 2026
c69a856
Merge origin/main into fix/mongodb-upsert-duplicate-key
LeeroyHannigan Nov 14, 2026
8507297
fix(mongodb): carry the driver error in the transaction create race arm
LeeroyHannigan Nov 14, 2026
4fcaf7e
refactor(mongodb): let the restore duplicate-key check use is_duplica…
LeeroyHannigan Nov 14, 2026
70b1a63
Merge fix/mongodb-upsert-duplicate-key into fix/mongodb-putitem-gsi-c…
LeeroyHannigan Nov 14, 2026
a48ef73
fix(mongodb): give the contention loops a 1,000-attempt budget of the…
LeeroyHannigan Nov 14, 2026
6c5b12c
refactor(mongodb): give up on the contention deadline beside retry_bu…
LeeroyHannigan Nov 14, 2026
b53bace
test(mongodb): build the stream lifecycle test engine through for_test
LeeroyHannigan Nov 14, 2026
0f9256b
test(batch): drop the MongoDB test of a batch with no request applied
LeeroyHannigan Nov 14, 2026
ef7548c
docs(mongodb): state the batch and give-up answers that main brings
LeeroyHannigan Nov 14, 2026
1a7eb75
docs(mongodb): say which error the 50-attempt loops delay
LeeroyHannigan Nov 14, 2026
6ddff4c
fix(mongodb): log the attempts a TransactWriteItems ran when it gives up
LeeroyHannigan Nov 14, 2026
c1524f0
docs(mongodb): give the design doc the contention budget and deadline
LeeroyHannigan Nov 14, 2026
6823bee
docs: state each contended MongoDB write fact in one row
LeeroyHannigan Nov 14, 2026
ff3626e
docs: give the contention bounds where main's text says 50 attempts
LeeroyHannigan Nov 14, 2026
95dc078
docs(batch): give each side's batch text the other side's rule
LeeroyHannigan Nov 14, 2026
390e6be
refactor(mongodb): cut two comments that repeat text stated elsewhere
LeeroyHannigan Nov 14, 2026
67fc2e7
docs: state the BatchWriteItem answers in the batch row only
LeeroyHannigan Nov 14, 2026
1eadcb9
fix(partiql): give the statements of one BatchExecuteStatement one co…
LeeroyHannigan Nov 20, 2026
84dcff9
Merge remote-tracking branch 'origin/main' into fix/mongodb-putitem-g…
LeeroyHannigan Nov 24, 2026
d714ee0
test(put-item): require nine in ten contended puts to commit
LeeroyHannigan Nov 24, 2026
89c62f0
test(mongodb): make the attempt budget the one bound of the hot-key test
LeeroyHannigan Nov 24, 2026
d138f8e
docs(mongodb): keep each contention measurement in one place
LeeroyHannigan Nov 24, 2026
076975f
style(mongodb): clear clippy's pedantic warnings on the lines this br…
LeeroyHannigan Nov 24, 2026
c85e24e
test(put-item): give the hot-key floor's comment the measured shed co…
LeeroyHannigan Nov 24, 2026
10363a1
Merge remote-tracking branch 'origin/main' into fix/mongodb-putitem-g…
LeeroyHannigan Nov 25, 2026
eaa83a5
fix(partiql): answer a contended batch statement with TransactionConf…
LeeroyHannigan Nov 25, 2026
6350dca
test(put-item): say what the hot-key floor bounds
LeeroyHannigan Nov 25, 2026
3e85e2f
fix(engine): read the batch request clock through web_time
LeeroyHannigan Nov 25, 2026
a24d811
Merge origin/main into fix/mongodb-putitem-gsi-conflict
LeeroyHannigan Dec 3, 2026
f5c22b6
fix(partiql): name the table on a contended batch statement's entry
LeeroyHannigan Dec 3, 2026
86d02ba
docs(upgrade): add a v1.2.0 entry for the MongoDB contention bounds
LeeroyHannigan Dec 3, 2026
d341468
Merge origin/main into fix/mongodb-putitem-gsi-conflict
LeeroyHannigan Dec 3, 2026
fe4d965
Merge origin/main into fix/mongodb-putitem-gsi-conflict
LeeroyHannigan Dec 4, 2026
b5af797
Merge origin/main into fix/mongodb-putitem-gsi-conflict
LeeroyHannigan Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions crates/engine/src/batch_write_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub async fn handle_batch_write_item(
body: Value,
ctx: &OperationContext,
) -> Result<DispatchResult, DynamoDbError> {
let started = web_time::Instant::now();
let input: BatchWriteItemInput =
serde_json::from_value(body).map_err(crate::deserialize_error)?;

Expand Down Expand Up @@ -106,13 +107,17 @@ pub async fn handle_batch_write_item(
lookups.push(ctx.table_key_info_uncached(table_name).await);
}

write_batch(
&*ctx.storage,
&ctx.limits,
&ctx.region,
&input,
&tables,
lookups,
// One contention deadline for the batch's writes: see `request_clock`.
extenddb_storage::request_clock::scope(
started,
write_batch(
&*ctx.storage,
&ctx.limits,
&ctx.region,
&input,
&tables,
lookups,
),
)
.await
}
Expand Down Expand Up @@ -181,7 +186,10 @@ async fn write_batch(
// retry with backoff, so a client's UnprocessedItems loop cannot spin on a
// batch that makes no progress. Each failed request spends its own retry
// budget first, so a batch of 25 contended requests can spend 25 budgets
// before it answers.
// before it answers. On MongoDB the requests also share one contention
// deadline, measured from the start of the batch (the request clock scope
// `handle_batch_write_item` opens), and no transaction retry starts once
// it has passed.
//
// The request faults the same page lists reject the whole batch before
// anything is written. `check_batch` finds a missing table, a key that
Expand Down
18 changes: 18 additions & 0 deletions crates/engine/src/partiql/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,24 @@ impl StatementError {
include_table_name: true,
item: None,
},
// A write the backend could not apply now. On MongoDB that is a
// write that reached its contention deadline or spent its attempt
// budget, which a single-item request answers 503. The engine
// answers a transient storage fault, a lost connection among them,
// with the same 503, so it takes this entry too. An item that a
// transaction holds arrives as `TransactionConflictException`. The
// service answers a statement whose item concurrent transactions
// hold with this code and message, and the statement's `TableName`
// (184 of 184 entries in us-east-1, measured by 2026-11-26).
DynamoDbError::ServiceUnavailable(_)
| DynamoDbError::TransactionConflictException(_) => Self {
code: "TransactionConflict",
message: CancellationReason::transaction_conflict()
.message
.unwrap_or_default(),
include_table_name: true,
item: None,
},
// Everything else a well-formed statement can raise per-statement is
// a validation error (partial key, bad value, key-type mismatch).
other => Self {
Expand Down
30 changes: 30 additions & 0 deletions crates/engine/src/partiql/common/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,36 @@ fn an_error_of_the_item_operation_names_the_batch_table() {
}
}

/// A write that lost to contention, answered 503 on the single-item API or
/// held by a transaction, is the service's entry for an item that concurrent
/// transactions hold, with the statement's `TableName` (184 of 184 entries in
/// us-east-1, measured by 2026-11-26).
#[test]
fn a_write_that_lost_to_contention_answers_transaction_conflict() {
let conflict = json!({
"Error": {
"Code": "TransactionConflict",
"Message": "Transaction is ongoing for the item"
},
"TableName": "t"
});
for error in [
DynamoDbError::ServiceUnavailable("Service is temporarily unavailable".to_owned()),
DynamoDbError::TransactionConflictException("held".to_owned()),
] {
assert_eq!(
StatementError::from_item_error(&error).into_entry(Some("t")),
conflict,
"{error:?}"
);
assert_eq!(
StatementError::from_error(&error).into_entry(Some("t")),
conflict,
"{error:?}"
);
}
}

#[test]
fn a_conditional_failure_without_an_item_has_none() {
let err = DynamoDbError::ConditionalCheckFailedException(
Expand Down
7 changes: 6 additions & 1 deletion crates/engine/src/partiql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ impl PartiqlExecutor for OperationContext {
}

async fn batch_execute_statement(&self, body: Value) -> Result<DispatchResult, DynamoDbError> {
batch::run(&translation_context(self), &body).await
// One contention deadline for the batch's statements: see `request_clock`.
extenddb_storage::request_clock::scope(
web_time::Instant::now(),
batch::run(&translation_context(self), &body),
)
.await
}

async fn execute_transaction(&self, body: Value) -> Result<DispatchResult, DynamoDbError> {
Expand Down
7 changes: 1 addition & 6 deletions crates/storage-mongodb/src/backup_live_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,8 @@ impl Fixture {
async fn engine_on(catalog: &str, data: &str, liveness: BackupLiveness) -> MongoEngine {
let client = mongodb::Client::with_uri_str(uri()).await.expect("client");
MongoEngine {
client: client.clone(),
catalog_db: client.database(catalog),
data_db: client.database(data),
region: REGION.to_owned(),
gsi_cache: Arc::default(),
tx_read_concern: mongodb::options::ReadConcern::snapshot(),
backup_liveness: liveness,
..MongoEngine::for_test(&client, client.database(catalog), client.database(data))
}
}

Expand Down
Loading
Loading