fix: marker_seen deletes commit with the wall change
A wall cause change (endpoint move, thickness/position, player_marker off, no longer window) committed the wall row in the FULL transaction while its marker_seen deletes rode the later NORMAL derived-memory transaction. A crash between them left the stale row, and restart restored the marker with the anchor recomputed from the NEW geometry, revealing a position the player never saw (DESIGN 5.8). updateWall now deletes the affected rows in the same FULL transaction as the replaced row, exactly as the composite FK cascade already does for wall.remove. The live del frames are unchanged and marker inserts stay in the derived transaction: wall+deletes commit, derived inserts, then ack. The marker cause signature moves to world.markerSig so the write-time delete and the online retraction cannot drift. Proof: a leakfault-only markerCrash hook quits between the wall commit and the derived write; tools/markers.test.mjs covers all four causes and restarts on a clean build, asserting no marker for the changed wall (no new anchor) and restoring the untouched window's marker as the positive control. Ref #60
This commit is contained in:
+12
-7
@@ -232,7 +232,8 @@ proc recordEncounters() =
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------
|
||||
# Derived player memory persistence: explored cells and player markers (DESIGN 4.2 step 6, 4.4, 5.8;
|
||||
# M3 slice 6 / #21, #59). Both live in memory and reach the DB only here. One rule: a mutation writes
|
||||
# M3 slice 6 / #21, #59). Both live in memory and reach the DB here, except a marker cause-change
|
||||
# delete, which `world.updateWall` commits with the wall row (5.8, #60). One rule: a mutation writes
|
||||
# exactly the explored chunks its refresh dirtied and the markers it minted, never the whole state,
|
||||
# and the write rides in the mutation's transaction so an ack cannot precede what it reports. NORMAL
|
||||
# durability (Q12): both are derived (explored only grows; a marker is minted and retracted by the
|
||||
@@ -254,8 +255,8 @@ proc persistMarkers(pids: openArray[int]) =
|
||||
## The marker half alone, for a connect where the explored grid must stay exactly as it was (a
|
||||
## schema-4/7 database rebuilds its grid on connect and stores nothing until a mutation): a marker
|
||||
## minted at the resync is still durable before it is sent (5.8, 4.2 step 6). The deletes run
|
||||
## before the inserts: a moved wall's old marker must be gone before its fresh one is stored, and
|
||||
## both are the same derived-memory transaction.
|
||||
## before the inserts: a moved wall's old rows are already gone (the wall transaction took them),
|
||||
## and a fresh one is stored after them, so one id can never be set and deleted in one refresh.
|
||||
for pid in pids:
|
||||
if pid == GmControlled: continue
|
||||
discard markers.writeDead(app.db, pid,
|
||||
@@ -264,10 +265,10 @@ proc persistMarkers(pids: openArray[int]) =
|
||||
app.visions.mgetOrPut(pid, PlayerVision()).markerFresh)
|
||||
|
||||
proc persistDerived(pids: openArray[int]) =
|
||||
## Writes the dirtied explored chunks and the markers the same refresh minted or retracted (5.8:
|
||||
## marker inserts and deletes are in the same derived-memory transaction as the explored chunks,
|
||||
## after the wall row commits). No transaction of its own: the caller wraps it together with the
|
||||
## mutation's row writes.
|
||||
## Writes the dirtied explored chunks and the markers the same refresh minted (5.8: marker inserts
|
||||
## ride the same derived-memory transaction as the explored chunks, after the wall row committed;
|
||||
## a cause-change delete already committed with that row). No transaction of its own: the caller
|
||||
## wraps it together with the mutation's row writes.
|
||||
let chunks = dirtyExplored(pids)
|
||||
if chunks.len > 0: discard explored.writeChunks(app.db, app.scene.id, chunks)
|
||||
persistMarkers(pids)
|
||||
@@ -2151,6 +2152,10 @@ proc dispatch(conn: Conn, env: Envelope) {.gcsafe.} =
|
||||
var mr = moveScene(app.scene, app.tokens)
|
||||
outcome = updateWall(app.db, app.scene, candidate.get)
|
||||
if outcome == waOk:
|
||||
when defined(leakfault):
|
||||
# LEAK_FAULT=markerCrash (TESTING 10.3, #60): die between the wall commit and the
|
||||
# derived-memory transaction, to prove the marker deletes commit with the wall row.
|
||||
if faultActive("markerCrash"): crashNow()
|
||||
let updated = wallById(app.scene, id)
|
||||
discard moverules.updateWall(mr, idx, ruleWall(updated.get))
|
||||
discard applyRuleOutcome(mr)
|
||||
|
||||
Reference in New Issue
Block a user