Skip to content

A class of test flake CI cannot see by construction: overlay tests fail under cargo test same-process concurrency, and nextest hides it #1895

Open

Description

@aaj3f

The finding that matters most: CI cannot see this class, and never will

CI runs cargo nextest run --workspace --all-features (.github/workflows/ci.yml), which runs every test in its own process. cargo test runs a binary's tests as threads in one process. Every flake below needs the second and cannot occur under the first — so CI is structurally blind to it, not lucky. It will stay green however many of these accumulate, and the only people who can ever see them are those running cargo test locally.

That is confirmed from both ends. The workflow file says nextest; and tiny_unselective_bracket_stays_bounded_below_floor was green in CI at two separate SHAs while failing roughly 40% of local full-target runs. It is also measured directly below: the same target is clean 6/6 under nextest and fails under cargo test.

So "CI is green" is not evidence about this class. Whatever the specific mechanism turns out to be, that gap in what our gates cover is the thing worth fixing first — and it is why these read as environmental to everyone who hits them.

A cheap reproducer

cargo test -p fluree-db-api --test grp_query it_bounded_overlay_translation — 12 tests, one file, fails in about two runs. That replaces "sometimes fails somewhere in a 468-test binary".

One trap for whoever runs it: every_subject_reads_back_correctly_after_scattered_retractions in that file takes over 60 seconds on its own, unrelated to the flake. It dominates the wall clock of any run that includes it, and it is the likeliest reason a reproducer looks hung.

Why a flake is worth a filing

Filing this because of what it will look like to whoever hits it next rather than because either test is important on its own.

Two tests failed for me during whole-crate cargo test --no-fail-fast runs, on separate occasions, and both passed on re-run:

it_join_batched_overlay::batched_subject_join_merges_novelty      (grp_misc)
  "alice-ages: batched subject lane should engage under novelty (merge mode);
   captured spans: ["sparql_lower", "stats_view_build", "sort_blocking"]"

it_bounded_overlay_translation::tiny_unselective_bracket_stays_bounded_below_floor
  (grp_query)

A third turned up the same day, found independently:

it_annotation_filter_pushdown::annotation_body_threshold_reduces_scan_work_on_both_surfaces
  (grp_misc)

Rates, pooled across two people on different branches:

Test Full target Isolated
tiny_unselective_bracket_stays_bounded_below_floor 2/4 fail at 23190ffb1, 1/3 on an unrelated branch, 1/6 here 0/8, 0/8 under load, 0/3
batched_subject_join_merges_novelty 1 observed 0/3, and grp_misc 295/295 ×3
annotation_body_threshold_reduces_scan_work_on_both_surfaces 1/3 at b91727d32 0/3

The rate on the first is roughly 40%, and it is the same either side of an unrelated Phase-2 export change whose diff touches no overlay, novelty, query or binary-index file — so it is pre-existing and not perturbed by tree content. The third is new from main, which suggests the pattern is still being added to rather than only inherited.

A threshold assertion that fails under load is indistinguishable from a genuine perf regression at the moment someone sees it red. Both of these assert something shaped like "the fast lane engaged" or "this stayed below the floor" — exactly the assertion a real regression would break. Someone who hits one of these on an unrelated PR has no way to tell, from the failure alone, whether they slowed something down. The cheap outcome is that they re-run it and move on; the expensive one is that they go looking for a regression they did not cause, or worse, "fix" something.

The trigger is same-process concurrency, not load — measured

The obvious reading is load sensitivity: threshold assertions on a busy box. That is wrong, and the experiment that separates the two is cheap. All on tiny_unselective_bracket_stays_bounded_below_floor, full grp_query target, same machine (16 cores):

Condition Concurrency Result
cargo test, full target threads, one process 1 failure in 6
cargo nextest run, full target one process per test 0 in 6
single test, isolated, 32 CPU burners on 16 cores (load ~10–13) none 0 in 8

The third row is the one that rules out load: the test passes eight times running while the machine is saturated. What reproduces it is running in the same process as its siblings — not being slow, and not being one of many processes, since nextest is also parallel and is clean.

So what is established is the trigger: concurrent execution in the same process. Everything below narrows from there, and the most useful product of it is a cheap repro — cargo test -p fluree-db-api --test grp_query it_bounded_overlay_translation is 12 tests in one file and reproduces in about two runs. That beats "sometimes fails somewhere in a 468-test binary" for whoever picks this up.

Four candidate mechanisms are excluded by measurement, not by argument:

  • CPU load — the burner row above. 8/8 clean on a saturated box.
  • Environment variables — zero of grp_query's 33 modules and zero of grp_misc's 38 call set_var/remove_var. Every env-mutating test file in the crate is a standalone [[test]] target, so it runs in its own process; env is per-process, so there is no channel at all.
  • The global fast-path switch. FAST_PATHS_DISABLED (fluree-db-query/src/execute/operator_tree.rs:2247) is a process-global AtomicBool flipped binary-wide by set_fast_paths_disabled — exactly the shape that would explain a lane assertion flaking. Only it_differential_fastpath calls it in grp_query, and skipping it does not help: 2/15 failures with it, 1/15 without.
  • Sibling modules generally. The target's own module, run alone with all 32 sibling modules skipped, still flakes — positive in 2 runs. The interference is inside it_bounded_overlay_translation.rs.

Within that file, it is not a single culprit either. Pairing the failing test with one sibling at a time: novelty_only_subject_is_fully_visible, retraction_in_novelty_suppresses_indexed_base_row and selective_brackets_stay_bounded are each clean in 30 runs — 90 clean runs with one sibling. The failing test alone is clean in 30. But three siblings together go positive in 5.

And composition matters as well as count, which is what stops this being a tidy story:

concurrent siblings result
0 clean in 30
1 (×3 different siblings) clean in 30 each — 90 runs
2 — novelty_only + retraction_in_novelty positive in 13
2 — selective_brackets + time_travel clean in 30
3 positive in 5
6 positive in 17
11 (whole module) positive in 2

So it needs at least two concurrent siblings, and which two is not irrelevant — the positive pair are both novelty tests.

That fork is now split, and composition wins. The discriminating arm is a set that is deliberately novelty-free but more concurrent than the sets that fired: the target plus four siblings chosen because nothing in their names touches novelty or retraction — selective_brackets_stay_bounded, unselective_bound_predicate_falls_back_to_whole_graph_path, warm_whole_product_short_circuits_and_respects_epoch, named_graphs_stay_isolated (time_travel_sees_pre_retraction_state deliberately left out, since it tests retraction state).

concurrent siblings novelty tests among them result
2 2 positive in 13
3 yes positive in 5
4 0 clean in 30 (5 tests ran each time, verified)

If intra-process contention were the driver, four concurrent siblings should fire at least as readily as two. They never fire. So count is excluded, and the interfering resource is scoped to what the novelty tests share with the bounded-overlay target — most plausibly a process-global overlay, novelty or epoch cache that one test populates or advances and another asserts a bound over. That narrows the search to what those tests have in common, which is a far smaller place to look than "shared state somewhere".

One honest caveat on that arm: "novelty-free" is classified by test name, not by reading what each test does internally. The four chosen are about bounds, a warm product cache and graph isolation, and none mentions novelty or retraction — but a name is a weak proxy, and if one of them touches the overlay's novelty path under the hood the classification is wrong in a way this arm cannot see. This caveat qualifies the novelty-scoping, not the exclusion of count. Count is excluded independently of how the tests are labelled — four concurrent siblings stayed clean while some pairs of two fired — so the contention experiments are settled either way. The only check this caveat calls for is cheap: read the four tests and confirm none touches the overlay's novelty path.

The next step is to find the resource, not to theorise about it: diff what novelty_only_subject_is_fully_visible and retraction_in_novelty_suppresses_indexed_base_row touch against what tiny_unselective_bracket_stays_bounded_below_floor reads, looking for a process-global. That is a code-reading task now, and a small one.

What would fix it

Two shapes, and the first is available today. Nextest supports test groups in .config/nextest.toml — the repo already has that file, currently carrying only slow-timeout — so these could be pinned to a serial group. That is cheap, uses a mechanism already in the tree, and costs nothing in CI because CI is already process-per-test and already passing. It would not help anyone running cargo test, which is the population actually hitting this, so it is a partial fix that documents the constraint rather than removing it.

The real fix is to find the shared static and stop the assertion depending on it. That is more work and needs the specific state identified first, which is the open question above.

Worth saying plainly: the cheapest honest option may be neither — if these assertions cannot be made robust, marking them #[ignore] with a pointer here is better than leaving three tests that cry wolf.

Not related to the changes I was running

Worth saying explicitly, since both observations came off branches that touch the Cypher parser and lowering: neither test file contains a single occurrence of "cypher" (grep -ci cypher returns 0 on both), and neither branch changed anything under fluree-db-query's execution path. Whatever this is, it predates both.

Activity

  1. added
    bug
    P3
    area:query
    on Sep 18, 2026
  2. changed the title [-]A class of test flake CI cannot see by construction: overlay tests fail under `cargo test` from shared in-process state, and `nextest` hides it[/-] [+]A class of test flake CI cannot see by construction: overlay tests fail under `cargo test` same-process concurrency, and `nextest` hides it[/+] on Sep 18, 2026
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

    P3area:querybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions