Repository navigation
Closed
Labels
P1Next up: wrong results, live user pain, unblocksarea:storageStorage backends, nameservice, ledger lifecycle, index storage, cachesbugSomething isn't working as expected
Description
What happens
NaN, INF and -INF are valid xsd:double values. A single one of them in a ledger causes the following:
- Indexing never completes. The build fails on the value, and the indexer retries the whole build indefinitely.
- A direct index build reports:
object resolve: f64 encode for p_id=…: NaN is not allowed in index values. - A trigger-and-wait call times out without surfacing that error.
- Novelty keeps growing while the retries continue.
- A direct index build reports:
- Export drops the triple. Exporting an unindexed ledger leaves the triple out. The CLI only reports it as a skipped row.
- Results go wrong once an index exists. A non-finite value in novelty over an index comes back with an empty object, and
FILTER(?o > 0)missesINF. - NaN compares as a number. On any ledger,
FILTER(?o > 5)matches NaN, andBIND(NaN > 5 AS ?b)is true.
A query against novelty alone returns the value correctly. Turtle and JSON-LD ingest behave the same way.
Reproduce
With the Python package (4.2.4b1):
import fluree, tempfile
doc = '<http://ex/s> <http://ex/v> "NaN"^^<http://www.w3.org/2001/XMLSchema#double> .'
with fluree.connect(tempfile.mkdtemp()) as conn:
ledger = conn.create("t")
ledger.insert(doc, format="turtle")
print(ledger.export(format="ntriples")) # empty
ledger.index(timeout=15) # times outThe same ledger without the NaN triple indexes in milliseconds.
Cause
- Encoding:
ObjKey::encode_f64(fluree-db-core/src/value_id.rs) refuses NaN and ±INF. The resolver calls it for every double (resolve_objectandresolve_object_chunkinfluree-db-indexer/src/run_index/resolve/resolver.rs), so the build fails. - Retries:
on_build_errorcallsschedule_retry(orchestrator.rs), which retries without limit.IndexOutcome::Failedis produced only for a missing ledger, so waiters never resolve.
- Novelty translation:
value_to_otype_okey(binary_scan.rs) andvalue_to_obj_pair(dict_overlay.rs) map an encode failure to the NULL sentinel. Export and queries then see no value. - Comparison:
numeric_cmp(fluree-db-core/src/value.rs) orders NaN by bit pattern whenpartial_cmpfails, so a comparison with NaN can be true. - Bulk import: the import sink stores a non-finite double as a string (
"inf"), which writes back out as an invalidxsd:double.
Proposed fix
- Encode every double.
- ±INF already sort correctly under the existing order-preserving transform:
-INFbelow-MAX,+INFaboveMAX. - Every NaN becomes one canonical bit pattern whose key sits just above
+INF. decode_f64already inverts these keys.- This is not an on-disk format change: these keys were never written before.
- ±INF already sort correctly under the existing order-preserving transform:
- Remove the fallbacks: drop the NULL sentinel in novelty translation and the string fallback in bulk import.
- Keep NaN out of numeric matches.
- An open upper bound on a float range stops at the
+INFkey. <,<=,>and>=are false when either side is NaN.- ORDER BY places NaN after
+INF, matching key order.
- An open upper bound on a float range stops at the
- Test: export before and after indexing, indexed and novelty query answers, and the COUNT fast path.
Indexing retrying forever on any data error is a separate problem, which this fix would no longer trigger for doubles.
Metadata
Metadata
Assignees
Labels
P1Next up: wrong results, live user pain, unblocksarea:storageStorage backends, nameservice, ledger lifecycle, index storage, cachesbugSomething isn't working as expected
Activity