Skip to content

Dispatch nested transaction updates to the enclosing transaction - #3868

Closed
chiliec wants to merge 1 commit into
simolus3:developfrom
chiliec:fix-nested-transaction-stream-updates
Closed

chiliec wants to merge 1 commit into
simolus3:developfrom
chiliec:fix-nested-transaction-stream-updates

Conversation

@chiliec

@chiliec chiliec commented Sep 23, 2026

Copy link
Copy Markdown

Fixes #3867.

transaction() resolves the enclosing engine (resolved), but then created the Transaction with this as its parent. For a nested transaction this meant the inner _TransactionStreamStore dispatched its table updates straight to the top-level stream store when the savepoint was released, while the outer transaction was still open. With a single connection the re-run query happens to wait for the outer transaction, so the bug was masked; with MultiExecutor the read connection re-runs the query before the outer commit, sees old data, and the stream is never notified again.

Passing resolved as the parent routes nested updates into the enclosing transaction's store, so they reach the top-level streams after the outermost transaction completes, as documented.

Tests

  • Added nested transactions notify about table updates after the outer transaction to test/database/transactions_test.dart. It fails before the change (top-level handleTableUpdates is called while the outer transaction is still open) and passes after.
  • Also ran the issue's standalone MultiExecutor + NativeDatabase (WAL) repro locally: FAILS: read pool + nested transaction fails before the change and passes after; the other two cases pass both ways. I didn't commit that file.

Validation (Dart 3.13.4)

  • dart test test/database/transactions_test.dart: 18/18 pass
  • dart test test/database test/engines test/integration_tests test/isolate_test.dart: 741 pass, 4 skipped
  • dart format --set-exit-if-changed and dart analyze --fatal-infos on the changed files: clean

I resolved the workspace without the Flutter packages because there's no Flutter SDK on my machine, so I haven't run the Flutter-dependent packages' tests.

@simolus3

Copy link
Copy Markdown
Owner

Merged in 2a825ba, thanks for the contribution!

@simolus3 simolus3 closed this Sep 23, 2026
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.

.watch not emitting in nested transactions when using MultiExecutor

2 participants