[PR #2486] [MERGED] parity: stop harnesses on SIGTERM, and reap orphaned harness JVMs #4361

Closed
opened 2026-11-03 04:16:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/parity-reap-orphans


📝 Commits (1)

  • 3755bb7 parity: stop harnesses on SIGTERM, and reap orphaned harness JVMs

📊 Changes

3 files changed (+52 additions, -8 deletions)

View changed files

📝 docs/release-flow.md (+4 -1)
📝 tools/ci/runner-gc.sh (+23 -0)
📝 tools/parity.py (+25 -7)

📄 Description

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

What

  • tools/parity.py: SIGTERM and SIGHUP now exit through its finally blocks.
    • Those blocks now also stop the local harnesses, not only the remote hosts'.
    • --worker stops its harnesses the same way.
  • tools/ci/runner-gc.sh (launchd, every 6 h) now stops orphaned harness JVMs (vanilla servers, oracles) once they are ORPHAN_HOURS old (default 3). It only stops a JVM when both hold:
    • its parent is gone (launchd, init or systemd --user adopted it);
    • its command line names a runner's checkout ($RUNNERS/*/_work/) or a worktree's .local/.
  • docs/release-flow.md is updated.

Why

The orchestrator found nine vanilla servers orphaned for 2 to 5 days on the Mac mini (2 GB heap each). Every harness runs in its own session, so killpg can stop it on a timeout. But when a CI job is cancelled (a new push, or parity-main's newer run), the runner signals parity.py. parity.py then died without stopping those sessions, and the harnesses and their servers lived on.

Tested

Signal handling. I added a temporary harness that starts sleep and waits, ran parity.py zzorphan -j 1, and sent kill -TERM to parity.py:

Version parity.py exit Harness and its child afterwards
Old (main) 143 both still running (orphaned)
New 143 both gone

runner-gc.sh. I started two fake orphans (parent pid 1), then ran it with RUNNERS=<empty temp dir> ORPHAN_HOURS=0:

  • the one whose command line held .claude/worktrees/zz/.local/server.jar was stopped;
  • the one under /tmp/unrelated was left alone;
  • the script exited 0.

shellcheck is clean apart from an existing SC2012 info. python3 -m unittest tests.test_parity_runner: OK.

After merge: the Mac mini's launchd copy needs refreshing (the curl line in docs/release-flow.md).

🤖 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/2486 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/parity-reap-orphans` --- ### 📝 Commits (1) - [`3755bb7`](https://github.com/horizon-rust/horizon/commit/3755bb7d7763a38c5b81900abba45510212a28ae) parity: stop harnesses on SIGTERM, and reap orphaned harness JVMs ### 📊 Changes **3 files changed** (+52 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `docs/release-flow.md` (+4 -1) 📝 `tools/ci/runner-gc.sh` (+23 -0) 📝 `tools/parity.py` (+25 -7) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What - **`tools/parity.py`:** SIGTERM and SIGHUP now exit through its `finally` blocks. - Those blocks now also stop the local harnesses, not only the remote hosts'. - `--worker` stops its harnesses the same way. - **`tools/ci/runner-gc.sh`** (launchd, every 6 h) now stops orphaned harness JVMs (vanilla servers, oracles) once they are `ORPHAN_HOURS` old (default 3). It only stops a JVM when both hold: - its parent is gone (launchd, init or `systemd --user` adopted it); - its command line names a runner's checkout (`$RUNNERS/*/_work/`) or a worktree's `.local/`. - `docs/release-flow.md` is updated. ## Why The orchestrator found nine vanilla servers orphaned for 2 to 5 days on the Mac mini (2 GB heap each). Every harness runs in its own session, so `killpg` can stop it on a timeout. But when a CI job is cancelled (a new push, or parity-main's newer run), the runner signals `parity.py`. `parity.py` then died without stopping those sessions, and the harnesses and their servers lived on. ## Tested **Signal handling.** I added a temporary harness that starts `sleep` and waits, ran `parity.py zzorphan -j 1`, and sent `kill -TERM` to parity.py: | Version | parity.py exit | Harness and its child afterwards | |---|---|---| | Old (main) | 143 | both still running (orphaned) | | New | 143 | both gone | **runner-gc.sh.** I started two fake orphans (parent pid 1), then ran it with `RUNNERS=<empty temp dir> ORPHAN_HOURS=0`: - the one whose command line held `.claude/worktrees/zz/.local/server.jar` was stopped; - the one under `/tmp/unrelated` was left alone; - the script exited 0. `shellcheck` is clean apart from an existing SC2012 info. `python3 -m unittest tests.test_parity_runner`: OK. **After merge:** the Mac mini's launchd copy needs refreshing (the `curl` line in docs/release-flow.md). 🤖 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 04:16:37 +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#4361
No description provided.