PlayerSync/src/main
laforetbrut 8f40d5b27f Fix critical cross-server duplication race + memory leak + atomic saves
CRITICAL FIX - Stale server overwrite prevention:
- writeSnapshotToDB now guards ALL writes with AND last_server=? so a
  crashing/slow server cannot overwrite fresher data saved by another server
- Logout and shutdown saves atomically set online=0 in the SAME UPDATE as
  the data write (no more gap between data write and flag set)
- ModCompatSync.writeModSnapshot guarded variant uses subquery on last_server

CRITICAL FIX - Poll loop actually waits now:
- onPlayerLoggedInKickCheck no longer sets last_server (only online=1)
- last_server is claimed AFTER the poll in doPlayerJoin completes
- This allows the poll to correctly detect and wait for the old server's
  async save to finish before reading data
- Poll increased from 30 to 60 attempts (30s window)

Memory leak fix:
- Added removePlayerLock() in doPlayerJoin's outer catch block to prevent
  unbounded growth of playerLocks ConcurrentHashMap on exceptions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:47:38 +02:00
..
java/vip/fubuki/playersync Fix critical cross-server duplication race + memory leak + atomic saves 2026-04-05 07:47:38 +02:00
resources add cobblemon support(in test) 2025-12-15 22:47:47 +08:00
templates add cobblemon support(in test) 2025-12-15 22:47:47 +08:00