[GH-ISSUE #5024] Dedicated server: a second, stale player save after disconnect overwrites the correct one (position lost, inventory rolled back) #1523

Closed
opened 2026-11-02 15:47:41 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @sideswipe001 on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5024

Summary

When a player leaves a horizon-server dedicated server, their player file is sometimes written twice, about 2 seconds apart. The first write is correct. The second is an older snapshot of the player with no Pos tag, and it replaces the first. On the next join the player is placed at world spawn, and their inventory and stats are rolled back to an earlier point in the session.

It's intermittent: some logouts restore the player correctly, others put them at spawn.

Environment

  • Horizon release: Nightly 2026-10-30 · 1da354b
  • horizon-server running in a container (Pelican panel, Debian image), Linux x86-64
  • online_mode = true, joined with a vanilla 26.3 Java client (Fabric, client-side mods only)
  • World copied from a vanilla 26.3 dedicated server (vanilla layout, region-file-compression=deflate)

Steps to reproduce

f18320a4-5f44-4af7-818d-da89150baa03.dat.zip

  1. Start horizon-server with an existing vanilla 26.3 world.
  2. Join, play for a few minutes (move, pick up some items), and disconnect.
  3. Rejoin. Repeat steps 2 and 3 a few times.

Within a few logouts the player rejoins at world spawn instead of where they left.

Evidence

From one bad logout. The log shows a single disconnect:

[01:31:16] [Server thread/INFO]: GeoframPureblade lost connection: Disconnected
[01:31:16] [Server thread/INFO]: System chat: GeoframPureblade left the game

But world/players/data/<uuid>.dat was written twice:

01:31:16.646  f18320a4-….dat_old  7072 bytes   (first write, rotated to .dat_old)
01:31:18.446  f18320a4-….dat      7039 bytes   (second write, the one loaded on rejoin)

Decoding both files:

Field First save (01:31:16) Second save (01:31:18)
Pos [-687.4, 66.0, -184.2] missing
Dimension minecraft:overworld minecraft:overworld
Inventory 23 stacks, incl. string (slot 15) and rotten flesh (slot 17) 21 stacks, slots 15 and 17 empty
foodLevel / foodSaturationLevel 18 / 0.0 20 / 1.2
warden_spawn_tracker.ticks_since_last_warning 7031 1028
Rotation [-99.5, 5.1] [-2.3, 18.8]

The second save is consistently older than the first (lower warden tick counter, items picked up later are missing) and has no Pos, so the player is treated as having no saved position.

As far as I can tell from the source, lan::playerdata::save → store() always sets level.position, so player_tag() would always write Pos from that path. The Pos-less write must come from a different code path that serializes an out-of-date copy of the player after (or racing with) the leave save.

Impact

Beyond the position reset, this rolls back player inventories, which can silently lose items on a real server. Logging in at spawn instead of the logout spot can also put the player in danger.

Files

Both player files from the bad logout are attached: [attach f18320a4-5f44-4af7-818d-da89150baa03.dat and .dat_old].

Originally created by @sideswipe001 on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5024 # Summary When a player leaves a `horizon-server` dedicated server, their player file is sometimes written **twice**, about 2 seconds apart. The first write is correct. The second is an **older snapshot of the player with no `Pos` tag**, and it replaces the first. On the next join the player is placed at world spawn, and their inventory and stats are rolled back to an earlier point in the session. It's intermittent: some logouts restore the player correctly, others put them at spawn. ## Environment - Horizon release: Nightly 2026-10-30 · 1da354b - `horizon-server` running in a container (Pelican panel, Debian image), Linux x86-64 - `online_mode = true`, joined with a vanilla 26.3 Java client (Fabric, client-side mods only) - World copied from a vanilla 26.3 dedicated server (vanilla layout, `region-file-compression=deflate`) ## Steps to reproduce [f18320a4-5f44-4af7-818d-da89150baa03.dat.zip](https://github.com/user-attachments/files/34212555/f18320a4-5f44-4af7-818d-da89150baa03.dat.zip) 1. Start `horizon-server` with an existing vanilla 26.3 world. 2. Join, play for a few minutes (move, pick up some items), and disconnect. 3. Rejoin. Repeat steps 2 and 3 a few times. Within a few logouts the player rejoins at world spawn instead of where they left. ## Evidence From one bad logout. The log shows a single disconnect: ``` [01:31:16] [Server thread/INFO]: GeoframPureblade lost connection: Disconnected [01:31:16] [Server thread/INFO]: System chat: GeoframPureblade left the game ``` But `world/players/data/<uuid>.dat` was written twice: ``` 01:31:16.646 f18320a4-….dat_old 7072 bytes (first write, rotated to .dat_old) 01:31:18.446 f18320a4-….dat 7039 bytes (second write, the one loaded on rejoin) ``` Decoding both files: | Field | First save (01:31:16) | Second save (01:31:18) | |---|---|---| | `Pos` | `[-687.4, 66.0, -184.2]` | **missing** | | `Dimension` | `minecraft:overworld` | `minecraft:overworld` | | `Inventory` | 23 stacks, incl. string (slot 15) and rotten flesh (slot 17) | 21 stacks, **slots 15 and 17 empty** | | `foodLevel` / `foodSaturationLevel` | 18 / 0.0 | 20 / 1.2 | | `warden_spawn_tracker.ticks_since_last_warning` | 7031 | 1028 | | `Rotation` | `[-99.5, 5.1]` | `[-2.3, 18.8]` | The second save is consistently *older* than the first (lower warden tick counter, items picked up later are missing) and has no `Pos`, so the player is treated as having no saved position. As far as I can tell from the source, `lan::playerdata::save` → `store()` always sets `level.position`, so `player_tag()` would always write `Pos` from that path. The Pos-less write must come from a different code path that serializes an out-of-date copy of the player after (or racing with) the leave save. ## Impact Beyond the position reset, this rolls back player inventories, which can silently lose items on a real server. Logging in at spawn instead of the logout spot can also put the player in danger. ## Files Both player files from the bad logout are attached: [attach `f18320a4-5f44-4af7-818d-da89150baa03.dat` and `.dat_old`].
Author
Owner

@kacpherek commented on GitHub (Oct 31, 2026):

Fixed by #4866 (same bug as #4846): the dedicated server world save no longer rewrites player files with a stale player snapshot that has no Pos. Please retry on the next nightly and reopen with the version and logs/latest.log if players still lose their position.

<!-- gh-comment-id:6541527893 --> @kacpherek commented on GitHub (Oct 31, 2026): Fixed by #4866 (same bug as #4846): the dedicated server world save no longer rewrites player files with a stale player snapshot that has no Pos. Please retry on the next nightly and reopen with the version and logs/latest.log if players still lose their position.
Sign in to join this conversation.
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
horizon-rust/horizon#1523
No description provided.