Skip to content

Single-process libtest: concurrent tests share a test-installed storage slot (~66 nondeterministic failures) #8467

Open

Description

@M3gA-Mind

Symptom

On main 9d5a06c, the single-process libtest form in test-reusable.yml (cargo test -p openhuman --lib, default threads) fails about 66 tests nondeterministically, and runs take ~600 s. The failing set differs between runs, around a stable core of ~47.

  • Groups: security::approval (gate and store, ~40), flows::builder_tools (13), skills::catalog (6), agent::orchestration spawn_subagent (4), skills::run_log (1).
  • The same command with --test-threads=1 passes: 596 passed, 0 failed in 24 s. The failures are concurrency-only.

Repro (cuttlefish):

( unset OPENHUMAN_MODULE_PATH; RUST_MIN_STACK=67108864 cargo test -p openhuman --lib \
    --features "$(bash scripts/ci/product-features.sh --core)" -- \
    flows::builder_tools security::approval skills:: agents::orchestrator:: spawn_subagent )

Cause (evidence below)

storage::local::backend_for (and every other reader of storage::installed()) prefers the process-wide installed storage slot over the workspace's own backend. Tests that install a backend use test_support::install_for_test / install_backend_for_test, which hold lock_storage_slot(). That serializes the installers only among themselves. While one holds the slot, every concurrently running test that opens storage through backend_for gets the installer's backend instead of its own TempDir workspace's.

As a result, rows from unrelated tests mix (row-count assertions fail), and they vanish when the installer's guard restores or clears the slot.

Evidence

  • A diagnostic build (eprintln! under cfg(test) when backend_for serves the installed slot, with the thread name and workspace) was run twice with default threads. 53 of 66 and 55 of 69 failing tests show that line in their captured output.
    • The thread named is the failing test itself, with its own temp workspace. Example: thread=Some("security::approval::gate::tests::forced_tests::forced_approval_denies_without_routable_web_chat_origin") workspace=/tmp/.tmpCjo3xc.
    • The same holds for store::tests::flow_trust_tests::* and the spawn_subagent tests.
  • The approval store tests panic at the first insert_pending(...).unwrap() or row-count assertion (store_persistence_tests.rs:5/57/77), which fits a backend that is shared or replaced mid-test.
  • --test-threads=1 gives 0 failures.

Not explained by this

The flows::builder_tools failures do not carry the installed-slot line, so they may have a second shared resource. To be checked once the slot is fixed.

Activity

  1. added
    priority: p1
    on Oct 27, 2026
  2. M3gA-Mind commented on Nov 16, 2026

    @M3gA-Mind
    CollaboratorAuthor

    Re-checked on current main (2b07daf): partly fixed. #8473 (with #8480) hides a test-installed storage slot from other libtest threads, which removes the cross-test mixing for tests that run on libtest's own threads. Two parts remain:

    • storage::local::backend_for still prefers the process-wide slot (storage/local.rs ~232-233), so runtime worker threads spawned inside a test (whose names don't carry the test path) can still see another test's backend.
    • test-reusable.yml (~299) still runs the single-process libtest form with default threads. It runs on release and dispatch only, so a regression would show up late.

    Next step: give worker threads the owning test's scope (or key the slot by tenant/workspace rather than thread), then re-measure the single-process run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions