Skip to content

Flaky test: runtime_chat_relay failed_state_writes…exact_retry_reopens fails under CI parallel load (owner-lock conflict) #5735

Description

@Hmbown

Sibling to #5605 (same class: full-suite/parallel-load flake).

Observed: Safety gate on PRs #5730 and #5734 (2026-08-30, within minutes of each other, same code shape as main) failed on runtime_chat_relay::tests::failed_state_writes_never_become_in_memory_authority_and_exact_retry_reopens:

panicked at crates/tui/src/runtime_chat_relay.rs:1710:10:
open Runtime Chat host: "Another Codewhale process already owns this Runtime Chat account session."

PRs #5732/#5733 on the same base passed it. Nothing in either failing PR touches runtime_chat_relay.rs — pre-existing main code, schedule-dependent.

Mechanism notes for whoever picks it up: the scope lock is flock(LOCK_EX|LOCK_NB) on scope-<sha>/ under a per-test tempdir (RelayScopeLock::acquire, runtime_chat_relay.rs:1520+). flock conflicts are per open-file-description, so a second open of the same path in the same process conflicts even single-process. The test drops the host then reopens the same root (drop(host); open_host(root) at ~:2216). If any host internals (RuntimeThreadManager background tasks) defer the fd close past drop(host), the reopen loses the race — which would explain scheduling-dependent flakiness. The map_err at open (:260) discards the underlying io error, which hides the real errno — keep the source error in the message when fixing.

Acceptance: the test (and its siblings using open_host) passes under repeated full-suite parallel load (e.g. 20 consecutive Safety-gate runs or a stress loop with --test-threads maxed), with the underlying io error preserved in the failure message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreliabilityReliability, flaky behavior, retries, fallbacks, and robustnesstuiTerminal UI behavior, rendering, or interaction

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions