[PR #4726] [MERGED] Saves: a thread the system refuses no longer stops the region writer #5809

Closed
opened 2026-11-03 05:15:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4726
Author: @ludovic111
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @ludovic111

Base: main ← Head: fix/region-writer-thread-limit


📝 Commits (1)

  • c3c2ffc Saves: a thread the system refuses no longer stops the region writer

📊 Changes

1 file changed (+54 additions, -21 deletions)

View changed files

📝 crates/horizon-client/src/save.rs (+54 -21)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

The region writer shares a batch's compression out to helper threads. A helper the system refuses to start no longer panics: the other threads take its share, and the writer thread now takes chunks too. At worst, the writer does the whole batch alone.

The total stays the same: helpers - 1 threads plus the writer (before: helpers threads while the writer waited).

Why

Official server, tonight at 21:50Z:

[horizon-region-writer/ERROR]: ... panicked at .../std/src/thread/scoped.rs:206:46:
failed to spawn thread: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }
  • thread::scope's spawn panics when the system refuses a thread (EAGAIN: the container was at its limit of threads).
  • That panic stopped the writer, so for four minutes every save failed (failed to save unloaded chunks: the region writer stopped).
  • Then the server stopped with "Fatal error: the region writer stopped" and restarted. Chunks unloaded in those four minutes were not saved.

Why the container ran out of threads is a separate question (it ran ~70 players with heavy churn while an operator spawned lightning, TNT and end crystals). I'm measuring it next. Whatever the cause, a refused thread must never cost the world's saves.

Test

work_shared_out_is_all_done_in_order_when_no_helper_can_start: every helper refused, some refused, all started, and no work. Each case does all the work, in order. records_compressed_on_helpers_match_one_thread_in_order still passes.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at b0cd39103, 10 min 24 s)

Check Result
Scope ✅ 1 files, +54 −21
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 481 passed (3 min 17 s)
rustfmt ✅ (7 s)
clippy ✅ (3 min 20 s)
tests: horizon-client ✅ 1177 passed (1 min 55 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 56 affected, to run in CI (--quick): arrow, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server, dispenser, entity_components, entity_death_loot, entity_model and 44 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4726 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/region-writer-thread-limit` --- ### 📝 Commits (1) - [`c3c2ffc`](https://github.com/horizon-rust/horizon/commit/c3c2ffc43eb2583fb44adb4dafd1eaec349cfa1c) Saves: a thread the system refuses no longer stops the region writer ### 📊 Changes **1 file changed** (+54 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/save.rs` (+54 -21) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What The region writer shares a batch's compression out to helper threads. A helper the system refuses to start no longer panics: the other threads take its share, and the writer thread now takes chunks too. At worst, the writer does the whole batch alone. The total stays the same: `helpers - 1` threads plus the writer (before: `helpers` threads while the writer waited). ## Why Official server, tonight at 21:50Z: ``` [horizon-region-writer/ERROR]: ... panicked at .../std/src/thread/scoped.rs:206:46: failed to spawn thread: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" } ``` - `thread::scope`'s `spawn` panics when the system refuses a thread (EAGAIN: the container was at its limit of threads). - That panic stopped the writer, so for four minutes every save failed (`failed to save unloaded chunks: the region writer stopped`). - Then the server stopped with "Fatal error: the region writer stopped" and restarted. Chunks unloaded in those four minutes were not saved. Why the container ran out of threads is a separate question (it ran ~70 players with heavy churn while an operator spawned lightning, TNT and end crystals). I'm measuring it next. Whatever the cause, a refused thread must never cost the world's saves. ## Test `work_shared_out_is_all_done_in_order_when_no_helper_can_start`: every helper refused, some refused, all started, and no work. Each case does all the work, in order. `records_compressed_on_helpers_match_one_thread_in_order` still passes. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at b0cd39103, 10 min 24 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +54 −21 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 481 passed (3 min 17 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (3 min 20 s) | | tests: horizon-client | ✅ 1177 passed (1 min 55 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 56 affected, to run in CI (--quick): arrow, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server, dispenser, entity_components, entity_death_loot, entity_model and 44 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:08 +07:00
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#5809
No description provided.