Skip to content

MOS-15: Run each MOS message in one transaction - #20

Merged
timoruohomaki merged 1 commit into
masterfrom
feat/MOS-15-transactions
Nov 9, 2026
Merged

timoruohomaki merged 1 commit into
masterfrom
feat/MOS-15-transactions

Conversation

@timoruohomaki

Copy link
Copy Markdown
Contributor
  • repository.TxRunner: InTx(ctx, fn) commits fn's changes if it returns nil and discards them on error or panic; nested InTx is a savepoint. Embedded in Repository, so the contract suite covers it.
  • PostgreSQL: InTx via pgx.BeginFunc with a transaction-bound repository.
  • Memory store: InTx works on a deep snapshot swapped in on commit; a writer mutex serialises transactions with direct writes.
  • Service takes the Repository and handles roCreate/roReplace and story actions in one transaction each; events are published after commit. A failed NEW story action no longer leaves its auto-created RO.
  • Tests: transaction contract (commit, rollback on error and panic, restored order, isolation, direct writes, nesting), concurrent running order updates (one winner, others ErrVersionConflict), and half-failed roCreate leaving no rows on memory and PostgreSQL.
  • Docs: how to use InTx in services.

- repository.TxRunner: InTx(ctx, fn) commits fn's changes if it returns
  nil and discards them on error or panic; nested InTx is a savepoint.
  Embedded in Repository, so the contract suite covers it.
- PostgreSQL: InTx via pgx.BeginFunc with a transaction-bound repository.
- Memory store: InTx works on a deep snapshot swapped in on commit; a
  writer mutex serialises transactions with direct writes.
- Service takes the Repository and handles roCreate/roReplace and story
  actions in one transaction each; events are published after commit.
  A failed NEW story action no longer leaves its auto-created RO.
- Tests: transaction contract (commit, rollback on error and panic,
  restored order, isolation, direct writes, nesting), concurrent
  running order updates (one winner, others ErrVersionConflict), and
  half-failed roCreate leaving no rows on memory and PostgreSQL.
- Docs: how to use InTx in services.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@timoruohomaki
timoruohomaki merged commit 8c73954 into master Nov 9, 2026
3 checks passed
@timoruohomaki
timoruohomaki deleted the feat/MOS-15-transactions branch November 9, 2026 17:55
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.

1 participant