fix(gameserver): stamp save blobs to prevent a periodic write rolling back a disconnect save #96

Merged
marco merged 1 commit from fix/persistence-lost-update into main 2026-07-19 13:37:37 +02:00
Owner

Code-review finding bug-1 (integrity).

The periodic snapshot captures every online player's blob (SerializeOnlinePlayers) then writes them to the store in a later step; a disconnect that lands in between writes a fresher blob that the stale periodic write could then overwrite — silently rolling the session back on next login (PlayerStore was last-writer-wins with no recency ordering).

Stamp each blob with its capture tick (World.CurrentTick, read on the sim thread in the same InvokeAsync as the serialize). PlayerStore.SaveAsync now drops a save whose stamp is older than the one already stored, so the later-captured blob wins regardless of the off-thread write order.

Test: PlayerStore_DropsAnOlderStampedSave — a fresh (stamp 10) save survives a subsequent stale (stamp 5) write.

Definition of Done

  • A disconnect save is never overwritten by a concurrently-running periodic snapshot captured earlier.
  • Suite green (158 GameServer), zero warnings.
Code-review finding **bug-1** (integrity). The periodic snapshot captures every online player's blob (`SerializeOnlinePlayers`) then writes them to the store in a **later** step; a disconnect that lands in between writes a **fresher** blob that the stale periodic write could then overwrite — silently rolling the session back on next login (`PlayerStore` was last-writer-wins with no recency ordering). Stamp each blob with its **capture tick** (`World.CurrentTick`, read on the sim thread in the same `InvokeAsync` as the serialize). `PlayerStore.SaveAsync` now **drops a save whose stamp is older** than the one already stored, so the later-captured blob wins regardless of the off-thread write order. Test: `PlayerStore_DropsAnOlderStampedSave` — a fresh (stamp 10) save survives a subsequent stale (stamp 5) write. ## Definition of Done - [ ] A disconnect save is never overwritten by a concurrently-running periodic snapshot captured earlier. - [ ] Suite green (158 GameServer), zero warnings.
fix(gameserver): stamp save blobs so a stale periodic write can't roll back a disconnect save
All checks were successful
ci / Lint & Test (pull_request) Successful in 2m57s
6eb9d1167e
The periodic snapshot captures every online player's blob, then writes them to the
store in a later step; a disconnect that lands in between writes a fresher blob that
the stale periodic write could then overwrite, silently rolling the session back on
next login. Stamp each blob with its capture tick (World.CurrentTick); PlayerStore
drops a save whose stamp is older than the one already stored, so the later-captured
blob always wins regardless of write order.

Review finding bug-1. Test: an older-stamped save does not overwrite a newer one.
marco merged commit eb57163fb1 into main 2026-07-19 13:37:37 +02:00
marco deleted branch fix/persistence-lost-update 2026-07-19 13:37:38 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marco/IsoMmo!96
No description provided.