fix: preserve operation order in TransactionWriteSet#255
Merged
ThePumpingLemma merged 1 commit intoJun 12, 2026
Merged
Conversation
polyatail
added a commit
to polyatail/tempest
that referenced
this pull request
Jun 11, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
TransactionWriteSet stored saves/puts/deletes/checks in separate sets and toTransactionWriteRequest emitted them grouped by kind (all saves, then puts, then deletes, then checks). DynamoDB returns a List<CancellationReason> that is positionally aligned with the submitted TransactWriteItems, so grouping by kind meant callers could not reliably map a cancellation reason back to the operation that triggered it once operations were interleaved across kinds. Track the caller's insertion order in TransactionWriteSet.Builder via a new WriteOperation sealed type, expose it as TransactionWriteSet.operations, and replay that order in both toTransactionWriteRequest and describeOperations. The field is populated in build() and kept out of the data class constructor to preserve the public equals/copy/destructuring signature; direct construction falls back to the historical save -> put -> delete -> check order. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0a00137 to
b2d30f3
Compare
ThePumpingLemma
approved these changes
Jun 12, 2026
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.
Fixes #254
Problem
TransactionWriteSetstores saves/puts/deletes/checks in four separate sets, andtoTransactionWriteRequestemits them grouped by kind — all saves, then puts, then deletes, then checks — regardless of the order the caller added them.DynamoDB returns a
List<CancellationReason>onTransactionCanceledExceptionthat is positionally aligned with theTransactWriteItemsin the submitted request. Because Tempest reorders the items by kind, a caller who interleaves operations (e.g.delete(B); save(A)) cannot reliably map a returned cancellation reason back to the operation that triggered it.Fix
WriteOperationsealed type (Save/Put/Delete/Check) and track the caller's insertion order inTransactionWriteSet.Builder.TransactionWriteSet.operations, populated inbuild(). It is kept out of the data class constructor to preserve the publicequals/copy/destructuring signature; direct construction falls back to the historical save → put → delete → check order.operationsin bothtoTransactionWriteRequest(covers the sync and async paths) anddescribeOperations, so the submitted request items — and the failure message — line up with the returned cancellation reasons.Builder.addAllnow replays the source builder'soperationsin order rather than re-adding bucket-by-bucket.Scoped to
tempest2(AWS SDK v2).Test plan
transactionWritePreservesOperationOrderAcrossKindsadds adeletebefore asaveand asserts bothTransactionWriteSet.operationsand the cancellation failure message reflect insertion order (Delete, Save) — fails under the old grouped behavior, passes now.LogicalDbTransactionTest,AsyncLogicalDbTransactionTest,WritingPagerTest, andAsyncWritingPagerTestpass.🤖 Generated with Claude Code