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
Retractions of novelty-only predicates are invisible to the crawl read path (deleted data reappears) #1683
P0Drop everything: data correctness / securityarea:transactStaging, commit, import/bulk-import, novelty, retraction semanticsbugSomething isn't working as expected
Surfaced while reviewing #1675. Pre-existing — reproduced at that PR's merge base a65eb1958, so it is not introduced by the hydration rewrite. Filing separately because the mechanism is different from anything #1675 touches.
Symptom
A filtered DELETE of a single @list entry commits with receipt.flake_count = 1, but the list is unchanged when queried afterwards. No error, no warning.
Trigger
The list's predicate exists only in novelty — no persisted p_id — on an otherwise indexed ledger. Narrowing done during review:
The same probe with the predicate also present in the indexed base passes.
List position does not matter: it fails at position 0, at position 1, and at the last position.
Staging is not the faulty component. hydrate_list_index_meta_for_retractions was instrumented and leaves the retraction with the correct m = { i: 1 }; the retraction reaches the commit intact.
That points at the query/overlay side and ephemeral (novelty-assigned) predicate ids rather than at the write path — the retraction appears to be written with a predicate id that does not line up with the one the asserted list row carries.
Why it matters
Silent data-loss-shaped failure in the opposite direction: the caller is told one flake was retracted and the entry is still readable. Any workload that inserts a list under a brand-new predicate and then deletes from it before the next index build is affected.
Suggested starting points
fluree-db-transact/src/stage.rs:1613 — hydration, confirmed correct; use it as the known-good boundary.
Predicate-id assignment for novelty-only predicates, and how the overlay resolves them against a persisted dictionary.
Origin
Review of #1675 (perf: make filtered-DELETE list-meta hydration O(novelty), not O(retractions × novelty)).
Here's the probe as it ran, @bplatz — it's self-contained apart from the three tests/support helpers, so it should drop straight into fluree-db-api/tests/ with the [[test]] stanza below. The two tests share one body and differ only in whether the indexed base already carries ex:items (as a plain value on the 50 seed rows) — that one boolean is the whole trigger.
# fluree-db-api/Cargo.toml
[[test]]
name = "it_probe_list_retract_base"path = "tests/it_probe_list_retract_base.rs"required-features = ["native"]
// fluree-db-api/tests/it_probe_list_retract_base.rs#![cfg(feature = "native")]mod support;usecrate::support::{query_jsonld_formatted, start_background_indexer_local, trigger_index_and_wait_outcome};use fluree_db_api::{CommitOpts,FlureeBuilder,IndexConfig,TxnOpts};use serde_json::json;fnctx() -> serde_json::Value{json!({"ex":"http://example.org/ns/"})}fnindex_cfg() -> IndexConfig{IndexConfig{reindex_min_bytes:1 << 40,reindex_max_bytes:1 << 41}}asyncfnlist_values(fluree:&fluree_db_api::Fluree,ledger:&fluree_db_api::LedgerState,subject:&str) -> Vec<String>{let q = json!({"@context": ctx(),"select":{"?s":["ex:items"]},"where":{"@id":"?s"},"values":["?s",[{"@id": subject}]]});let rows = query_jsonld_formatted(fluree, ledger,&q).await.expect("list query");
rows.as_array().and_then(|a| a.first()).and_then(|n| n.get("ex:items")).map(|v| match v {
serde_json::Value::Array(items) => items.iter().filter_map(|x| x.as_str().map(String::from)).collect(),
other => other.as_str().map(String::from).into_iter().collect(),}).unwrap_or_default()}asyncfnrun(ledger_id:&'staticstr,base_has_pred:bool){let tmp = tempfile::TempDir::new().unwrap();letmut fluree = FlureeBuilder::file(tmp.path().to_string_lossy().to_string()).build().unwrap();let(local, handle) = start_background_indexer_local(fluree.backend().clone(), fluree.nameservice_mode().publisher_arc().unwrap(), fluree_db_indexer::IndexerConfig::small());
fluree.set_indexing_mode(fluree_db_api::tx::IndexingMode::Background(handle.clone()));
local.run_until(asyncmove{let ledger = fluree.create_ledger(ledger_id).await.unwrap();// 50 seed rows; with `base_has_pred` they also carry `ex:items: "plain"` so the predicate gets a persisted p_id.let graph:Vec<_> = (0..50).map(|n| if base_has_pred {json!({"@id": format!("ex:r{n}"),"ex:name": format!("r{n}"),"ex:items":"plain"})}else{json!({"@id": format!("ex:r{n}"),"ex:name": format!("r{n}")})}).collect();let r = fluree.upsert_with_opts(ledger,&json!({"@context": ctx(),"@graph": graph}),TxnOpts::default(),CommitOpts::default(),&index_cfg()).await.unwrap();trigger_index_and_wait_outcome(&handle, ledger_id, r.receipt.t).await;let ledger = fluree.ledger(ledger_id).await.unwrap();assert!(ledger.snapshot.range_provider.is_some());// The list lives only in novelty; with `base_has_pred == false`, so does its predicate.let _ = fluree.insert_with_opts(ledger,&json!({"@context": ctx(),"@id":"ex:nov1","ex:items":{"@list":["a","b","c"]}}),TxnOpts::default(),CommitOpts::default(),&index_cfg()).await.unwrap();let ledger = fluree.ledger(ledger_id).await.unwrap();assert_eq!(list_values(&fluree,&ledger,"ex:nov1").await, vec!["a","b","c"]);let del = json!({"@context": ctx(),"where":[{"@id":"?s","ex:items":"b"}],"delete":[{"@id":"?s","ex:items":"b"}]});let r = fluree.update_with_opts(ledger,&del,TxnOpts::default(),CommitOpts::default(),&index_cfg()).await.unwrap();eprintln!("PROBE {ledger_id}: flake_count={} t={}", r.receipt.flake_count, r.receipt.t);let ledger = fluree.ledger(ledger_id).await.unwrap();assert_eq!(list_values(&fluree,&ledger,"ex:nov1").await, vec!["a","c"]);}).await;}#[tokio::test]asyncfnbase_probe_novelty_only_pred(){run("it/probe-base-novpred:main",false).await;}#[tokio::test]asyncfnbase_probe_pred_in_base(){run("it/probe-base-inbase:main",true).await;}
Run as cargo nextest run -p fluree-db-api --test it_probe_list_retract_base --no-fail-fast --no-capture. At the merge base a65eb1958 this is what it printed:
So both variants commit a one-flake retraction at t=3; only the novelty-only-predicate one leaves the list untouched. I also just re-ran it against today's main (47e96b7b6) before posting: same result — base_probe_novelty_only_pred fails with the identical ["a", "b", "c"] vs ["a", "c"] and flake_count=1 t=3, base_probe_pred_in_base passes — so it's still live, not something the last week of index work happened to fix.
A couple of details from the instrumented run at #1675's head that may save you a step, since you've pointed the issue at predicate-id assignment. With hydrate_list_index_meta_for_retractions instrumented, the group it forms is (g=0, s=ex:nov1, p=ex:items), the overlay walk finds all three list rows (t=2, op=true, i=0/1/2, all matching), and the retraction leaves hydration carrying m = { lang: None, i: Some(1) } — so the flake that reaches the commit has the right subject, predicate, object and position, and the flake_count = 1 in the receipt is that flake. The mismatch has to be downstream of that: either the retraction's predicate id at commit/novelty time doesn't line up with the id the asserted rows carry, or the read side resolves the two differently. I didn't chase it past that boundary.
What this probe doesn't cover, fwiw: the position-independence claim came from separate variants of the same body ("a" / "b" / "c" as the deleted entry — fails at all three); and I never ran it on a ledger with no index at all (the range_provider.is_some() assert is deliberate), so whether an unindexed ledger with a brand-new predicate is also affected is still open. Happy to turn the two-test version above into a proper #[should_panic]-free regression pin once the fix lands, if that's useful.
changed the title [-]@list retraction on a novelty-only predicate over an indexed ledger commits but does not take effect[/-][+]Retractions of novelty-only predicates are invisible to the crawl read path (deleted data reappears)[/+]on Aug 26, 2026
Scope correction from the fix work (PR #1698) — two findings that make this issue read differently than filed:
It isn't @list-specific. A plain-valued novelty-only predicate fails identically: ex:tags: ["p","q"], then delete "p", and the retraction is invisible the same way. @list is just the shape it happened to be found through. I've retitled accordingly, since "@list retraction" undersells what's affected.
Reload does not heal it — that was the open question from the triage sweep, and it was answered by running the reload leg against unfixed code: a fresh handle replays the same novelty and reads it the same wrong way. It heals on the next index build, not on reload.
The mechanism also explains why the sweep's CLI probes couldn't reproduce it: binary_range_eq_v3 bails to overlay_only_flakes whenever a bound component has no persisted id, and that function filtered its overlay walk to asserts only (if !flake.op { return; }). Since the overlay is a log, the assert at t=2 and its retraction at t=3 both live in novelty — dropping the retracts resurrected every fact whose assert and retract were both in the window. A BGP select takes the cursor path, which was always correct; only the subject-crawl reaches the broken function.
P0Drop everything: data correctness / securityarea:transactStaging, commit, import/bulk-import, novelty, retraction semanticsbugSomething isn't working as expected
Activity
aaj3f commentedon Aug 25, 2026
Here's the probe as it ran, @bplatz — it's self-contained apart from the three
tests/supporthelpers, so it should drop straight intofluree-db-api/tests/with the[[test]]stanza below. The two tests share one body and differ only in whether the indexed base already carriesex:items(as a plain value on the 50 seed rows) — that one boolean is the whole trigger.Run as
cargo nextest run -p fluree-db-api --test it_probe_list_retract_base --no-fail-fast --no-capture. At the merge basea65eb1958this is what it printed:So both variants commit a one-flake retraction at
t=3; only the novelty-only-predicate one leaves the list untouched. I also just re-ran it against today'smain(47e96b7b6) before posting: same result —base_probe_novelty_only_predfails with the identical["a", "b", "c"]vs["a", "c"]andflake_count=1 t=3,base_probe_pred_in_basepasses — so it's still live, not something the last week of index work happened to fix.A couple of details from the instrumented run at #1675's head that may save you a step, since you've pointed the issue at predicate-id assignment. With
hydrate_list_index_meta_for_retractionsinstrumented, the group it forms is(g=0, s=ex:nov1, p=ex:items), the overlay walk finds all three list rows (t=2, op=true, i=0/1/2, all matching), and the retraction leaves hydration carryingm = { lang: None, i: Some(1) }— so the flake that reaches the commit has the right subject, predicate, object and position, and theflake_count = 1in the receipt is that flake. The mismatch has to be downstream of that: either the retraction's predicate id at commit/novelty time doesn't line up with the id the asserted rows carry, or the read side resolves the two differently. I didn't chase it past that boundary.What this probe doesn't cover, fwiw: the position-independence claim came from separate variants of the same body (
"a"/"b"/"c"as the deleted entry — fails at all three); and I never ran it on a ledger with no index at all (therange_provider.is_some()assert is deliberate), so whether an unindexed ledger with a brand-new predicate is also affected is still open. Happy to turn the two-test version above into a proper#[should_panic]-free regression pin once the fix lands, if that's useful.[-]@list retraction on a novelty-only predicate over an indexed ledger commits but does not take effect[/-][+]Retractions of novelty-only predicates are invisible to the crawl read path (deleted data reappears)[/+]aaj3f commentedon Aug 26, 2026
Scope correction from the fix work (PR #1698) — two findings that make this issue read differently than filed:
It isn't
@list-specific. A plain-valued novelty-only predicate fails identically:ex:tags: ["p","q"], then delete"p", and the retraction is invisible the same way.@listis just the shape it happened to be found through. I've retitled accordingly, since "@list retraction" undersells what's affected.Reload does not heal it — that was the open question from the triage sweep, and it was answered by running the reload leg against unfixed code: a fresh handle replays the same novelty and reads it the same wrong way. It heals on the next index build, not on reload.
The mechanism also explains why the sweep's CLI probes couldn't reproduce it:
binary_range_eq_v3bails tooverlay_only_flakeswhenever a bound component has no persisted id, and that function filtered its overlay walk to asserts only (if !flake.op { return; }). Since the overlay is a log, the assert att=2and its retraction att=3both live in novelty — dropping the retracts resurrected every fact whose assert and retract were both in the window. A BGPselecttakes the cursor path, which was always correct; only the subject-crawl reaches the broken function.fix(query): resolve per-metadata inside a fact run, and sweep the thi…
bench(query): measure the overlay-only read path this PR changes