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
fluree.db() can serve a stale cached view after subsequent commits (read-your-writes violation) #1330
Calling fluree.db(ledger_id) after committing additional transactions can return a previously cached GraphDb view that predates those commits. Observed twice while writing integration tests, in both ledger-manager configurations:
FlureeBuilder::memory().with_ledger_cache_config(LedgerManagerConfig::default()) + background indexer: after trigger_index_and_wait_outcome, two further commits (verified receipt.ledger.t() == 3), then fluree.db(ledger_id) returned a view with snapshot.t == 1 — neither commit visible (it_cyclic_bgp_probe.rs, phase 2).
Plain FlureeBuilder::memory().build_memory() + synchronous fluree.reindex(...): the secondfluree.db() call in a test (after an earlier call had populated the cache, followed by more commits) served the pre-commit view; even a post-reindex fluree.db() reported t = 1 while the data was at t = 5 (it_join_batched_overlay.rs::batched_join_decimal_novelty).
Both tests work around it by pinning explicitly: fluree.db_at_t(ledger_id, receipt.ledger.t()) — the workaround sites are marked with comments ("a cached pre-commit view can otherwise serve").
Why it matters beyond tests
If the same lookup path backs server-side view resolution, a client that commits and immediately queries can read stale state — a read-your-writes violation that would be intermittent and hard to diagnose in production. If the embedded-API path is the only one affected, the fix may just be cache invalidation (or a freshness check against the nameservice head) in the ledger manager's view lookup.
Repro
See the two test files above: drop the db_at_t pinning back to fluree.db(ledger_id) and both tests fail with pre-commit data.
Activity
fix: db() reflects owned-state commits (read-your-writes)