Commit 805dc7a
committed
feat(rivetkit): isolate includeState transaction reads with a committed snapshot
An includeState state transaction mutated actor state in place, so a
concurrent action reading state mid-transaction observed the owner's
uncommitted writes (a dirty read); the writes only reverted on rollback. That
gave atomic commit but not read isolation.
Take a structured-clone snapshot of the committed state when the transaction
opens. The transaction owner keeps mutating the live state (so commit/rollback,
onStateChange, and retained-proxy semantics are unchanged), but every non-owner
context — actions, runtime save ticks, the inspector, sleep saves — reads the
snapshot instead. Concurrent readers therefore observe only committed values
until the owner commits, and a save driven from a non-owner context can no
longer serialize uncommitted state. The snapshot is torn down on transaction
exit.
Note: the driver-suite state-transaction tests require the native engine and
could not be run in this environment (they fail identically on unmodified
main); validated by typecheck, the mock-provider unit tests, and review.1 parent 49693dc commit 805dc7a
4 files changed
Lines changed: 68 additions & 4 deletions
File tree
- rivetkit-typescript/packages/rivetkit
- fixtures/driver-test-suite
- src
- common/database
- registry
- tests/driver
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| 403 | + | |
403 | 404 | | |
404 | 405 | | |
405 | 406 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
Lines changed: 32 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
304 | 309 | | |
305 | 310 | | |
306 | 311 | | |
| |||
3114 | 3119 | | |
3115 | 3120 | | |
3116 | 3121 | | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
3117 | 3134 | | |
3118 | 3135 | | |
3119 | | - | |
3120 | | - | |
3121 | | - | |
| 3136 | + | |
3122 | 3137 | | |
3123 | 3138 | | |
3124 | 3139 | | |
| |||
3152 | 3167 | | |
3153 | 3168 | | |
3154 | 3169 | | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
3155 | 3173 | | |
3156 | 3174 | | |
3157 | 3175 | | |
| |||
3467 | 3485 | | |
3468 | 3486 | | |
3469 | 3487 | | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
3470 | 3499 | | |
3471 | 3500 | | |
3472 | 3501 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
825 | 825 | | |
826 | 826 | | |
827 | 827 | | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
828 | 860 | | |
829 | 861 | | |
830 | 862 | | |
| |||
0 commit comments