Repository navigation
fix: harden the upsert absent-subject skip against an unattached index - #1656
Conversation
…to load
`generate_upsert_deletions` treated a missing range provider as proof that no
base index exists, so every subject was decided by novelty alone. That holds at
genesis, but the ledger manager treats a binary-store load failure as non-fatal
("Failed to load binary store, continuing without"), which leaves an indexed
ledger (`t > 0`) with no provider attached. There the pre-check reported every
subject absent, skipped it, and committed zero retractions -- old values
silently survived alongside the new ones. Before the skip existed that state
failed loudly at `range_with_overlay`.
- stage.rs: require `t == 0` alongside the missing provider, mirroring
`fluree_db_core::range`, which treats a missing provider as an empty index
only at genesis and errors otherwise. A `t > 0` ledger with no provider now
falls through to the per-predicate query, which surfaces the load failure.
- stage.rs: drop the `store.sid_to_iri` fallback. The store's namespace table
is a subset of the snapshot's -- the index root is a materialized cache at
`index_t` and `sync_store_and_snapshot_ns` reconciles its codes back on load
-- so it can never decode a code the snapshot could not. Collapse the
closure's no-store arm to `false`, which is all `!base_index_absent` could
ever evaluate to under the caller's gate.
Tests: the per-subject-namespace case now covers a subject committed after the
last index build, where the snapshot decodes the namespace code but the store
conclusively misses, so only the novelty backstop prevents a wrong skip. That
is the one direction the fail-open removal could lose a retraction in, and it
is visible in the results; verified by neutralizing the backstop, which fails
exactly that assertion. The previously covered subject was already indexed and
never reached the branch.
Move the span-capture assertion out of the grouped binary into its own
`it_upsert_skip_fires` test, per the standalone rule in
docs/contributing/tests.md: tracing's callsite-interest cache is process-global
and the capture thread-local, so a sibling test in the same process can leave
the event undelivered.
Docs: namespace-allocation no longer suggests "setting HostPlusN(n) on the
ledger" -- there is no user-facing knob, the bulk-import preflight is the only
thing that selects it, and the mode is immutable after genesis.
…lexity `Arc<RwLock<HashMap<(GraphId, Sid), Vec<Sid>>>>` tripped `type_complexity` when the class cache was keyed on the graph in 18ad842, which fails CI's `clippy --all --all-features --all-targets -D warnings`. Introduce a `ClassCache` alias; no behaviour change.
|
Flagging the second commit here,
Since clippy runs with Would you be open to landing that commit on its own, ahead of the rest of this PR? It is a three-line type alias with no behaviour change, so it could go in immediately and unblock the queue without waiting on review of the upsert hardening here (+246/−134 across 8 files). I can open that PR if it is useful, but it is your commit and I would rather not duplicate it — happy for you to take it whichever way is least work. Raising it mainly because the type became complex in #1580, which was mine: I had this same alias on my own integration branch and should have carried it into that PR instead of leaving you to write it. |
aaj3f
left a comment
There was a problem hiding this comment.
LGTM, @bplatz. The "name the class-cache type" work, though, did get covered by #1658 -- may worth a fast-foward or merge of main into this branch to ensure it's not now a textual / logic conflict.
Adherence to repo commitments:
- Patterns/abstractions: ✔ extends the existing
range-module absence contract rather than special-casing; the standalone-test convention followsit_cyclic_bgp_probeprecedent. - Performance (speed first, memory second): ✔ neutral — staging-setup gate only, no hot-path or per-flake change; the #1645 skip's win is preserved and pinned by
it_upsert_skip_fires. - Testing: ✔ both binaries verified live and passing locally (
it_upsert_skip_fires1/1,grp_transact it_transact_upsert_indexed3/3); the new file is correctly wired via[[test]](autotests=false trap avoided). - Conventions: ✔ thorough multi-line commit bodies; clippy/fmt clean (and commit 2 un-reds
main's workspace clippy); docs updated where behavior claims changed (namespace-allocation.md,tests.md).
Verified locally at branch HEAD: it_upsert_skip_fires + it_transact_upsert_indexed green, cargo fmt --all -- --check clean, clippy -p fluree-db-policy --all-targets --no-deps clean of type_complexity.
# Conflicts: # fluree-db-policy/src/evaluate.rs
Follow-up to #1645, from a code review of that branch. Two commits: the correctness fix, and an unrelated one-line clippy repair that CI on
maincurrently needs.1.
fix(transact): keep absence undecidable when the store failed to loadgenerate_upsert_deletionstreated a missing range provider as proof that no base index exists, so every subject was decided by novelty alone.That holds at genesis, but
LedgerManagertreats a binary-store load failure as non-fatal (ledger_manager.rs:1254, "Failed to load binary store, continuing without"), which leaves an indexed ledger (t > 0) with no provider attached. In that state the pre-check reported every subject absent, skipped it, and committed zero retractions — old values silently survived alongside the new ones. Before the skip existed the same state failed loudly inrange_with_overlay.t == 0alongside the missing provider, mirroringfluree_db_core::range, which treats a missing provider as an empty index only at genesis and errors otherwise (binary-only db has no range_provider attached). At > 0ledger with no provider now falls through to the per-predicate query, which surfaces the load failure instead of silently dropping retractions.store.sid_to_irifallback. The store's namespace table is always a subset of the snapshot's — the index root is a materialized cache atindex_t, andns_helpers::sync_store_and_snapshot_nsreconciles its codes back into the snapshot on load (fluree_ext.rsdocuments the same invariant on the read-only view path) — so it can never decode a code the snapshot could not. The closure's no-store arm collapses tofalse, which is all!base_index_absentcould evaluate to under the caller's gate.Tests
The existing per-subject-namespace regression test never reached the changed branch: its subject was already indexed, so it hit
find_subject_id_by_partson the first probe. It now also covers a subject committed after the last index build, where the snapshot decodes the namespace code but the store conclusively misses — the one direction where removing the fail-open could lose a retraction, and the only thing standing in the way is the novelty backstop. Verified by neutralizing that backstop, which fails on exactly the new assertion (left: ["C1","C2"], right: ["C2"]) and nothing else.The span-capture counter assertion moves to its own
it_upsert_skip_firesbinary, per the standalone rule indocs/contributing/tests.md: tracing's callsite-interest cache is process-global and the capture is thread-local, so a sibling test in the same process can leave the event undelivered.Docs
namespace-allocation.mdno longer suggests "settingHostPlusN(n)on the ledger" as a remedy — there is no user-facing knob, the bulk-import preflight is the only thing that selects it, and the mode is immutable after genesis.2.
chore(policy): name the class-cache typeArc<RwLock<HashMap<(GraphId, Sid), Vec<Sid>>>>tripsclippy::type_complexity, which fails CI'sclippy --all --all-features --all-targets -D warnings. This arrived with 18ad842 (#1580) andmainis red on it right now. Adds aClassCachealias; no behaviour change. Happy to split this out if it should go back to that PR's author instead.Not addressed here
Two findings from the same review are left for a separate perf PR — they are the remaining 30-70s, not correctness:
BinaryScanOperatorstill widens to a PSOT/SPOT partition walk for a bound subject whose IRI decodes but conclusively has no base rows, while the bound-objectRefpath already treatsOk(None)as a conclusive miss. Only upsert benefits from the caller-side pre-check; SPARQL/JSON-LD/DELETE WHEREstill pay it.open_overlay_only_fallbackstill walks all of novelty per probe instead of using the boundedSegment::rangeseek.Validation
cargo fmt --all -- --checkcleancargo clippy --all --all-features --all-targets -- -D warningsclean (was failing onmainbefore commit 2)cargo nextest run --workspace --all-features --no-fail-fast: 11115/11115 passed