[GH-ISSUE #3882] World upgrade: DataVersion is stamped before chunks are converted, so a failed upgrade silently loses data #1126

Closed
opened 2026-11-02 15:44:28 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @ccclosed on GitHub (Oct 29, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3882

🤖 Filed by ccclosed's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by ccclosed personally.

Severity: High — silent world data loss on upgrade
Snapshot: origin/main 7c1e0f979 (2026-10-30)

What happens

Opening a pre-1.16 world stamps level.dat with the current DataVersion before the chunks/entities/data are converted. If the conversion stops on a bad chunk, the next open sees DataVersion == CURRENT, returns Ok, and never retries — the world is permanently a mix of a current level.dat and old-format chunks.

Where

  • crates/horizon-world/src/datafix/files.rs:591-633 — fix_world_files rewrites level.dat with DataVersion=CURRENT at the end (:629-631).
  • crates/horizon-world/src/datafix/files.rs:907-910 — upgrade_world = fix_world_files(base)? then upgrade_world_data(base)?.
  • crates/horizon-world/src/datafix/files.rs:790-829 — upgrade_world_data converts regions dimension by dimension and can fail halfway.
  • crates/horizon-client/src/save.rs:165 — upgrade_older_world calls upgrade_world.
  • On the next open, fix_world_files returns early at :597-600 (loaded >= CURRENT).

Repro

  1. Craft a world in the 1.16 layout with several region files where one chunk's payload is truncated/unreadable.
  2. Open it once: upgrade_world_data errors after fix_world_files already wrote DataVersion=CURRENT.
  3. Open it again: it returns Ok and no datafix runs.

Observed in a test fixture: level.dat said DataVersion=5023 while 2 586 of 5 023 chunks were still the old format.

Expected

Vanilla upgrades the chunks and only writes the new DataVersion once the whole world converted; a failed upgrade keeps the old DataVersion and retries on the next open.

Impact

A single unreadable chunk (old bug, disk error, interrupted download) permanently prevents the rest of the world from being upgraded, and nothing tells the player.

Suggested fix

Upgrade the data first, write DataVersion=CURRENT last (or write level.dat only after upgrade_world_data succeeds); on failure leave the old DataVersion so the next open retries.

Originally created by @ccclosed on GitHub (Oct 29, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3882 > 🤖 Filed by ccclosed's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by ccclosed personally. **Severity:** High — silent world data loss on upgrade **Snapshot:** `origin/main` `7c1e0f979` (2026-10-30) ### What happens Opening a pre-1.16 world stamps `level.dat` with the current `DataVersion` **before** the chunks/entities/data are converted. If the conversion stops on a bad chunk, the next open sees `DataVersion == CURRENT`, returns `Ok`, and never retries — the world is permanently a mix of a current `level.dat` and old-format chunks. ### Where - `crates/horizon-world/src/datafix/files.rs:591-633` — `fix_world_files` rewrites `level.dat` with `DataVersion=CURRENT` at the end (`:629-631`). - `crates/horizon-world/src/datafix/files.rs:907-910` — `upgrade_world` = `fix_world_files(base)?` **then** `upgrade_world_data(base)?`. - `crates/horizon-world/src/datafix/files.rs:790-829` — `upgrade_world_data` converts regions dimension by dimension and can fail halfway. - `crates/horizon-client/src/save.rs:165` — `upgrade_older_world` calls `upgrade_world`. - On the next open, `fix_world_files` returns early at `:597-600` (`loaded >= CURRENT`). ### Repro 1. Craft a world in the 1.16 layout with several region files where one chunk's payload is truncated/unreadable. 2. Open it once: `upgrade_world_data` errors after `fix_world_files` already wrote `DataVersion=CURRENT`. 3. Open it again: it returns `Ok` and no datafix runs. Observed in a test fixture: `level.dat` said `DataVersion=5023` while 2 586 of 5 023 chunks were still the old format. ### Expected Vanilla upgrades the chunks and only writes the new `DataVersion` once the whole world converted; a failed upgrade keeps the old `DataVersion` and retries on the next open. ### Impact A single unreadable chunk (old bug, disk error, interrupted download) permanently prevents the rest of the world from being upgraded, and nothing tells the player. ### Suggested fix Upgrade the data first, write `DataVersion=CURRENT` last (or write `level.dat` only after `upgrade_world_data` succeeds); on failure leave the old `DataVersion` so the next open retries.
Author
Owner

@WhyFovius commented on GitHub (Oct 29, 2026):

🤖 Agent: I'll take this one — reordering the upgrade so the chunks convert first and level.dat is stamped with the current DataVersion only after upgrade_world_data succeeds. /claim

<!-- gh-comment-id:6508927910 --> @WhyFovius commented on GitHub (Oct 29, 2026): 🤖 Agent: I'll take this one — reordering the upgrade so the chunks convert first and level.dat is stamped with the current DataVersion only after upgrade_world_data succeeds. /claim
Author
Owner

@WhyFovius commented on GitHub (Oct 29, 2026):

🤖 Agent: /unclaim — stopping for today before starting this one; the analysis is above if the next taker wants it (fix_world_files stamps level.dat at files.rs:629-631 before upgrade_world_data runs, so the stamp needs to move behind a successful chunk conversion).

<!-- gh-comment-id:6509632099 --> @WhyFovius commented on GitHub (Oct 29, 2026): 🤖 Agent: /unclaim — stopping for today before starting this one; the analysis is above if the next taker wants it (fix_world_files stamps level.dat at files.rs:629-631 before upgrade_world_data runs, so the stamp needs to move behind a successful chunk conversion).
Author
Owner

@WhyFovius commented on GitHub (Oct 30, 2026):

🤖 Agent: /claim — back to it now: the stamp moves behind a successful upgrade_world_data.

<!-- gh-comment-id:6518301712 --> @WhyFovius commented on GitHub (Oct 30, 2026): 🤖 Agent: /claim — back to it now: the stamp moves behind a successful upgrade_world_data.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 30, 2026):

🤖 Claims: refused, back to it now: the stamp moves behind a successful upgrade isn't understood here. Use /claim or /unclaim (the trusted reviewers: /unclaim @login). (asked by @WhyFovius)

<!-- gh-comment-id:6518304728 --> @github-actions[bot] commented on GitHub (Oct 30, 2026): 🤖 Claims: refused, `back to it now: the stamp moves behind a successful upgrade` isn't understood here. Use `/claim` or `/unclaim` (the trusted reviewers: `/unclaim @login`). (asked by @WhyFovius)
Author
Owner

@WhyFovius commented on GitHub (Oct 30, 2026):

🤖 Agent: Fix is up in #4286 — the stamp is held back and applied only after upgrade_world_data succeeds.

<!-- gh-comment-id:6518579449 --> @WhyFovius commented on GitHub (Oct 30, 2026): 🤖 Agent: Fix is up in #4286 — the stamp is held back and applied only after upgrade_world_data succeeds.
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#1126
No description provided.