You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Numeric MIN/MAX fast path can return a retracted value: it reads leaflet routing keys as the extremes #2398
P1Next up: wrong results, live user pain, unblocksarea:queryQuery execution, planning, fast paths, overlay, result formattingbugSomething isn't working as expected
minmax_numeric_post (fluree-db-query/src/fast_min_max_string.rs:258) answers MIN(?o) and MAX(?o) over one predicate from POST leaflet directories. It takes each leaflet's first_key as that leaflet's minimum and its last_key as its maximum (:283-310). The only checks are that the key's o_type is numeric and is the same across leaflets. Since 25e0721, those keys are routing bounds widened over the leaflet's retracted history (see #2394), so a retracted extreme of the same type can come back as the answer.
Found by reading the code on main at f42ea37. Not reproduced yet.
How a retracted value reaches the keys
Full build, MAX: a predicate's trailing retracted fact is buffered. At the segment flush it is committed into the outgoing leaflet (commit_pending_for_current_segment in push_record, fluree-db-binary-index/src/format/leaf.rs), and flush_leaflet widens that leaflet's last_key to cover it.
Full build, MIN: history that sorts before the predicate's first live row is committed into the leaflet that row opens, which widens its first_key.
Incremental build: a retracted extreme keeps widening the leaflet it was in.
The Cypher max(n.n) shape reaches the same function (fast_whole_graph_agg.rs:1046). String MIN/MAX (minmax_string_dict_post) is suspected of the same after an incremental retraction, but not traced.
Repro to run
Give ex:n the values 0 to 9, plus 1000 and -5.
Delete 1000 and -5.
Index once with a full build, and separately with an incremental build.
The correct answers are MAX(?n) = 9 and MIN(?n) = 0. Reading the code predicts 1000 and -5. Compare against the general pipeline on the same view, using fluree_db_api::set_fast_paths_disabled(true).
main, after that: read the live edge of the last (for MAX) or first (for MIN) leaflet that has rows for the predicate. The leaflets don't overlap and are in key order, so that one read is the answer.
The v5 half landed on next in #2402 (merged 2026-11-19, c63b329): numeric MIN/MAX reads the group of the predicate's first or last live row, and reads only that leaflet. Covered in it_leaflet_live_edges after full and incremental builds, and on a v4.2.6 fixture.
Open for the main fix: read the live edge of the predicate's first (MIN) or last (MAX) leaflet.
P1Next up: wrong results, live user pain, unblocksarea:queryQuery execution, planning, fast paths, overlay, result formattingbugSomething isn't working as expected
Activity
bplatz commentedon Nov 20, 2026
The v5 half landed on
nextin #2402 (merged 2026-11-19, c63b329): numericMIN/MAXreads the group of the predicate's first or last live row, and reads only that leaflet. Covered init_leaflet_live_edgesafter full and incremental builds, and on a v4.2.6 fixture.Open for the
mainfix: read the live edge of the predicate's first (MIN) or last (MAX) leaflet.