Skip to content

it_reasoning_request_limits fuel tests flake under load: the warm query re-materializes #2326

Open

Description

@bplatz

Raised in review of #2271. Reproduces on main.

Symptom

compiled_closures_are_charged_as_query_fuel and property_path_rule_bodies_are_charged_as_query_fuel fail intermittently at tests/it_reasoning_request_limits.rs:162 when grp_reasoning runs with many test threads:

materializing 1275 facts cost 3.6 fuel, reading the cached result 3.6

fuel_covers_materialization_of runs one query twice and expects the second to be served from the reasoning cache, at lower fuel. When it fails, cold and warm cost exactly the same: the warm query materialized again.

Binary, --test-threads=64, RUST_MIN_STACK=16777216 Runs failed
main 8308ba1 4/40
#2271 head (d3c37bc and e3409f9, in batches of 40) 5–12/40

jdorety saw the two tests fail in 17 of 40 runs at 64 threads.

The batches don't establish whether #2271 changes the rate: with the same test set, they ranged from 5 to 12 out of 40.

Cause

The reasoning cache (global_reasoning_cache, fluree-db-reasoner/src/cache.rs) is one process-wide LRU of 16 entries. Every concurrently running test in grp_reasoning materializes into it. When 16 other materializations land between this test's two queries, its entry is evicted, and the "warm" query rebuilds it. datalog_materialization_is_cached_across_identical_queries (it_datalog_rules_annotations) assumes the same thing and failed once in the same runs.

Fix

Give these tests a binary of their own, so their materializations can't be evicted by siblings. #2271 did this for its two cache-dependent tests (it_reasoning_lane_cache), which then failed 0 of 40 runs at 64 threads. That needs:

  • a [[test]] entry with a comment saying why the tests need their own binary;
  • moving them out of grp_reasoning.rs;
  • removing their #[path] lines from it.

The alternative, a cache per Fluree instance, would be a product change.

Note: running the grp_reasoning binary directly needs RUST_MIN_STACK set (cargo test applies 8 MB from .cargo/config.toml). Without it, the binary aborts with a stack overflow that looks like a test failure.

Activity

  1. added
    bug
    P3
    area:query
    on Nov 11, 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