Repository navigation
fix(transact): rank index-key faults and handle the ClientRequestToken as the service does - #853
Open
LeeroyHannigan wants to merge 52 commits into
Open
LeeroyHannigan wants to merge 52 commits into
LeeroyHannigan wants to merge 52 commits into
Conversation
…eason on every backend In a TransactWriteItems request an Update member can give a secondary-index key a value of the wrong type in two ways: a literal operand in the request, or a value computed from the stored item (an attribute reference, the fallback of if_not_exists). The service ranks them differently across members, measured on 2026-10-30 in us-east-1 on two tables, every request sent twice: - a wrong type supplied in the request (a table key, a Put item's index key, an Update's literal operand) cancels with ValidationError at that member and None at every other member, ahead of a failed condition and ahead of a computed wrong type elsewhere; - otherwise an empty index key supplied in the request is a top-level ValidationException, in either member order, ahead of a computed wrong type and ahead of a failed condition elsewhere; - otherwise each member keeps its own outcome, and a computed wrong type is a ValidationError at its member beside them: [ValidationError, ConditionalCheckFailed]. The SQLite, PostgreSQL and MongoDB transacted Update arms carried the computed check as the internal key-type-mismatch reason, which the resolver treats as a request fault, so a computed mismatch masked a failed condition on another member ([ValidationError, None]) and outranked an empty key on another member (a cancellation instead of the ValidationException); on MongoDB, which has no pre-pass, it also outranked a Put item's empty key and a wrong-typed value supplied on a later member. Cassandra already carried it as a plain ValidationError and answered every measured row as the service does. The three arms now carry the computed check as a plain ValidationError. The resolver, its doc comment, the docs row and the test docstring state the rule as measured; the earlier statement that any wrong-typed key masks every other member holds only for a value supplied in the request. The pre-pass is unchanged. Tests: tests/test_transact_index_key_cross_member.py runs the 16 measured two-member transactions and 5 single-request controls with their exact codes, messages and the no-write check on SQLite, PostgreSQL, MongoDB and Cassandra. Before this commit it fails A2, A2r, B1 and B1r on SQLite and PostgreSQL, those four plus C1, C1r, F1 and F2 on MongoDB, and nothing on Cassandra; after it, 21 pass on each. Three resolver unit tests cover the three kinds of fault against each other in both orders.
…ared pass Move the SQLite and PostgreSQL key checks into extenddb-storage as transact_op_key_checks and transact_key_check_pass, and run the pass on all four backends before any member is applied: SQLite and PostgreSQL where they ran their own, MongoDB before its session transaction starts, Cassandra before its ledger entry and PREPARE. resolve_key_faults now lets the first internal key fault in request order decide. PostgreSQL's lock-conflict path resolves its reasons too. is_key_fault had no caller and is removed.
…ross members tests/test_transact_index_key_cross_member.py gains the 19 rows of the 2026-10-31 measurement that put a Put item's empty index key against a wrong type supplied in the request (G rows), against an Update member's empty value (H rows), and an Update member's empty value against a wrong-typed literal or a failed condition (J rows), with the measured codes and messages and the no-write check. On servers built from cef39cf90 the G rows with the Put item first fail on all four backends, and G6r and H1 to H4 also fail on MongoDB and Cassandra; on this branch all 40 cases pass on each backend.
…append and arithmetic by their result An Update's empty index-key literal (SET k = :v, :v an empty string or binary) is reported by the service on the statement, after the literal type check and ahead of the condition, of an action that cannot apply and of a wrong type computed from the item, on UpdateItem and in TransactWriteItems (measured 2026-10-31, 15 requests). UpdateItem now checks it right after the literal type check, in the engine and against the write's own index read on PostgreSQL and SQLite. TransactWriteItems runs a second request-level pass, transact_op_empty_literal_checks, over every member after the first and before any member is applied; the first empty literal in request order answers the top-level ValidationException. An empty value written from the item or from the if_not_exists fallback is still found after the condition. list_append always yields a list and arithmetic always a number, and the service checks both on the statement whatever their operands read, so literal_operand_type types them by their result; an attribute reference and if_not_exists stay values written from the item. The four tests of tests/test_index_key_validation_on_update.py that pinned an empty literal after the condition or after an action that cannot apply now expect the measured answer and are renamed for it. The twi_conflict deadlock test keys its placeholder the way the parser does.
…cs row tests/test_transact_index_key_cross_member.py gains the measured rows for an Update's empty index-key literal on UpdateItem (s1 to s9) and in TransactWriteItems (t1 to t6, K1, K1r), and for list_append that reads the item, alone and beside every partner (L1 to L10, la1, la2). On servers built from cef39cf90 the 75 cases fail 38 on SQLite and PostgreSQL and 43 on MongoDB and Cassandra; on this branch all 75 pass on each backend. s8, s9, K1r and the reversed G and H rows pass on cef39cf90 too and pin both orders. The twi_conflict deadlock test now writes its empty value from the stored item, since an empty literal is found before any row is locked. The validation unit tests satisfy clippy. docs/differences-from-dynamodb.md states the rules as measured and the shared differences with their issues.
…rvice does PR #416 checks secondary-index keys on UpdateItem and in TransactWriteItems, and its review asked that the four backends rank those faults across members the same way. A measurement on the service on 1 November 2026, each request and token sequence sent twice, found three rules that the four backends, with the earlier commits of this branch, still answered differently. Across members the first empty index-key value in request order decides, whether an Update supplies it as a literal or writes it from the item: [Update r SET sidx = e, Update b0 SET bidx = :eb] answers the first member's empty string. The backends, with those commits, answered the second member's empty binary literal, because they checked every member's literals before any member ran. Now they find the first Update member with an empty literal, run only the members before it, put the literal's reason at its position and resolve the reasons as before. Within one statement the literal still comes first, and a member whose own condition fails writes nothing, so its empty if_not_exists fallback is never reported. With the literal on the first member nothing runs. With it later, the members before it run, and on PostgreSQL they lock their rows, so such a request waits on a row another transaction holds, as any member does: until the holder commits or rolls back, or the deadlock detector breaks a cycle. The checks on keys supplied in the request (table key types, a Put item's index keys, an Update's literal types) now run before the ClientRequestToken is checked. A reused token beside such a fault answers the fault, and the token stays unused. A fault found after those checks (an empty literal, an empty or wrong-typed value written from the item, a failed condition) now leaves the token used: another request with it answers IdempotentParameterMismatchException and is not applied, and the same request runs again. Each backend rolls the writes back and then stores the token with its fingerprint prefixed "cancelled:", which no request fingerprint carries, and StoredToken::of tells a replay, a rerun and a mismatch apart. Cassandra no longer deletes the token on these paths. Two empty literals of different kinds in one statement had no fixed order on the service, so the unit test that pinned one order now accepts either. tests/test_transact_index_key_cross_member.py gains U3a, U3b, U3c, U3f and U1a to U1c from that measurement, and the reverse list_append rows L4r, L9r and L10r of the 31 October one (85 cases). The new tests/test_transact_index_key_token.py sends its token sequences (20 cases). On servers of main 25ee109 the two files fail 51 of the 105 cases on SQLite and on PostgreSQL, 62 on MongoDB and 52 on Cassandra. On this branch all 105 pass on every backend, as do the 64 of tests/test_index_key_validation_on_update.py. A twi_conflict test pins that an empty literal on the first member answers without waiting on a later member's lock, and a Cassandra direct test pins the token after a request-level fault, an empty literal and a failed condition. The docs row states the rules and the shared differences, three of them with their issues.
…ogress Amazon DynamoDB keeps the ClientRequestToken of a cancelled TransactWriteItems request used for 10 minutes from the last cancellation. This was measured in us-east-1 on 2026-11-05, with each sequence sent twice. A different request with the token answers IdempotentParameterMismatchException 9 minutes after the cancellation and runs 11 minutes after it. A cancellation of the same request sent again starts the 10 minutes again. Every cancellation after the request-level key checks keeps the token used. These include a failed condition on a ConditionCheck, Delete, Put or Update member, an Update that grows the item past 400 KB, an action that cannot apply, and TransactionConflict. After a TransactionConflict the same request runs again and commits. The service also got two sends of one request at the same moment. It answered one with the request's answer and the other with TransactionInProgressException "Transaction from previous request is still in progress". In some rounds it answered both with the request's answer. When two clients sent a request that commits at the same moment, the service applied it once in each of 20 rounds. The commit before this one keeps the token used after such a cancellation, and left these differences: - Cassandra wrote the cancelled token with no TTL, so the token stayed used with no end. It now writes the cancelled token with a TTL of 600 seconds. The take of a cancelled token by its rerun writes the same TTL. So the token stays used for 10 minutes from the last cancellation, as on the other backends. - SQLite, PostgreSQL and MongoDB kept the created_at of the first cancellation when the same request was cancelled again. The record of the cancelled token now sets created_at to the time of the cancellation. MongoDB also replaces a token document older than the 10-minute read window, which $setOnInsert left in place. - On Cassandra, the token row of a send held the request's fingerprint while the send ran. Another send of the same request could read the row. It then answered as a replay of a write that had not happened, also when the first send was then cancelled. The row now holds running:<fingerprint> while the send runs. The send writes the plain fingerprint when it commits and the cancelled fingerprint when it is cancelled. A send that reads a running row of its own request answers TransactionInProgressException. - A Cassandra send that fails after the reservation leaves the running row, and so does a failed write of the plain fingerprint. The reservation and the take now write the row with a TTL of 600 seconds. So the same request answers TransactionInProgressException, and another request the mismatch, until the row expires 10 minutes after the reservation or the take. Before, such a row held the plain fingerprint with no TTL, and the same request answered as a replay with no end. The plain fingerprint of a committed request still has no TTL, so a committed token stays used with no end, as before. - On Cassandra, a send could lose the reservation of the token to another send. It then compared the stored fingerprint with ==, so it answered the mismatch when the other send was cancelled. It now classifies the row as the read before the reservation does. A take that loses its LWT answers TransactionInProgressException, where it answered a replay. The new StorageError::TransactionInProgress maps to that exception. - On SQLite, PostgreSQL and MongoDB, a failed write of the cancelled token after the rollback answered an internal error. The failure is now logged, and the request answers its cancellation. - The PostgreSQL conflict paths outside the member loop released the token: the token check, the stream record, the index work and the commit. These paths raise no conflict at READ COMMITTED, the default isolation, and can raise one at a stricter isolation. The MongoDB TransactionConflict after the last attempt released the token too. They now record it as cancelled. SQLite unit tests, a PostgreSQL twi_conflict test and MongoDB live tests set created_at back to pin the 10 minutes and their restart. The MongoDB tests also pin the replaced document. Cassandra direct tests read the TTL of a cancelled token row and of a reservation. A twi_conflict test pins the token after a deadlock: another request answers the mismatch, and the same request commits. A Cassandra direct test sends one request twice at once, in 10 rounds of first sends and 10 rounds of a cancelled request. It accepts only the cancellation or TransactionInProgressException. Another writes a running row by hand: the same request answers TransactionInProgressException, and another request answers the mismatch. A SQLite unit test makes the token write fail and expects the cancellation. tests/test_transact_index_key_token.py gets the rows of 5 November: an Update past 400 KB, an action that cannot apply, failed conditions on ConditionCheck, Delete and Put members, and the same request twice. It also marks the ReturnConsumedCapacity row as an expected failure (#514). The docs row states the rules of 5 November, the mismatch message (#760) and #514. It also states PostgreSQL's answer to two sends of one request at once (#851). It no longer states an order between the 400 KB check and the index-key checks, which no measurement shows.
Cassandra marks a committed ClientRequestToken of TransactWriteItems by writing the request's plain fingerprint into its row of idempotency_tokens_by_account. The write is an UPDATE ... IF fingerprint = running:<fingerprint>, and it had no TTL. The table has no default TTL, and the Cassandra cleanup_expired_idempotency_tokens returns 0. The token check reads the row without its created_at. So the token of a committed request stayed used for as long as the row existed. At any time after the commit, the same request sent again answered as a replay. A different request with the token answered IdempotentParameterMismatchException. Amazon DynamoDB keeps the token of a committed request used 9 minutes after the request. It treats the token as new 11 minutes after the request (measured in us-east-1 on 2026-11-05, each sequence sent twice). SQLite, PostgreSQL and MongoDB keep a token for 10 minutes through its created_at. The commit mark now writes with USING TTL 600 (IDEMPOTENCY_TOKEN_TTL_SECONDS), as the reservation, the take and the write of a cancelled token do. So every token row that this release writes expires 10 minutes after its last write. A row that an earlier release wrote has no TTL and stays. A send that fails before the mark leaves the running row of its reservation or its take: that row expires 10 minutes after the write. A direct test commits a Put with a token and reads TTL(fingerprint) of its row as a value from 590 to 600 seconds.
LeeroyHannigan
requested review from
amrith,
c33howard,
eliseong,
hitesh96db,
jcshepherd,
navareamol,
pdf-amzn and
robinnsc
as code owners
November 5, 2026 06:16
Three twi_conflict tests close a deadlock cycle through an outside transaction and expect PostgreSQL to abort the write transaction. PostgreSQL aborts the transaction whose deadlock check finds the cycle, and each waiter checks once, deadlock_timeout after it starts to wait. The write transaction waits first. With the default of 1 second on both sides, the two checks fall a few milliseconds apart. Under load the outside transaction's check can then run first, and PostgreSQL aborts the outside transaction instead. The test then fails. The token test of the conflict path failed that way once in 54 runs of the file. The outside transaction now runs SET LOCAL deadlock_timeout = '5s'. The write transaction's check runs 1 second into its wait, with the cycle closed. The outside transaction gets its lock when the write transaction aborts. SET LOCAL ends with the transaction, so the pooled connection keeps the server default. The role must be allowed to set deadlock_timeout. The CI role postgres is a superuser. At the SQL level, an outside session with a check at 100 ms was the victim, and with 5 seconds the write session was. With the change, the two deadlock tests passed 20 runs, the token test passed 20 runs and the whole file passed 5 runs.
…re a token On PostgreSQL, two sends of one TransactWriteItems request with one ClientRequestToken at the same moment could both apply the request (#851). The token check is one statement. It inserts the token row with INSERT ... ON CONFLICT DO UPDATE ... WHERE in a WITH query, and it selects the stored row with UNION ALL. The second send's insert waited on the first send's uncommitted token row. When the first send committed, the insert locked the committed row. Its WHERE was false, so it returned no row. The select read with the snapshot that the statement took before that commit, and it returned no row either. The request then ran as a new one. On a PostgreSQL server built from the parent commit, two clients sent [Update cnt SET n = n + :one] with one fresh token in 10 rounds. Both sends answered OK in every round, and n grew by 2 in 3, 8, 10, 10 and 10 rounds of five runs. The same stale read gave the wrong answer when the token was stored as cancelled. One of two sends of the same request took the cancelled row and committed. The other read the cancelled row with its older snapshot and answered IdempotentParameterMismatchException, the answer for a different request. In both cases the select read an older version of the row than the one the insert locked. The insert's WHERE is false on the locked row, so that row is less than 10 minutes old and is not this request's cancelled row. A select that returns no row, or this request's cancelled row, has therefore read an older version. For these two results the check now runs the statement once more. At READ COMMITTED the second statement takes a new snapshot, which holds the locked row. The first statement keeps that row locked until the transaction ends, so the second statement does not wait, and it reads the same row. A committed row of the request answers as a replay. A row of another request answers the mismatch. Amazon DynamoDB applied such a request once in each of 20 rounds (us-east-1, 2026-11-05, retries off). In 18 rounds one send answered OK and the other TransactionInProgressException. In 2 rounds both sends answered OK. So the second send answers TransactionInProgressException, or waits and answers as the first send did. The PostgreSQL send has waited for the commit when it reads the row, so it answers the replay. A client that retries TransactionInProgressException gets the same replay on its retry. Two storage tests in twi_conflict.rs send a request twice at the same moment, released by a barrier. Each test runs 20 rounds with a fresh token per round. One test sends the request alone. The other first sends it with the token while its condition fails. In each round n grows by 1, one send commits, and the other answers the replay or TransactionInProgress. On the parent commit, 13 to 18 of the 20 rounds failed in each of five runs of each test. A wire test in test_transact_write_conflict.py sends the request from two clients in 10 rounds. It requires that n grows by 1 and that each answer is OK or TransactionInProgressException, on every backend and against the service. The docs row on index key validation no longer lists the PostgreSQL difference. Fixes #851.
6 of 8 tasks
…tale check_idempotency_token_in_tx runs the token statement a second time when the first one returns no row, or this request's cancelled row. At READ COMMITTED, and with NOW() the same in both statements, the second statement reads the row that the first statement locked. The check did not test the second result. If the second statement also returned no row, the request ran as a new one and applied a second time, as in #851. transact_write_items_impl opens its transaction with begin(), which takes the default isolation level of the role or the database. The check now answers TransactionInProgress when the second statement also returns no row or this request's cancelled row, and it does not run the request. The engine maps that error to TransactionInProgressException ("Transaction from previous request is still in progress"). Amazon DynamoDB gave that answer in 18 of 20 rounds of two sends at once (us-east-1, 2026-11-05). is_conflict_abort does not match the error, so the transaction rolls back and the token row stays as the other send stored it.
…d token row The second token statement also fixes two races that the storage tests did not cover. Two new tests in twi_conflict.rs run 20 rounds with a fresh token per round. In each round they send two calls at the same moment through a barrier. two_requests_with_one_token_at_once_apply_only_one sends the same update with one token and two fingerprints. In each round n grows by 1, one call commits, and the other answers IdempotentMismatch or TransactionInProgress. two_sends_that_take_an_old_token_row_apply_it_once first stores a token row of another request with a created_at 11 minutes ago. Then it sends one request twice. The first send takes the old row. The first statement of the second send reads the old row with its snapshot, and the 10-minute filter drops that row. In each round n grows by 1, one call commits, and the other answers the replay or TransactionInProgress. With tx_helpers.rs from the head of #853 (e1c6bba), both tests failed in 3 of 3 runs. The first test failed in 15, 15 and 17 of the 20 rounds. The second test failed in 16, 16 and 17 of the 20 rounds. In each failing round both calls committed and n grew by 2. On this branch both tests passed in 3 of 3 runs. send_twice_at_once now takes one key for each of the two sends.
The doc comment of check_idempotency_token_in_tx said that the transaction runs at READ COMMITTED. transact_write_items_impl opens the transaction with begin(), which takes the default isolation level of the role or the database. The comment now says that the second statement reads the locked row when the transaction runs at READ COMMITTED. It also says that the check tests the second result for this reason.
The doc comment of `record_cancelled_token` said that neither LWT replaces a row that another send or request holds. The UPDATE applies to any row that holds the request's running fingerprint. If a send runs longer than the TTL of its row, a later send of the same request can reserve the token with that fingerprint. The UPDATE of the first send can then replace the running row of the later send. The comment now states the condition of each LWT. `apply_lwt` answers `Err` for every statement failure, a Paxos timeout included, and the write can still apply after a timeout. The comment of the `Err` arm now says that the token row stays as it was if the write did not apply. The comment no longer lists what the row can hold, because a later send of the same request can also leave a row. The log line no longer says `(token row unchanged)`. `apply_lwt` already logs the statement error with its context.
Collaborator
Author
|
Thanks Joel. Point by point:
Also, b5e034c and 96fe994 move test code, unchanged, to files of their own. The Cassandra token tests go from |
Main is at 44cd436, 13 commits after the last merge. No file has a conflict. One file changed on both sides, and git merged it with no overlap: tests/test_transact_write_conflict.py. In that file, #1148 sends the calls of the contention test through call_with_handshake_retry. The token race test of this branch is in another part of the file.
Main is at 6aef346, 2 commits after the last merge (#432 and #468). No file has a conflict. Three files changed on both sides, and git merged each of them with no overlap: docs/differences-from-dynamodb.md, crates/storage/src/lib.rs and crates/storage-cassandra/tests/direct_integration.rs. #468 adds a Streams section to the differences page, a method to the StreamEngine trait and a test module to the Cassandra direct tests. This branch changes the index key validation row, the transact exports and the token test module.
validate_index_key_not_empty and validate_index_key_empty_literals wrote the same message text. Both now call update_expression_empty_key_message. The empty-literal unit test compares the full message with assert_eq, where it checked only the last sentence. For two empty literals of different kinds in one statement, it accepts either full message, because the service answered with either one (measured 2026-11-01).
…rage error storage_err_to_dynamo wrote the text of StorageError::TransactionInProgress a second time. It now uses the error's Display text, so the message has one copy, in crates/storage/src/error.rs. A unit test pins the status, the error type and the message that the service sends (measured 2026-11-19).
… transaction The key-check pass and the empty-literal pass of transact_write_items each built the IndexKeyRef list of a member's table again for every member. Both passes now read one list per table, which the function builds from the index schemas it fetched.
…on level The comment on check_idempotency_token_in_tx said that a stricter isolation level gives a second stale result. A probe on PostgreSQL 16 gave this instead. At READ COMMITTED, the second statement of the second send reads the row that the first send committed. At REPEATABLE READ and SERIALIZABLE, the first statement fails with SQLSTATE 40001, and the backend cancels the request with TransactionConflict on every member. The comment now says this and names #570. The TransactionInProgress arm stays as a guard, so that a request does not run twice if a second stale result comes.
The two sends of test_two_sends_of_one_request_with_one_token_apply_it_once now go through call_with_handshake_retry, as #1148 did for the other race test in tests/test_transact_write_conflict.py. The helper retries only a handshake that fails before the client sends the request, so each send still reaches the server once.
…ey row The index key validation row of docs/differences-from-dynamodb.md now names two backend differences that the PR description lists. On MongoDB, a request whose token document is older than 10 minutes gets a TransactionConflict cancellation until the TTL monitor removes the document (#836). On Cassandra, a send that fails after it reserves the token leaves its row, and the same request answers TransactionInProgressException until the row expires (#837).
…file to a module of their own tests/direct/transact_write_tokens.rs had 686 lines. Three tests move, unchanged, to the child module transact_write_tokens/concurrent_sends.rs: - a send that meets a running send of its request - two sends of one request at once - a token row that changes while a send runs They use the file's helpers through `super::`. The file keeps the key fault test, the three TTL tests and the helpers, in 410 lines. The child has 294.
Main is at 018715e, 5 commits after the last merge (#503, #526, #690, #765 and #774). No file has a conflict. One file changed on both sides, and git merged it with no overlap: docs/differences-from-dynamodb.md. #526 adds a Transactions section to it, and this branch changes the index key validation row. #526 puts the Return fields in the token fingerprint and gives IdempotentParameterMismatchException the service's message. #774 picks the message key per error. The commits after this merge bring the branch in line with both.
This branch raises TransactionInProgressException, and main's message_key sent it with the key message. The service sends it with Message (raw bodies, us-east-1, 2026-11-19, two runs of eight concurrent TransactWriteItems with one ClientRequestToken). The error is now in the Message arm of message_key. A new row of the_message_key_follows_the_service_per_error pins the key. The comment of message_key no longer says that ExtendDB does not raise the error.
#526 gives IdempotentParameterMismatchException the service's message and puts ReturnConsumedCapacity and ReturnItemCollectionMetrics in the token fingerprint. The index key row of the differences page still listed both as differences (#760 and #514). The two sentences are gone. The Q7a case of tests/test_transact_index_key_token.py sends a cancelled request again with ReturnConsumedCapacity TOTAL. Its xfail marker expected an assertion failure on ExtendDB (#514). The case now passes, so the marker is gone.
#526 says in the compute_fingerprint comment and in its upgrade manual entry that Cassandra keeps a token with no expiry. On this branch every write of a Cassandra token row has a TTL of 600 seconds. Only a row that an earlier release wrote has no TTL. Both texts now say this. The upgrade entry also says that after a downgrade, the tokens of this release expire as on the other backends.
Main is at 3534c9e, one commit after the last merge (#1009, the WebAssembly build). One file conflicted: crates/server/src/response.rs. #1009 moved message_key, the function that picks the key of an error message, from that file to crates/core/src/error/mod.rs, where the shared error_document helper calls it. The merge takes main's response.rs. It adds this branch's TransactionInProgressException arm and its doc sentence to the moved function, so that error still carries its message under Message (measured 2026-11-19). crates/storage-sqlite/src/data/tx_helpers.rs merged with no overlap. #1009 reads the clock there through web_time.
This was referenced Nov 24, 2026
Main is at db8a90d. This branch last had main at 3534c9e (#1009). Since then, 44 commits merged into main. Among them, #1514 released v1.1.0 without this branch, and #1166 moved to sqlx 0.9.1. Four files conflicted: - crates/storage/src/lib.rs: #1449 exports VectorItemFilter beside the transact exports that this branch extends. The merge keeps both. - crates/storage-mongodb/src/data_engine_live_tests.rs: #1446 declares its delete_table module where this branch declares token. The merge keeps both, main's first. - crates/storage-postgres/tests/twi_conflict.rs: #1166 passes the SQL of the deadlock test through sqlx::AssertSqlSafe, and this branch takes the outside transaction from outside_transaction. The merge keeps the helper and the wrapper. - docs/manuals/07-upgrade-manual.md: #1514 moved and rewrote the v1.1.0 ClientRequestToken entry of #526. This branch changed the Cassandra sentence of the old copy. The merge keeps the entry as main has it. The text of this branch is now a v1.2.0 entry after the v1.2.0 entries of main, because v1.1.0 shipped without this change. sqlx 0.9 takes SQL that is not a &'static str only in sqlx::AssertSqlSafe (#1166). The merge passes the SQL of the 11 queries that this branch adds to twi_conflict.rs in it. The SQL text does not change. Git merged these files, which both sides change, at other lines: - crates/core/src/error/mod.rs and crates/core/src/validation/mod.rs - crates/engine/src/transact_write_helpers.rs and crates/storage/src/transact.rs - tx_helpers.rs of PostgreSQL and SQLite, and crates/storage-postgres/src/data/update_item.rs - the Cassandra direct_integration.rs and docs/differences-from-dynamodb.md Since #1375, the engine stores a ClientRequestToken with each backslash doubled and each U+0000 written \0 before a backend sees it. The token code of this branch uses that stored form, as it used the token before.
Main is at 44a7b79, four commits past db8a90d: #1466, #1087, #768 and #1296. #1087 adds its v1.2.0 entry to docs/manuals/07-upgrade-manual.md after the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of #1087 first, then the entry of this branch, before the v1.1.0 entries. Git merged two other files with no conflict: - crates/storage-mongodb/src/data_engine.rs: #1087 computes the parallel Scan segment with scan_segment in scan_key_in_segment and in scan_impl. This branch changes the TransactWriteItems functions at other lines. - crates/storage/src/lib.rs: #1087 rewrites the doc comment of scan_key_in_segment, and this branch adds the transact exports.
Main is at 1e2ebdd, six commits past 44a7b79: #1485, #1228, #1325, #1443, #1269 and the squash commit of #1093. One file conflicted: crates/storage-mongodb/src/data_engine_live_tests.rs. #1093 declares the update_window module after delete_table, where this branch declares the token module. The merge keeps both declarations: update_window first, then token. Git merged five other files with no conflict: - crates/core/src/validation/mod.rs: #1228 adds the pattern clause for an empty value in validate_name_member. This branch changes the index key checks, at other lines. - crates/storage/src/error.rs: #1093 adds a sentence to the doc comment of IndexesInUse, and this branch adds TransactionInProgress. - crates/storage/src/lib.rs: #1093 declares update_window_conformance, and this branch adds names to the transact exports. - docs/differences-from-dynamodb.md: #1443 changes the default delay to 0.25 s, and #1093 changes the row on stream disable and the row of the delay setting. This branch changes the row on index key validation. - docs/manuals/07-upgrade-manual.md: #1093 adds its v1.2.0 entry at the top of "Behavior Changes by Release". The entry of this branch stays after the v1.2.0 entries of main.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes since the last review
The last review is jcshepherd's of 20 November, at 98ed152. These commits came after it:
b3b6d51 and 4a01560: the Cassandra cancellation writes the cancelled token with an LWT, as every other write of the token row does. If the send's row expired, the write inserts the row with
IF NOT EXISTS.05769a3, 6f128ab and 23f3f15: the Cassandra token tests read the token row through one helper and check its TTL after a cancellation. The comment of the cancellation says only what its LWTs guarantee.
c25d75e, a6d6e1a and 9293478: the comment on the PostgreSQL token check. 9293478 fixes what it said about REPEATABLE READ and SERIALIZABLE (the thread on
tx_helpers.rs).203cb12, 943e606 and ea0279d delete second copies. They are the update-expression message of an empty index key, the message of
TransactionInProgressExceptionand the MongoDB index key list of each table.53f0437:
TransactionInProgressExceptioncarries its message under the keyMessage, as the service sends it. fix(server): send Message on the two errors the service sends it on #774 added the per-error key on main.57f2e47 and 0958e28 bring this branch in line with fix(engine): compare the Return fields on a TransactWriteItems token replay #526. 57f2e47 deletes two differences that fix(engine): compare the Return fields on a TransactWriteItems token replay #526 fixed from the index key row of the differences page. They are the message of the token mismatch (TransactionCanceledException and IdempotentParameterMismatchException carry
message; DynamoDB sendsMessage, and the token mismatch text differs #760) and the fingerprint without the Return fields (TransactWriteItems token replay ignores ReturnConsumedCapacity and ReturnItemCollectionMetrics #514). The test of a cancelled request sent again with anotherReturnConsumedCapacityloses its xfail marker. The comment ofcompute_fingerprintand the token entry of the upgrade manual said that Cassandra keeps a token with no expiry. They now say that a Cassandra token row expires 10 minutes after its last write, unless an earlier release wrote it. In the manual, that text is a v1.2.0 entry since 676cf8f.76e961e: the token race test in
tests/test_transact_write_conflict.pysends throughcall_with_handshake_retry, as test(wire): retry a TLS handshake failure in the race tests and print it #1148 did for the other race test of that file.9819376: the docs row names the MongoDB and Cassandra token differences (MongoDB: a ClientRequestToken older than 10 minutes answers TransactionConflict until the TTL monitor removes its document #836, Cassandra: a TransactWriteItems sent again after a failure that applied nothing answers as a replay #837).
b5e034c, 96fe994 and a67a182 move test code, unchanged, to files of their own.
6555187, a67e1eb, 08f2a93, 1e36a9b and c414410 merge main at 2ef5613, 44cd436, 6aef346, 018715e and 89fc971. No file had a conflict.
62cea0c merges main at 3534c9e (feat(wasm): [Add WebAssembly browser support for ExtendDB #1009, the WebAssembly build). One file conflicted:
crates/server/src/response.rs. feat(wasm): [Add WebAssembly browser support for ExtendDB #1009 movedmessage_keyfrom that file tocrates/core/src/error/mod.rs. The merge takes main'sresponse.rsand adds theTransactionInProgressExceptionarm of 53f0437 to the moved function.676cf8f merges main at db8a90d (fix(storage-cassandra): retry a lost UpdateItem version check over the PutItem and DeleteItem window #1531), 44 commits after 3534c9e. Four files conflicted:
crates/storage/src/lib.rs: the merge keeps the transact exports of this branch and theVectorItemFilterexport of feat: SearchVectors inequality filters #1449.crates/storage-mongodb/src/data_engine_live_tests.rs: the merge keeps thedelete_tablemodule of fix(storage-mongodb): keep a DELETING table's tags until its document goes #1446 and thetokenmodule of this branch.crates/storage-postgres/tests/twi_conflict.rs: the merge keepsoutside_transaction. It passes the SQL of the 11 queries that this branch adds there throughsqlx::AssertSqlSafe, as fix(deps): move to sqlx 0.9.1 for the SQLite fix of RUSTSEC-2026-0459 #1166 does for sqlx 0.9.1.docs/manuals/07-upgrade-manual.md: chore(release): bump version to 1.1.0 #1514 moved and rewrote the v1.1.0 token entry of fix(engine): compare the Return fields on a TransactWriteItems token replay #526, and v1.1.0 shipped without this branch. The merge keeps that entry as main has it. The Cassandra text of 0958e28 is now a v1.2.0 entry after the v1.2.0 entries of main. Its title is "on Cassandra, aClientRequestTokenrow expires 10 minutes after its last write".Since fix(engine): check a ClientRequestToken as DynamoDB does #1375, the engine stores a token with each backslash doubled and each U+0000 written
\0before a backend sees it. The token code of this branch uses that stored form. The merge adds no check, message or helper.469ceba merges main at 44a7b79, which brings ci(release): add devtools/freeze-migrations #1466, fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087, fix(bin): rerun the build script when the checked-out commit changes #768 and fix(server): ignore a TableName sent to an operation without one #1296. fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 adds its v1.2.0 entry to
docs/manuals/07-upgrade-manual.mdafter the other v1.2.0 entries of main, where this branch has its entry. That is the one conflict. The merge keeps both entries without change: the entry of fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 first, then the entry of this branch, above the v1.1.0 entries. Git merged two other files that both sides change, each at other lines. Incrates/storage-mongodb/src/data_engine.rs, fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 computes the parallel Scan segment withscan_segmentinscan_key_in_segmentand inscan_impl, and this branch changes the TransactWriteItems functions. Incrates/storage/src/lib.rs, fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 rewrites the doc comment ofscan_key_in_segment, and this branch adds the transact exports. The lines that this branch changes against main are the same before and after the merge. The gates on 469ceba:cargo fmt --all -- --checkis clean. Both clippy commands of.github/workflows/clippy.ymlwith-D warningsare clean on the whole workspace.backup_storeand two SQLite tests ofbackup_catalog::write_lock_tests.cargo test -p extenddb-wasm-adapter: its 3 unit tests and theparitycorpus test pass.doc_version_literalspasses (3).--no-default-features --features sqlite) and 179 passed on PostgreSQL.pytest --collect-onlycollectstests/(7460 tests) andtests/python/(820 tests) with no error.6d3d448 merges main at 1e2ebdd, which brings docs: correct the throttle bucket key and the LSI plan limits #1485, fix(core): list the pattern clause for an empty name member #1228, fix(console): serve the pages under a Content-Security-Policy that runs no inline script #1325, docs: fix stale defaults and duplicate headings outside install pages #1443, test(storage-cassandra): widen the timing bounds of two lock tests #1269 and fix: answer UPDATING while an UpdateTable change applies #1093. One file conflicted:
crates/storage-mongodb/src/data_engine_live_tests.rs. fix: answer UPDATING while an UpdateTable change applies #1093 declares itsupdate_windowtest module afterdelete_table, where this branch declarestoken. The merge keeps both,update_windowfirst. Git merged five other files that both sides change, each at other lines:crates/core/src/validation/mod.rs: fix(core): list the pattern clause for an empty name member #1228 adds the pattern clause for an empty value invalidate_name_member. This branch changes the index key checks.crates/storage/src/error.rs: fix: answer UPDATING while an UpdateTable change applies #1093 adds a sentence to the doc comment ofIndexesInUse, and this branch addsTransactionInProgress.crates/storage/src/lib.rs: fix: answer UPDATING while an UpdateTable change applies #1093 declaresupdate_window_conformance, and this branch adds names to the transact exports.docs/differences-from-dynamodb.md: docs: fix stale defaults and duplicate headings outside install pages #1443 changes the default delay to 0.25 s, and fix: answer UPDATING while an UpdateTable change applies #1093 changes the row on stream disable and the row of the delay setting.docs/manuals/07-upgrade-manual.md: fix: answer UPDATING while an UpdateTable change applies #1093 adds its v1.2.0 entry at the top of "Behavior Changes by Release". The entry of this branch stays after the v1.2.0 entries of main.The lines that this branch changes against main are the same before and after the merge. The gates on 6d3d448:
cargo fmt --all -- --checkis clean. Both clippy commands of.github/workflows/clippy.ymlwith-D warningsare clean on the whole workspace.backup_storeand two SQLite tests ofbackup_catalog::write_lock_tests.cargo test -p extenddb-storage-mongodb --lib -- --ignored --test-threads=1 data_engine::live_tests::, on a one-nodemongo:7replica set: 24 passed. They include the 2tokentests of this branch and theupdate_windowtest of fix: answer UPDATING while an UpdateTable change applies #1093.cargo test -p extenddb-wasm-adapter: its 3 unit tests and theparitycorpus test pass.doc_version_literalspasses (3).--no-default-features --features sqlite) and 179 passed on PostgreSQL.pytest --collect-onlycollectstests/(7516 tests) andtests/python/(858 tests) with no error.What
This PR follows #416. It makes
TransactWriteItemsrank its key faults and theClientRequestTokenas the service does, on all four backends. It also keeps the token of a cancelled request as the service keeps it. The rules, as measured on the service:Putitem, and the type of anUpdate's literal operand. The first such fault in request order decides the answer, and the token stays unused.Updatecan supply that value as a literal or write it from the item. In one statement the literal comes first. A member whose condition fails writes nothing.IdempotentParameterMismatchException, and the backend does not apply it. The same request runs again.Updatepast 400 KB, an action that cannot apply, andTransactionConflict. Another request with the token gets the mismatch 570 seconds after the last cancellation, and the backend applies it 600 seconds after it. A cancellation of the same request sent again starts that time again. A committed token stays used as long, and the same request sent again 11 minutes after its commit runs again.TransactionInProgressException"Transaction from previous request is still in progress", or it waits and gets the answer of that send. The service applies such a request once.The changes:
transact_first_empty_literalinextenddb-storagefinds the firstUpdatemember with an empty literal. Each backend runs only the members before that member and puts the literal's reason at its position.resolve_key_faultsthen decides from the reasons, as before.transact_op_key_checksover every member before it checks the token.cancelled:. No request fingerprint has that prefix.StoredToken::oftells a replay, a rerun and a mismatch apart, and the schema does not change. Cassandra no longer deletes the token on these paths. It writes the cancelled token with an LWT, as it writes the token row everywhere else. The LWT updates the running row, or inserts a row if the running row expired during the send. The write has a TTL of 600 seconds. So the token stays used for 10 minutes from the last cancellation, as on the other backends.TransactionConflictafter the last attempt. If that write fails, the backend logs the failure, and the request still gets its cancellation.InternalServerError. Main dropped the transaction and answered the cancellation. Neither the items nor the token row change.running:and the fingerprint while a send runs, and the plain fingerprint after the send commits. Another send of the same request that reads a running row getsTransactionInProgressException. So does a send that loses the reservation or the take of the token. Before, such a send got a replay of a write that had not happened, or the mismatch. The newStorageError::TransactionInProgressmaps to that exception. The reservation and the take write the row with a TTL of 600 seconds. So a send that fails after them leaves its running row for 10 minutes.TransactionInProgressExceptioncarries its message under the keyMessage, as the service sends it (measured on 19 November 2026).message_keyincrates/core/src/error/mod.rspicksMessagefor it, as it does forTransactionCanceledExceptionandIdempotentParameterMismatchException.compute_fingerprintand the v1.2.0 entry of the upgrade manual.twi_conflicttests close a deadlock cycle through an outside transaction and expect PostgreSQL to abort the write transaction. PostgreSQL aborts the transaction whose deadlock check finds the cycle. Each waiter checks once,deadlock_timeoutafter it starts to wait. With the default on both sides, the check of the outside transaction could run first, so PostgreSQL aborted that transaction instead. One of the tests failed that way once in 54 runs of the file. The outside transaction now setsSET LOCAL deadlock_timeout = '5s', so the check of the write transaction runs first.On PostgreSQL, an empty literal on a later member makes the members before it run, and they lock their rows. If another transaction holds one of those rows, the request waits, as any member does. The wait ends when the holder commits or rolls back, or when the deadlock detector breaks a cycle. The backend sets no
lock_timeouton data transactions. When the literal is on the first member, the backend locks nothing.Why
Closes #852.
jcshepherd's review of #416 on 28 October asked for one ranking of these faults on every backend. #416 merged on 3 November with the ranking it had before that review. The issue gives the measurements and the answers of main at
25ee109bfon each backend. The measurements are from 30 October, 31 October, 1 November, 4 November and 5 November 2026, with each request or token sequence sent twice.The fix of #851 merged into this branch in #873.
Known differences
All four backends share the first four. This PR does not change the first three.
Actual: N, where the service lists a set of number types (Arithmetic on an index key: the type mismatch names N where the service names a set of types #702).GetItem,DeleteItem,UpdateItemandTransactGetItemsgetsType mismatch for key <attr> expected: <T> actual: <U>, where the service answers "The provided key element does not match the schema" (GetItem, DeleteItem, UpdateItem and TransactGetItems answer a wrong-typed key with the PutItem message #701).AttributeUpdatesparameter gets the update-expression wording, where the service uses thePutItemwording that names the index (UpdateItem: an empty secondary-index key sent through legacy AttributeUpdates gets the UpdateExpression wording on every backend #423).Updatethat grows an item past 400 KB gets the cancellation reason "Item size has exceeded the maximum allowed size". The service and SQLite answer "Item size to update has exceeded the maximum allowed size" (MongoDB applies no item size limit to updates, and Cassandra sizes updates on the finished item against a fixed 400 KiB with the PutItem wording #818, TransactWriteItems: updating a key attribute is a top-level ValidationException, and the item size reason text differs #761).Updatethat grows an item past 400 KB commits, where the service cancels it (MongoDB applies no item size limit to updates, and Cassandra sizes updates on the finished item against a fixed 400 KiB with the PutItem wording #818). The token file skips that case on MongoDB.TransactionConflict(MongoDB: a ClientRequestToken older than 10 minutes answers TransactionConflict until the TTL monitor removes its document #836). The backend then stores the cancelled token of that request over the old document. The same request sent again runs, and another request with the token gets the mismatch for 10 minutes.TransactionInProgressException, and another request the mismatch, until the row expires 10 minutes after the reservation or the take. Before this PR it got a replay of the write that did not happen (Cassandra: a TransactWriteItems sent again after a failure that applied nothing answers as a replay #837).TransactionConflictcancellation, where the service answersTransactionInProgressExceptionor the replay. Main answers the same (storage-postgres: the data path assumes READ COMMITTED and does not pin it; put_create_race fails under a repeatable read default #570). fix(storage-postgres): set READ COMMITTED on the server's and the stores' sessions #1340 (open) sets READ COMMITTED on every session of the pools.These answers of the service are not measured:
TransactionInProgressExceptionfor 10 minutes.Put50 ms apart both gotOKand wrote the items once, but the first send had very likely finished.Overlaps with other PRs
message_keyfromcrates/server/src/response.rstocrates/core/src/error/mod.rs, with main's comment that ExtendDB does not raiseTransactionInProgressException. The merge 62cea0c putsTransactionInProgressExceptionin the"Message"arm of the moved function and drops that sentence.message_key, now incrates/core/src/error/mod.rs, and keeps that sentence. It conflicts with this branch in that file and incrates/server/src/response_tests.rs, and so does fix(server): write __type first in an error body #1249 on its branch. Since 676cf8f it also conflicts in the upgrade manual, where both add a v1.2.0 entry after the v1.2.0 entries of main. The second to merge keeps this branch's arm, drops the sentence and keeps both entries.git merge-treecompared 6d3d448 and main with each of the 213 other open PRs. For fix(mongodb): retry an unconditional PutItem that conflicts on a GSI table #487, fix: answer requests during a table's DELETING window as the service does #550 and fix(engine): refuse a table name of a bad length before the lookup #1127 it used their merges of main at 1e2ebdd (b5af797, 3d882d0 and 059c6ca). This branch also conflicts with these open PRs in files where they do not conflict with main:crates/storage-postgres/src/data/transactions.rsandtx_helpers.rs.ConsumedCapacityof TransactWriteItems: thetransactions.rsfiles of the Cassandra, PostgreSQL and SQLite crates,crates/storage/src/lib.rsandcrates/storage/src/transact.rs.crates/storage-sqlite/src/data/transactions.rs.crates/engine/src/create_table.rs.crates/storage-mongodb/src/data_engine_live_tests.rs. fix(mongodb): retry an unconditional PutItem that conflicts on a GSI table #487 declares itsput_raceandcontentionmodules at the place where this branch declarestoken.TableNamein TransactGetItems and TransactWriteItems:crates/core/src/types/transaction.rs. This branch moves the tests of that file totransaction_tests.rs, and fix(core): ignore a top-level TableName in TransactGetItems and TransactWriteItems #1579 adds two tests to the test module in the file.docs/manuals/07-upgrade-manual.md. Each adds a v1.2.0 entry at the same place as this branch. The PR that merges second keeps both entries. 20 other open PRs conflict with this branch there and with main there too.Testing done
676cf8f merges main at db8a90d. These runs used 676cf8f on 3 December 2026, with Rust 1.97.0 and the dev profile:
cargo fmt --all -- --checkis clean. Both clippy commands of.github/workflows/clippy.ymlwith-D warningsare clean on the whole workspace.cargo +1.94.0 check --locked --all-targetson the eight crates that this PR changes is clean. 1.94.0 is the MSRV since fix(deps): move to sqlx 0.9.1 for the SQLite fix of RUSTSEC-2026-0459 #1166. The clippy step of.github/workflows/wasm.ymlis clean. This host has no clang, so that run used a stand-in C compiler and archiver for the bundled SQLite. Clippy does not link.backup_storeand two SQLite tests ofbackup_catalog::write_lock_tests. uid 65534 owns/local/home, and their filesystem checks refuse a directory under it.cargo test -p extenddb-wasm-adapter: its 3 unit tests and theparitycorpus test pass.doc_version_literalspasses (3).cargo test -p extenddb-storage-postgres --tests --no-fail-fastagainst PostgreSQL 16 with pgvector, withEXTENDDB_TEST_PG_REQUIRED=1: 508 passed and 2 ignored, andtwi_conflictpassed 16 of 16. Five tests that open a filesystem backup store fail for the same reason on/local/home: threestore_identitytests inbackup_restore.rsand two tests incatalog_nul_backup_jobs.rs.mongo:7replica set:data_engine::live_tests::passed 23 of 23. Every test target of the crate, as themongodb-rustjob runs it (--tests -- --skip snapshot_engine::withEXTENDDB_TEST_MONGODB_REQUIRED=1), gave 282 passed and 88 ignored.PasswordAuthenticator, as CI configures it: the 40 tests ofdirect_integrationwhose names holdtransact_write, built withtest-hooks, passed. They hold thetransact_write_items::andtransact_write_tokens::modules. The rest of the target did not run here. The Cassandra CI job runs all of it.tests/test_idempotency_account_scope.pyandtests/test_transact_token_return_fields.py, against servers built from 676cf8f: 211 passed on SQLite (--no-default-features --features sqlite) and 211 passed on PostgreSQL.pytest --collect-onlycollectstests/(7417 tests) andtests/python/(820 tests) with no error.62cea0c merges main at 3534c9e. On 62cea0c,
cargo fmt --checkis clean, and both clippy commands of.github/workflows/clippy.ymlwith-D warningsare clean on the whole workspace. The lib tests give core 1172 passed and 1 ignored, engine 891 passed and server 514 passed. On the test host, five server tests ofbackup_storefail, as on every branch, because uid 65534 owns/local/home. The four wire files of this PR and the token and transaction files of main listed below ran against a SQLite server built from 62cea0c. They gave 443 passed and 2 xfailed. The two xfails are main'sTRANSACTION_INDEX_UNITScases intests/test_partiql_transaction.py.tests/python/test_transactions.pygives 16 passed.pytest --collect-onlycollectstests/(6750 tests) andtests/python/(672 tests) with no error. The wasm32 steps of.github/workflows/wasm.ymlwere not run locally. The WebAssembly CI job runs them.c414410 merges main at 89fc971. The one new commit of main changes
crates/storage-mongodb/tests/migrations_guards.rs, which this PR does not change. On c414410,cargo fmt --checkis clean, andcargo clippy --all-targets -- -D warningswith the MongoDB test hooks is clean onextenddb-serverandextenddb-storage-mongodb.The runs below used 57f2e47, after the merge of main at 018715e. The lints and the lib tests ran again at 0958e28, the last commit of this round. That commit changes only a comment and the upgrade manual. Rust, on the eight crates that the PR changes:
cargo +1.97.0 fmt --all -- --check: clean.cargo +1.97.0 clippy --locked --all-targets -- -D warnings, with each feature set of.github/workflows/clippy.yml: clean.cargo +1.91.1 check --locked --all-targets(the MSRV): clean.cargo +1.97.0 test --locked --lib: core 1157 passed, engine 886, server 514, storage 288, SQLite 329, PostgreSQL 87, MongoDB 190 (87 ignored) and Cassandra 181. On the test host, five server tests ofbackup_storeand two SQLite tests ofbackup_catalog::write_lock_tests(storage-sqlite: the two write_lock_tests fail when an ancestor of the Cargo target directory is owned by another user #1414) fail. Their filesystem checks refuse a directory under an ancestor that neither root nor the test user owns. This PR does not change that code.twi_conflictagainst PostgreSQL 16 (CI'spgvector/pgvector:pg16image), withEXTENDDB_TEST_PG_REQUIRED=1, three runs: 16 of 16 passed in each run. Eight tests are new:a_cancelled_token_is_used_for_ten_minutes_from_its_last_cancellationmovescreated_atback to check the 10 minutes and their restart.a_conflict_cancellation_keeps_the_token_used_and_the_same_request_runs_againcancels a request with a token in a deadlock. Another request with the token then gets the mismatch, and the same request commits.a_deadlock_after_an_empty_index_key_answers_the_empty_keychecks that an empty key that a member writes from the item still decides when the next member deadlocks.an_empty_literal_first_answers_without_waiting_on_later_lockschecks that an empty literal on the first member answers while another transaction holds the next member's row.two_sends_of_one_request_with_one_token_apply_it_oncechecks that the second send gets the replay (PostgreSQL: two sends of one TransactWriteItems with one ClientRequestToken at the same moment can both apply #851).two_sends_that_run_a_cancelled_request_again_apply_it_oncechecks the replay for a cancelled request that two sends run again.two_requests_with_one_token_at_once_apply_only_onechecks that the second request gets the mismatch and applies nothing.two_sends_that_take_an_old_token_row_apply_it_oncechecks the replay when the two sends take a token row older than 10 minutes.data_engine::live_tests::against amongo:7replica set: 21 of 21 passed. Two of them are new, and they movecreated_atback. They check the restart of the 10 minutes and the replaced document.cassandra:4.1: thetransact_write_items::tests (8, as on main) and thetransact_write_tokens::tests (7, all new) passed 15 of 15. The token tests passed 7 of 7 in a second run of their own. They are intests/direct/transact_write_tokens.rsand its child moduletransact_write_tokens/concurrent_sends.rs:TransactionInProgressException. In five earlier runs of its own, 38 or 39 of the 40 answers were the cancellation and the othersTransactionInProgressException.Wire tests, the four files of this PR, against a local server built from 57f2e47:
tests/test_index_key_validation_on_update.py(64),tests/test_transact_index_key_cross_member.py(85),tests/test_transact_index_key_token.py(27) andtests/test_transact_write_conflict.py(3).--no-default-features --features sqlite): 179 passed.The skipped case is the
Updatepast 400 KB, which runs on SQLite and PostgreSQL only (#818, #761). In the runs of these files on 20 November and earlier, the xfailed case sends a cancelled request again with anotherReturnConsumedCapacity(#514). It passes since the merge of #526, and 57f2e47 deletes its xfail marker.The token and transaction files of main ran against the same two servers:
tests/test_transact_token_return_fields.py(23),tests/test_error_message_key.py(4),tests/test_partiql_transaction.py(203),tests/test_idempotency_account_scope.py(5),tests/test_transaction_operations.py(31) andtests/python/test_transactions.py(16). On SQLite and on MongoDB, 280 passed and 2 xfailed. The two xfailed cases are the index unit cases oftests/test_partiql_transaction.py, which carry an xfail marker in main's file.pytest --collect-onlycollectstests/(6750 tests) andtests/python/(672 tests) with no error.Before 20 November, at earlier heads of this branch, a local release server per backend gave these results. The new rows are in
tests/test_transact_index_key_cross_member.py(85 cases) and the newtests/test_transact_index_key_token.py(27 cases).25ee109bftest_index_key_validation_on_update.py, main at25ee109bfAt those heads,
tests/test_transaction_operations.py(31) andtests/python/test_transactions.py(16) passed on every backend. The 33 test files that cover index keys and transactions gave these results:tests/(26 files)tests/python/(7 files)Before 20 November, two clients sent one request with one token to a Cassandra server at the same moment. There were 10 rounds of first sends and 10 rounds of a cancelled request, in each of two runs. On this branch every answer was the cancellation or
TransactionInProgressException, and the item was never written. Main answeredOKfor that write in 1 to 8 of the 20 answers of a run, over three runs.Mutants, one at a time, and the tests that fail on each. The three that change a Cassandra TTL or the commit mark ran at the head of this branch before 20 November. The mutants with a plain INSERT, and with no write when the token row is gone, ran after the merge of main at
2ef56139e. The others ran before the rebase onto94b5f689b, which did not change the code they mutate. This round does not change the code that any of them mutates.StoredToken::ofgives the mismatch for a cancelled token of the same request:a_stored_token_is_a_replay_a_rerun_or_a_mismatch.test_a_token_a_cancelled_request_used.a_failed_token_write_keeps_the_cancellation.a_conflict_cancellation_keeps_the_token_used_and_the_same_request_runs_again.live_a_cancellation_keeps_the_token_used_from_its_last_cancellation.test_a_cancelled_token_row_expires_ten_minutes_after_its_last_cancellationandtest_idempotency_token_after_a_key_fault.test_a_cancelled_token_row_expires_ten_minutes_after_its_last_cancellation.test_a_cancellation_leaves_a_token_row_that_changed_while_the_send_ran.test_a_cancellation_leaves_a_token_row_that_changed_while_the_send_ran.==after a lost reservation, or gives a replay when the take loses:test_two_sends_of_one_request_answer_its_cancellation_or_in_progress.test_two_sends_of_one_request_answer_its_cancellation_or_in_progress.test_a_reserved_token_row_expires_ten_minutes_after_its_reservation.test_idempotency_token_replayandtest_a_committed_token_row_expires_ten_minutes_after_its_commit.test_a_committed_token_row_expires_ten_minutes_after_its_commit.This round's controls, on its own commits:
index_key_empty_messages_by_contextandan_empty_literal_on_an_index_key_is_refused_with_its_kind. The second test as it was before this round passes with that change, because it checked only the end of the message.StorageError::TransactionInProgressfailstransaction_in_progress_carries_the_service_message, a new engine test that checks the status, the error type and the message.Messagearm ofmessage_keyas main has it, withoutTransactionInProgressException, failsthe_message_key_follows_the_service_per_error. The body then has the keys__typeandmessage.Against Amazon DynamoDB: the three test files of this branch (
tests/test_index_key_validation_on_update.py,tests/test_transact_index_key_cross_member.pyandtests/test_transact_index_key_token.py) ran at 73d5b3e on 5 November 2026 in us-east-1, and 176 passed. Since then, these files changed only in 57f2e47, which deletes the xfail marker of one case. That marker applied only when the files ran against ExtendDB.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a. The change gives the answers that DynamoDB gives, and the token store keeps its schema. An older binary reads a cancelled token as a token that another request holds.
Breaking changes
cancelled:row, and on Cassandra arunning:row, as the token of another request. So after a downgrade, the same request answersIdempotentParameterMismatchExceptionuntil the token expires.By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.