Skip to content

fix: incremental class-stat base-store load failure publishes wrong stats (rdf:type-star fold can serve wrong COUNT) #1272

@bplatz

Description

@bplatz

Summary

Incremental Phase 3b loads the base V6 store for class attribution (fluree-db-indexer/src/build/incremental.rs, ~line 1897). On a load_from_root_v6 failure it currently only warn!s and continues with store_opt = None — it does not IncrementalAbort. With store = None, every base ClassStatEntry is dropped (the subject sid64 resolves to 0 in the seed loop, ~line 2604), so novelty-only (wrong) class stats get published into the root.

This became a HEAD-correctness risk once the lex_sorted_string_ids provenance gate was removed (#1266): count_plan_exec::try_type_star_pred_fold now runs on any base index, so it would serve a wrong COUNT(*) at HEAD from those stale class stats.

Severity

Narrow — requires a transient base-store load failure during an incremental build that includes rdf:type — but it is a correctness bug (silently wrong query result), and it precedes adding more class-stat fold paths (e.g. the bound-class fold), which would inherit the same exposure.

Fix

Make the base-store load failure return Err(IncrementalAbort(...)) → caller falls back to a full rebuild (which recomputes class + ref stats from scratch), mirroring the oversized-re-type gate (incremental.rs ~line 2086).

Minor sibling (perf-only, not correctness)

An all-quiet increment (no class deltas and no subject-property records) fails the Phase 3b gate (~line 1840); id_hook finalize sets classes: None with no carry-forward else-branch, so class stats are wiped → the fold declines and falls back to a scan (correct, just unaccelerated until the next rebuild). Worth a carry-forward of the prior class stats when there are no deltas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions