[PR #1121] [MERGED] Release the session lock before closing it (DirectoryLock.close); fixes the world-deletion test flakes #3067

Closed
opened 2026-11-02 16:01:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/session-lock-release


📝 Commits (1)

  • 782d93b Release the session lock before closing it, as DirectoryLock.close does

📊 Changes

1 file changed (+22 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/save.rs (+22 -1)

📄 Description

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

What

SessionLock now releases its file lock before the file closes, as vanilla's DirectoryLock.close releases the FileLock before closing the channel.

Why (#749)

session.lock is held with flock. Closing the file releases the lock only when every copy of the descriptor is gone, and a process spawned on another thread holds a copy until it execs. cargo test -p horizon-client spawns processes in parallel tests (crash reports run uname/sw_vers), so deleting a world right after drop(open) could fail with "already open in another instance": title::tests::delete_refuses_an_open_world_then_removes_it_with_its_lock (title/tests.rs:643) and front::tests::horizon_world_delete_confirms_and_keeps_the_selection_in_place, both on a loaded Mac mini.

How

impl Drop for SessionLock calls File::unlock. New test session_lock_releases_while_a_descriptor_copy_lives keeps a try_clone of the lock's file (what a spawned child holds) and checks that the world can be locked again after the drop. It fails without the fix (checked by commenting the unlock out) and passes with it.

Fixes #749

Self-check (Mac mini, one integration commit of the five Q1 PRs on origin/main 2d586fac)

  • cargo fmt --all --check: clean
  • set -o pipefail; cargo clippy --workspace --all-targets -- -D warnings: clean (no warnings, no errors)
  • cargo test -p horizon-client: lib 962 passed (14 ignored), main 84 passed, horizon-ctl 15 passed, integration tests 7 passed
  • tools/parity.py --changed origin/main: all 101 affected harnesses pass (secure_chat failed once in the batch run, which reused cached oracle results, then passed when rerun alone)

Needs Ludovic

Nothing.

🤖 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/1121 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/session-lock-release` --- ### 📝 Commits (1) - [`782d93b`](https://github.com/horizon-rust/horizon/commit/782d93bf996413f15328fdaef54ad8f84a7b8efe) Release the session lock before closing it, as DirectoryLock.close does ### 📊 Changes **1 file changed** (+22 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/save.rs` (+22 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `SessionLock` now releases its file lock before the file closes, as vanilla's `DirectoryLock.close` releases the `FileLock` before closing the channel. ## Why (#749) `session.lock` is held with `flock`. Closing the file releases the lock only when every copy of the descriptor is gone, and a process spawned on another thread holds a copy until it execs. `cargo test -p horizon-client` spawns processes in parallel tests (crash reports run `uname`/`sw_vers`), so deleting a world right after `drop(open)` could fail with "already open in another instance": `title::tests::delete_refuses_an_open_world_then_removes_it_with_its_lock` (title/tests.rs:643) and `front::tests::horizon_world_delete_confirms_and_keeps_the_selection_in_place`, both on a loaded Mac mini. ## How `impl Drop for SessionLock` calls `File::unlock`. New test `session_lock_releases_while_a_descriptor_copy_lives` keeps a `try_clone` of the lock's file (what a spawned child holds) and checks that the world can be locked again after the drop. It fails without the fix (checked by commenting the unlock out) and passes with it. Fixes #749 ## Self-check (Mac mini, one integration commit of the five Q1 PRs on origin/main 2d586fac) - `cargo fmt --all --check`: clean - `set -o pipefail; cargo clippy --workspace --all-targets -- -D warnings`: clean (no warnings, no errors) - `cargo test -p horizon-client`: lib 962 passed (14 ignored), main 84 passed, horizon-ctl 15 passed, integration tests 7 passed - `tools/parity.py --changed origin/main`: all 101 affected harnesses pass (secure_chat failed once in the batch run, which reused cached oracle results, then passed when rerun alone) ## Needs Ludovic Nothing. 🤖 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-02 16:01:15 +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#3067
No description provided.