Root cause: auto-save BG task queued before logout could acquire bgLock and write a stale snapshot AFTER the logout BG task had committed fresh data + online=0. On reconnect, the stale inventory was restored while the dropped ItemEntity remained on the ground -> duplication. Three-layer guard applied to onPlayerSaveToFile and onLivingDeath BG tasks: 1. Early skip if pendingLogoutSaves contains the player (before tryLock) 2. Re-check pendingLogoutSaves after acquiring bgLock (race window) 3. SELECT online from player_data before write; skip if online=0 Logout BG task now acquires bgLock via .lock() (blocking) so concurrent auto-save / death-save tasks using tryLock either skip cleanly or wait. removePlayerLock reordered before bgLock.unlock so late auto-save BGs see containsKey=false and skip. |
||
|---|---|---|
| .. | ||
| main | ||