Skip to content

feat(storage): add RunInSerializableTransaction for component catalog writes - #1416

Merged
andrzejfudro merged 1 commit into
mainfrom
feat/cms-storage-serializable-tx
Oct 30, 2026
Merged

andrzejfudro merged 1 commit into
mainfrom
feat/cms-storage-serializable-tx

Conversation

@andrzejfudro

@andrzejfudro andrzejfudro commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Replace TransactionRunner.RunInTransactionWithCommitTime with RunInSerializableTransaction, running multi-row invariant transactions at SERIALIZABLE isolation and returning the commit timestamp written to commit-time columns.
  • Add pgdb.RunInSerializableTx (internal/storage/postgres/pgdb/tx.go) using pgx.TxOptions{IsoLevel: pgx.Serializable} while keeping pgdb.RunInTx at default READ COMMITTED, implement postgres.Storage.RunInSerializableTransaction (internal/storage/postgres/storage.go) returning the transaction's SELECT now() timestamp in UTC, and route all dbstore.Store writes through RunInSerializableTransaction.

Assumptions

None — requirements were fully specified.

Testing

  • bazel test //internal/storage:storage_test //internal/storage/postgres:postgres_test //internal/storage/postgres/pgdb:pgdb_test //internal/storage/spanner:spanner_test //pkg/components/store/dbstore:dbstore_test

TAG=agy
CONV=5d43b8db-2f9c-4908-a311-376a2b7dfdf0

@andrzejfudro
andrzejfudro added this pull request to stack #1399 October 26, 2026 12:04

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for serializable transaction isolation in PostgreSQL to protect multi-row invariants in the component catalog, aligning its behavior with Spanner. It also refactors component snapshot decoding and payload unmarshaling into a shared internal/storage/data package. The review feedback focuses on improving robustness by adding defensive nil checks to prevent potential runtime panics in IsSerializableTransaction, DecodeComponentPayloads, FinalizeComponentRecord, and the transaction runner's clock function.

Comment thread internal/storage/isolation.go Resolved
Comment thread internal/storage/data/component.go Resolved
Comment thread internal/storage/data/component.go Resolved
Comment thread internal/storage/postgres/storage.go Resolved
@andrzejfudro
andrzejfudro removed this pull request from stack #1399 October 28, 2026 15:46
@andrzejfudro
andrzejfudro added this pull request to stack #1472 October 28, 2026 15:47
andrzejfudro added a commit that referenced this pull request Oct 29, 2026
…e contract

Document RunInTransactionWithCommitTime, ComponentRepository.WithReadOnlySnapshot,
and MockStorage.CommitTime in internal/storage/README.md, clarify the
storage.Storage requirements on NewSpannerStore, and align the PostgreSQL
RunInTransactionWithCommitTime stub comment with #1416.

TAG=agy
CONV=5d43b8db-2f9c-4908-a311-376a2b7dfdf0
@andrzejfudro
andrzejfudro force-pushed the feat/cms-storage-serializable-tx branch from 0f1336f to 2f8165a Compare October 29, 2026 15:49
@andrzejfudro andrzejfudro changed the title feat(storage): serializable CMS transactions, per-attempt commit timestamp, and shared component decoding feat(storage): add serializable transaction option and shared component decoding Oct 29, 2026
Base automatically changed from test/cms-dbstore-backend-neutral-tests to main October 30, 2026 06:44
@andrzejfudro
andrzejfudro force-pushed the feat/cms-storage-serializable-tx branch from 5823a27 to c8516ca Compare October 30, 2026 06:44
@andrzejfudro andrzejfudro changed the title feat(storage): add serializable transaction option and shared component decoding feat(storage): add RunInSerializableTransaction and shared component decoding Oct 30, 2026
@andrzejfudro andrzejfudro changed the title feat(storage): add RunInSerializableTransaction and shared component decoding feat(storage): add RunInSerializableTransaction for component catalog writes Oct 30, 2026
Replace TransactionRunner.RunInTransactionWithCommitTime with
RunInSerializableTransaction so multi-row component catalog invariants run
at SERIALIZABLE isolation while default RunInTransaction stays at READ
COMMITTED on PostgreSQL. Add pgdb.RunInSerializableTx, implement
postgres.Storage.RunInSerializableTransaction returning SELECT now() in
UTC, and route dbstore.Store writes through RunInSerializableTransaction.

TAG=agy
CONV=5d43b8db-2f9c-4908-a311-376a2b7dfdf0
@andrzejfudro
andrzejfudro force-pushed the feat/cms-storage-serializable-tx branch from 39b662d to f434063 Compare October 30, 2026 09:14
@andrzejfudro
andrzejfudro marked this pull request as ready for review October 30, 2026 09:15
@andrzejfudro
andrzejfudro added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit c982cb7 Oct 30, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants