Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
819b4d9
fix: report a computed index-key type fault as a plain cancellation r…
LeeroyHannigan Oct 31, 2026
5c2dbe2
fix: run the request key checks of every transaction member in one sh…
LeeroyHannigan Oct 31, 2026
45d3ac4
test: pin the 31 October measurement of empty and wrong-typed keys ac…
LeeroyHannigan Oct 31, 2026
74900d4
fix: check an empty index-key literal on the statement and type list_…
LeeroyHannigan Oct 31, 2026
857f9e1
test: pin empty literals, list_append that reads the item, and the do…
LeeroyHannigan Oct 31, 2026
0c391a0
fix: rank transaction index-key faults and the client token as the se…
LeeroyHannigan Nov 4, 2026
73d5b3e
fix: keep a cancelled token for 10 minutes and answer TransactionInPr…
LeeroyHannigan Nov 5, 2026
cb5f48b
fix: expire a committed ClientRequestToken on Cassandra after 10 minutes
LeeroyHannigan Nov 5, 2026
335ef9f
test: let the write transaction lose the PostgreSQL deadlock tests
LeeroyHannigan Nov 5, 2026
ed1ab6d
fix: apply a TransactWriteItems once on PostgreSQL when two sends sha…
LeeroyHannigan Nov 5, 2026
e1c6bba
Merge origin/main into fix/transact-index-key-order
LeeroyHannigan Nov 6, 2026
6651759
Merge fix/transact-index-key-order into fix/851-pg-token-race
LeeroyHannigan Nov 6, 2026
4b6c58b
fix: answer TransactionInProgress if the second token read is still s…
LeeroyHannigan Nov 7, 2026
ba547aa
test: cover two requests with one token and two sends that take an ol…
LeeroyHannigan Nov 7, 2026
e042542
Merge origin/main into fix/transact-index-key-order
LeeroyHannigan Nov 7, 2026
3acef8c
docs: say that the second token read depends on READ COMMITTED
LeeroyHannigan Nov 7, 2026
60d1296
Merge fix/transact-index-key-order into fix/851-pg-token-race
LeeroyHannigan Nov 7, 2026
ff2d713
Merge origin/main into fix/transact-index-key-order
LeeroyHannigan Nov 9, 2026
c6e3ca1
Merge fix/transact-index-key-order into fix/851-pg-token-race
LeeroyHannigan Nov 9, 2026
9c937d3
Merge origin/main into fix/transact-index-key-order
LeeroyHannigan Nov 9, 2026
b6e5ca3
Merge fix/transact-index-key-order into fix/851-pg-token-race
LeeroyHannigan Nov 9, 2026
92d76c6
Merge pull request #873 from ExtendDB/fix/851-pg-token-race
hitesh96db Nov 9, 2026
fe98fd0
Merge main into fix/transact-index-key-order
LeeroyHannigan Nov 10, 2026
98ed152
Merge main into fix/transact-index-key-order
LeeroyHannigan Nov 12, 2026
6555187
Merge main into fix/transact-index-key-order
LeeroyHannigan Nov 20, 2026
b5e034c
test(storage-cassandra): move the token tests to transact_write_token…
LeeroyHannigan Nov 20, 2026
b3b6d51
fix(storage-cassandra): write the cancelled token with an LWT
LeeroyHannigan Nov 20, 2026
c25d75e
docs(storage-postgres): shorten the comment on the token check
LeeroyHannigan Nov 20, 2026
96fe994
test: move three test modules that this branch grew to files of their…
LeeroyHannigan Nov 20, 2026
4a01560
fix(storage-cassandra): store the cancelled token when the send's row…
LeeroyHannigan Nov 20, 2026
a6d6e1a
docs(storage-postgres): say why the token check tests the second result
LeeroyHannigan Nov 20, 2026
05769a3
test(storage-cassandra): read the token row through one helper
LeeroyHannigan Nov 20, 2026
6f128ab
test(storage-cassandra): check the TTL of the token row after a cance…
LeeroyHannigan Nov 20, 2026
23f3f15
fix(storage-cassandra): say only what the cancellation's LWTs guarantee
LeeroyHannigan Nov 20, 2026
a67e1eb
Merge main into fix/transact-index-key-order
LeeroyHannigan Nov 24, 2026
08f2a93
Merge main into fix/transact-index-key-order
LeeroyHannigan Nov 24, 2026
203cb12
refactor(core): build the update-expression empty-key message once
LeeroyHannigan Nov 24, 2026
943e606
refactor(engine): take the TransactionInProgress message from the sto…
LeeroyHannigan Nov 24, 2026
ea0279d
refactor(storage-mongodb): build each table's index key list once per…
LeeroyHannigan Nov 24, 2026
9293478
docs(storage-postgres): say what the token check does at each isolati…
LeeroyHannigan Nov 24, 2026
76e961e
test(wire): retry a TLS handshake failure in the token race test
LeeroyHannigan Nov 24, 2026
9819376
docs: list the MongoDB and Cassandra token differences in the index k…
LeeroyHannigan Nov 24, 2026
a67a182
test(storage-cassandra): move the concurrent send tests of the token …
LeeroyHannigan Nov 24, 2026
1e36a9b
Merge main into fix/transact-index-key-order
LeeroyHannigan Nov 24, 2026
53f0437
fix(server): send TransactionInProgressException with Message
LeeroyHannigan Nov 24, 2026
57f2e47
docs, test(wire): drop the token differences that #526 fixed
LeeroyHannigan Nov 24, 2026
0958e28
docs: say that Cassandra token rows now expire after 10 minutes
LeeroyHannigan Nov 24, 2026
c414410
Merge main into fix/transact-index-key-order
LeeroyHannigan Nov 24, 2026
62cea0c
Merge origin/main into fix/transact-index-key-order
LeeroyHannigan Nov 24, 2026
676cf8f
Merge origin/main into fix/transact-index-key-order
LeeroyHannigan Dec 3, 2026
469ceba
Merge origin/main into fix/transact-index-key-order
LeeroyHannigan Dec 4, 2026
6d3d448
Merge origin/main into fix/transact-index-key-order
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
14 changes: 7 additions & 7 deletions crates/core/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,16 @@ pub fn error_document(error: &DynamoDbError) -> serde_json::Value {

/// The key that carries the error message. `DynamoDB` sends `Message` on
/// `TransactionCanceledException` and `IdempotentParameterMismatchException`
/// (us-east-1, raw bodies, 2026-10-29, 2026-11-03 and 2026-11-19). It also
/// sends `Message` on `TransactionInProgressException`, which ExtendDB does
/// not raise, and on `AccessDeniedException` and `SerializationException`
/// (2026-11-12 and 2026-11-19), which keep `message` here. The other errors
/// measured carry `message`. REQ-ERR-002 in `docs/design/01-requirements.md`
/// lists them.
/// (us-east-1, raw bodies, 2026-10-29, 2026-11-03 and 2026-11-19), and on
/// `TransactionInProgressException` (2026-11-19). It also sends `Message` on
/// `AccessDeniedException` and `SerializationException` (2026-11-12 and
/// 2026-11-19), which keep `message` here. The other errors measured carry
/// `message`. REQ-ERR-002 in `docs/design/01-requirements.md` lists them.
fn message_key(error: &DynamoDbError) -> &'static str {
match error {
DynamoDbError::TransactionCanceledException { .. }
| DynamoDbError::IdempotentParameterMismatchException(_) => "Message",
| DynamoDbError::IdempotentParameterMismatchException(_)
| DynamoDbError::TransactionInProgressException(_) => "Message",
_ => "message",
}
}
Expand Down
162 changes: 49 additions & 113 deletions crates/core/src/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,21 @@ impl CancellationReason {
}
}

/// Internal reason for a wrong-typed key found while preparing a
/// Internal reason for a wrong-typed key supplied in the request of a
/// transaction member: a table key element that does not match the
/// schema, or a secondary-index key (on a written item or as a literal
/// operand) that does not match its attribute definition. Never reaches a
/// client: [`Self::resolve_key_faults`] rewrites it to `ValidationError`.
/// schema, or a secondary-index key (on a Put item or as an Update's
/// literal operand) that does not match its attribute definition. Never
/// reaches a client: [`Self::resolve_key_faults`] rewrites it to
/// `ValidationError`.
///
/// A wrong type an Update writes from `if_not_exists` or from an
/// attribute reference is not this reason. With the path present the
/// value comes from the stored item; with the path absent the fallback
/// is a literal from the request, and the service ranks it with the
/// values taken from the item. The service reports both as a plain
/// positional `ValidationError` and leaves the other members' outcomes
/// in place, so the storage layers carry them as
/// [`Self::validation_error`].
#[must_use]
pub fn key_type_mismatch(msg: impl Into<String>) -> Self {
Self {
Expand All @@ -342,47 +352,47 @@ impl CancellationReason {
}
}

/// Whether this reason is one of the internal key faults that
/// [`Self::resolve_key_faults`] gives precedence to. A backend that runs
/// members out of request order can stop once the earliest such member
/// in request order is known: a wrong-typed key there outranks every later
/// member, and an empty index key there outranks every later member that
/// is not itself a wrong-typed key.
#[must_use]
pub fn is_key_fault(&self) -> bool {
self.code == KEY_TYPE_MISMATCH_CODE || self.code == INDEX_KEY_EMPTY_ABORT_CODE
}

/// Apply the precedence `DynamoDB` gives key faults across the members of
/// a `TransactWriteItems` request, measured on the service. A wrong-typed
/// key (table or secondary index) on any member cancels the transaction
/// with the first such member's `ValidationError` in position and `None`
/// in every other position, whatever those members' own faults were.
/// Otherwise an empty secondary-index key on any member aborts the whole
/// request with a top-level `ValidationException`, outranking failed
/// conditions and unapplicable statements on the other members. Otherwise
/// the reasons are returned as they are.
/// a `TransactWriteItems` request, measured on the service: the first
/// internal key fault in request order decides. A wrong-typed key there
/// (see [`Self::key_type_mismatch`]) cancels the transaction with that
/// member's `ValidationError` and `None` in every other position,
/// whatever those members' own faults were. An empty secondary-index key
/// there (see [`Self::index_key_empty_abort`]) answers the whole request
/// with a top-level `ValidationException` carrying its message. With no
/// internal key fault the reasons are returned as they are: a wrong type
/// an Update writes from the stored item arrives as a plain
/// `ValidationError` and the other members keep their own outcomes beside
/// it (measured: `[ValidationError, ConditionalCheckFailed]`).
///
/// The storage layers resolve the faults supplied in the request (table
/// keys, a Put item's index keys, an Update's literal types) over every
/// member before any member is applied. They then run the members before
/// the first Update member with an empty index-key literal and put that
/// literal's reason at its position, so the reasons carry only empty
/// values, the first of which decides, beside plain reasons: an empty
/// value an earlier member wrote from the item answers ahead of the
/// literal (measured 2026-11-01).
///
/// # Errors
///
/// Returns `Err(message)` when the request must be answered with a
/// top-level `ValidationException` carrying `message`.
pub fn resolve_key_faults(reasons: Vec<Self>) -> Result<Vec<Self>, String> {
let first_type_mismatch = reasons
pub fn resolve_key_faults(mut reasons: Vec<Self>) -> Result<Vec<Self>, String> {
let Some(first) = reasons
.iter()
.position(|r| r.code == KEY_TYPE_MISMATCH_CODE);
let mut reasons = reasons;
.position(|r| r.code == KEY_TYPE_MISMATCH_CODE || r.code == INDEX_KEY_EMPTY_ABORT_CODE)
else {
return Ok(reasons);
};
if reasons[first].code == INDEX_KEY_EMPTY_ABORT_CODE {
return Err(reasons.swap_remove(first).message.unwrap_or_default());
}
for (i, reason) in reasons.iter_mut().enumerate() {
match first_type_mismatch {
Some(first) if i == first => reason.code = "ValidationError".to_owned(),
Some(_) => *reason = Self::none(),
None if reason.code == INDEX_KEY_EMPTY_ABORT_CODE => {
if let Some(message) = reason.message.take() {
return Err(message);
}
*reason = Self::none();
}
None => {}
if i == first {
reason.code = "ValidationError".to_owned();
} else {
*reason = Self::none();
}
}
Ok(reasons)
Expand All @@ -398,79 +408,5 @@ const KEY_TYPE_MISMATCH_CODE: &str = "ExtendDbKeyTypeMismatch";
const INDEX_KEY_EMPTY_ABORT_CODE: &str = "ExtendDbIndexKeyEmptyAbort";

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn item_response_missing_serializes_as_empty_object() {
let resp = ItemResponse { item: None };
let json = serde_json::to_value(&resp).unwrap();
// Real DynamoDB returns {} (no Item key) for missing items.
assert_eq!(json, serde_json::json!({}));
}

#[test]
fn item_response_present_serializes_item() {
let mut item = Item::new();
item.insert("pk".to_owned(), AttributeValue::S("val".to_owned()));
let resp = ItemResponse { item: Some(item) };
let json = serde_json::to_value(&resp).unwrap();
assert_eq!(json["Item"]["pk"]["S"], "val");
}

fn codes(reasons: &[CancellationReason]) -> Vec<&str> {
reasons.iter().map(|r| r.code.as_str()).collect()
}

#[test]
fn no_key_fault_leaves_the_reasons_untouched() {
let reasons = vec![
CancellationReason::condition_check_failed_with_item(None),
CancellationReason::validation_error("cannot apply"),
CancellationReason::none(),
];
let out = CancellationReason::resolve_key_faults(reasons).unwrap();
assert_eq!(
codes(&out),
["ConditionalCheckFailed", "ValidationError", "None"]
);
}

#[test]
fn an_empty_index_key_becomes_a_top_level_message_over_other_member_faults() {
let reasons = vec![
CancellationReason::condition_check_failed_with_item(None),
CancellationReason::index_key_empty_abort("empty key"),
CancellationReason::validation_error("cannot apply"),
];
assert_eq!(
CancellationReason::resolve_key_faults(reasons).unwrap_err(),
"empty key"
);
}

#[test]
fn a_type_mismatch_masks_every_other_member_including_an_empty_key() {
let reasons = vec![
CancellationReason::condition_check_failed_with_item(None),
CancellationReason::index_key_empty_abort("empty key"),
CancellationReason::key_type_mismatch("type"),
CancellationReason::validation_error("cannot apply"),
];
let out = CancellationReason::resolve_key_faults(reasons).unwrap();
assert_eq!(codes(&out), ["None", "None", "ValidationError", "None"]);
assert_eq!(out[2].message.as_deref(), Some("type"));
}

#[test]
fn only_the_first_type_mismatch_by_position_is_reported() {
let reasons = vec![
CancellationReason::none(),
CancellationReason::key_type_mismatch("second"),
CancellationReason::key_type_mismatch("third"),
];
let out = CancellationReason::resolve_key_faults(reasons).unwrap();
assert_eq!(codes(&out), ["None", "ValidationError", "None"]);
assert_eq!(out[1].message.as_deref(), Some("second"));
}
}
#[path = "transaction_tests.rs"]
mod tests;
Loading
Loading