Repository navigation
Description
A delete that removes nothing — a no-op DELETE DATA, or a replayed delete — can make a scan return rows that don't match the query. This is the graph-scoped sibling of #1721, on a lane #1728 deliberately doesn't touch.
Reproduced, with a control
ex:p carrying "25"^^xsd:int and "25"^^xsd:long, published index, novelty non-empty on both measurements, query SELECT ?s WHERE { ?s ex:p 25 }:
| action | result |
|---|---|
no-op delete of "999"^^xsd:int — a datatype the predicate does carry |
[] → [ex:b] |
control: no-op delete of "999"^^xsd:short — a datatype it does not carry |
[] → [] |
The control is what makes this conclusive: only a retraction naming a tag already present in the base perturbs the answer, which is exactly the mechanism below.
Mechanism
update_graph_property_datatypes → increment_count (fluree-db-novelty/src/runtime_stats.rs:507) applies a blind ±1 with retain(|e| e.1 > 0) onto the base index's graph-scoped datatypes. A spurious -1 zeroes a base tag and drops it from the set. That leaves a singleton, and infer_exact_datatype_sid_from_stats (fluree-db-query/src/binary_scan.rs:3366) narrows the scan to that exact datatype on the strength of it — its comment asserting the premise #1721 disproved, that the set "reflects base + novelty, so 'only one string-compatible tag' is a conclusive statement about the whole logical DB."
So a row that doesn't satisfy the query is returned, rather than an optimization merely being declined.
Relationship to #1721 and #1728
#1728 fixes the aggregate PropertyStatEntry by adding observed_datatypes — base tags ∪ novelty-asserted tags, monotone under retraction. This is the same defect on the graph-scoped GraphPropertyStatEntry, which that PR doesn't touch. So #1721's class isn't fully closed by #1728, and this issue is the remainder.
Why it wasn't folded into #1728
The correct fix mirrors observed_datatypes onto GraphPropertyStatEntry: six construction sites across five crates (core and binary-index decoders, id_hook.rs ×2, the novelty merge, ledger_info.rs), plus per-(graph, predicate) asserted-tag tracking in the merge, plus a StatsView field and its own regression test — roughly the same size again as the #1721 half of that PR, on a lane it otherwise leaves alone.
There is a cheaper alternative, and it needs a decision rather than a drive-by: veto the narrowing from the now-monotone aggregate set. That's sound, but it silently declines narrowing for any predicate whose datatype set differs across graphs, and it depends on IndexStats.properties being present (it's an Option). That's a performance trade-off someone should choose deliberately.
Notes
- The corruption window is the same as filter_fold's node-only soundness guard reads an estimate that a spurious retraction can drive to zero #1721's: from the bad delete until the next index publish, since the indexer's
on_record_with_base_presencereconciles retractions against base presence. - Whatever lands should carry the control case above — a repro without it can't distinguish this mechanism from ordinary stats drift.
- Per the surface-parity rule, check the JSON-LD surface for the same narrowing.
Found while remediating #1728's review; the reviewer flagged the site and the fix work confirmed it end to end.
Activity
test(binary-index,api): pin the historical tail's wire contract and b…
aaj3f commentedon Aug 28, 2026
Update: this is now folded into #1728 after all —
Fixes #1738is wired there, so it closes on that merge.What changed the calculus: #1728's review pushed on the global time-travel clearing, and the answer was to persist the observed-tag sets on the stats wire (an appended tail behind the existing length prefix — invisible to old readers, no format bump). Once the wire tail and its producers had to visit all six of this issue's construction sites anyway, the marginal cost of mirroring the sets onto
GraphPropertyStatEntrycollapsed, and the "same size again" estimate above stopped being true.The fix is the set-based veto this issue's "cheaper alternative" section discusses, but per-graph rather than aggregate — so it doesn't decline narrowing for predicates whose datatype sets differ across graphs, which was the trade-off that made the aggregate veto a decision rather than a drive-by.
infer_exact_datatype_sid_from_statsnow narrows off a per-(g, p)tag set that a spurious-1cannot shrink, and the control case above (no-op delete of a tag the predicate doesn't carry) is pinned alongside the mechanism case. It also closes the time-travel variant of the narrowing, which nothing previously covered.