Skip to content

A NaN or ±INF xsd:double stops indexing for the whole ledger, and export drops it #2043

Closed

Description

@bplatz

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.
  • 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) misses INF.
  • NaN compares as a number. On any ledger, FILTER(?o > 5) matches NaN, and BIND(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 out

The 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_object and resolve_object_chunk in fluree-db-indexer/src/run_index/resolve/resolver.rs), so the build fails.
  • Retries:
    • on_build_error calls schedule_retry (orchestrator.rs), which retries without limit.
    • IndexOutcome::Failed is produced only for a missing ledger, so waiters never resolve.
  • Novelty translation: value_to_otype_okey (binary_scan.rs) and value_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 when partial_cmp fails, 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 invalid xsd:double.

Proposed fix

  • Encode every double.
    • ±INF already sort correctly under the existing order-preserving transform: -INF below -MAX, +INF above MAX.
    • Every NaN becomes one canonical bit pattern whose key sits just above +INF.
    • decode_f64 already inverts these keys.
    • This is not an on-disk format change: these keys were never written before.
  • 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 +INF key.
    • <, <=, > and >= are false when either side is NaN.
    • ORDER BY places NaN after +INF, matching key order.
  • 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.

Activity

  1. added
    bug
    P1
    area:storage
    on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:storagebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions