Commit 533be70
fix(persistence): always route mutations through coordinator to prevent seq collisions
The leader tab had two mutation paths: a "direct" path (write to SQLite
and broadcast) and an RPC path (through the coordinator). Previously,
only follower tabs used the RPC path — the leader bypassed the
coordinator and wrote directly.
This caused a seq collision: the leader's direct writes incremented the
runtime's `localSeq` but left the coordinator's `state.latestSeq` at 0.
When a follower later sent an RPC, the coordinator assigned seq starting
from 1 again, producing duplicate seq numbers. The leader then skipped
these "already-seen" tx:committed messages, causing follower mutations
to silently disappear.
Fix: Always route through `requestApplyLocalMutations` when available,
regardless of leader/follower status. This keeps the coordinator's seq
counter in sync with all writes.
Also removes `requestApplyLocalMutations` from `SingleProcessCoordinator`
— it was a stub that returned success without persisting, which would
break now that the leader uses this path. Single-process mode correctly
falls back to the direct path since it has no multi-tab coordination.
Co-Authored-By: Claude Opus 4.6 <[email protected]>1 parent 5163087 commit 533be70
1 file changed
Lines changed: 9 additions & 19 deletions
Lines changed: 9 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | 409 | | |
425 | 410 | | |
426 | 411 | | |
| |||
1321 | 1306 | | |
1322 | 1307 | | |
1323 | 1308 | | |
1324 | | - | |
1325 | | - | |
1326 | | - | |
1327 | | - | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
1328 | 1316 | | |
1329 | 1317 | | |
1330 | 1318 | | |
| |||
1368 | 1356 | | |
1369 | 1357 | | |
1370 | 1358 | | |
| 1359 | + | |
| 1360 | + | |
1371 | 1361 | | |
1372 | 1362 | | |
1373 | 1363 | | |
| |||
0 commit comments