Stale autosave can overwrite a logout/admin save (cross-channel write race) #44
Labels
No labels
bug
ci-cd
client
epic:security-hardening
feature
optimization
priority:high
priority:low
priority:medium
server
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
BlackLobster/Server#44
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Two uncoordinated channels persist the same profile row:
Persistence.enqueue_save_all/1(5-min:autosave) snapshots state and enqueues onDatabase.Pipeline(per-profile_idFIFO + dedupe).Persistence.save_all/1fromGame.Entity.Player.terminate/2(logout) andsave_skills/1from admin commands, written directly (not through the pipeline).The pipeline's dedupe/FIFO only orders writes within the queue, so a stale autosave job can run after a newer synchronous write:
terminate/2writessave_allsynchronously (newer data).Fix options
profile_idbefore the synchronous write, orAcceptance
Refs:
lib/black_lobster/game/entity/player/persistence.ex(save_all,enqueue_save_all),lib/black_lobster/game/entity/player.ex(terminate/2),lib/black_lobster/database/pipeline/*.Part of the Security & Data-Integrity Hardening epic.