Photon Server Room Persistence and Client Rejoin Interoperability After Version Upgrade
0 reputation · 15 Feb 2021, 04:25 UTC
0 reputation · 15 Feb 2021, 04:25 UTC
This question examines the interoperability of Photon Server room persistence and client-side rejoining following a version upgrade. The LoadBalancing client API provides RejoinAndReconnect() methods intended to restore prior room context, while room persistence stores the latest room state on the server and cached events (lastN) are retained when RoomOptions.CleanupToRoom defaults to preserve recent action history. The precise conditions under which cached events are cleared or preserved during a server version transition remain undocumented, creating risk for clients that depend on state continuity after upgrade. Version assumptions around major and minor Photon Server releases, combined with the Persistence flag configuration, influence whether the rejoin flow successfully restores expected room properties or encounters missing or stale data. Given the interplay between CleanupToRoom, MaxPlayers, and server restart behavior, the integration boundary between server persistence and client rejoin logic requires clarification.
Under what conditions does the server clear cached events during a version upgrade? How does this interact with RoomOptions.CleanupToRoom and the Persistence flag? Does RejoinAndReconnect() reliably restore room state when cached events are lost?
34775 reputation · 15 Feb 2021, 14:51 UTC
The server clears cached events (the lastN history) only when the persisted room state cannot be read or when persistence is disabled. This happens in two scenarios:
When CleanupToRoom is true (the default), the server removes a room’s persisted state as soon as the last player leaves. If persistence is disabled or the persisted data is unreadable, the cleanup simply removes the in‑memory room object, which also drops the cached events. If CleanupToRoom is false, the room remains in the persistence store after it empties, preserving the cached events until the next server start or a successful migration.
RejoinAndReconnect() will restore the room’s properties and player list only if the server successfully loads the persisted room state. When cached events are lost because of the scenarios above, the client receives a successful rejoin event but the lastN buffer is empty or contains only events that occurred after the rejoin. Gameplay logic that depends on recent history must therefore resynchronize (e.g., by requesting a full state snapshot) after rejoining.
RoomOptions.Persistence is true and note the provider (SQLite, MySQL, custom).RejoinAndReconnect() on a known room ID; verify that the client receives a OnRejoinedRoom callback and that room properties match the pre‑upgrade values.To give a definitive recommendation, we need to know: Is persistence enabled, and which persistence provider are you using? If persistence is disabled, the only solution is to enable it or accept that cached events will not survive upgrades; if persistence is enabled, the migration procedure above applies.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 15 Feb 2021, 09:38 UTC
When the Photon Server process restarts for an upgrade, it reloads persisted rooms only if they are still considered active. A room remains active after its last player leaves when either RoomOptions.PlayerTtl > 0 (the room stays in memory for that period) or RoomOptions.EmptyRoomTtl > 0 (the persisted snapshot is kept). If both timers have expired, the server treats the room as abandoned, discards its persisted state and the cached lastN events, even when Persistence is true and CleanupToRoom is false. Thus, event preservation across upgrades depends on these TTL settings as well as the persistence flag and CleanupToRoom.