Repository navigation
Description
Found while building the export half of the RDF 1.2 work — I was implementing a refusal for the "annotations present, no arena" state and went to check that the remedy I was about to print actually worked. It doesn't, and the state it can't recover from is the one you land in by doing the obvious thing.
Insert an annotation, run fluree index, and the ledger ends up at has_annotations = true, annotation_index = None, had_annotation_arena = true. That last bit is sticky and never cleared, and it is exactly what gates the base-index bootstrap in attachment_events_from_state (fluree-db-api/src/indexer_attachment_provider.rs:304-306):
let bootstrap_eligible = snapshot.has_annotations
&& snapshot.annotation_index.is_none()
&& (force_annotation_bootstrap() || !snapshot.had_annotation_arena);So once fluree index has set the bit without sealing anything, no later reindex resolves coverage, and the arena stays absent for the life of the ledger.
Repro
$ fluree create x
$ fluree insert x --format turtle -e '@prefix ex: <http://example.org/> .
ex:a ex:knows ex:b ~ ex:c1 {| ex:conf 0.5 |} .'
$ fluree index x
Indexed x to t=1 (root: baghybqabciq…)
$ fluree reindex x
Reindexed x to t=1 (root: baghybqabciq…) # completes, seals nothing
$ fluree reindex x # and again, same
The ledger is stuck. Contrast the two paths that do work, on identical data:
| how the ledger was built | arena sealed? |
|---|---|
insert, then fluree reindex (no index first) |
yes |
create --from <dir> (bulk import) |
yes — commands/create.rs:915 runs a one-shot seal pass |
insert, then fluree index |
no |
insert, then fluree index, then fluree reindex |
no, and never will be |
The ordering is the whole defect: fluree index and fluree reindex disagree about what they owe an annotated ledger, and the one that does less also poisons the other.
What it costs you
The arena is the forward EdgeKey → annotation index. Without it, annotation reads fall back to the generic join chain — correct, but an order of magnitude slower. Same ledger, same query, sealed vs unsealed:
SELECT ?r ?c WHERE { ex:a ex:knows ex:b ~ ?r . ?r ex:conf ?c }
sealed arena : 7.7 ms
unsealed : 182.6 ms # 24x, and it is the state you get by default
Both return the right answer, which is why nothing has caught this: the only symptom is that quoted-triple queries are quietly slow on every ledger built the normal way. create --from prints a warning when its seal pass doesn't take ("Annotation arena was not sealed … until fluree reindex seals it"), so the bulk-import path at least tells you. fluree index says nothing at all.
Where it goes wrong
index_ledger (fluree-db-cli/src/commands/index.rs:70-81) does resolve the provider for annotated ledgers, with a comment explaining that without it the indexer "takes the defensive-drop path (annotation_index = None)". So the intent is right and the call is there. What it does not do is what Fluree::reindex does at admin.rs:2012-2018: fall back to attachment_events_from_state when the provider comes back with nothing. In a one-shot CLI process there is no long-lived LedgerManager for the provider to read a running ledger from, so it comes back with nothing, and fluree index has no second chance — while reindex does, which is why reindex-first works.
Then the pass sets had_annotation_arena anyway, and the second chance is gone for good.
I haven't decided which end to fix and don't think I should:
- give
index_ledgerthe sameattachment_events_from_statefallbackreindexhas (smallest, makes the two paths agree); - don't set the sticky bit on a pass that resolved no coverage and sealed no arena (narrower, and arguably what the bit was always supposed to mean — it reads as "an indexer owns history the live base doesn't reflect", which is not true of a pass that processed nothing);
- or make
force_annotation_bootstrap()reachable as something other than an env var, so there is at least a documented way out for ledgers already in this state.
The second one is the one I'd look at first, because the bit's own doc comment describes a condition that pass didn't meet. But whoever owns the indexer will have a better view than I do, and there may be a reason the bit is set unconditionally that I can't see from the read side.
Relationship to the other open index issues
Worth saying plainly, because there are now several fluree index threads and they are not the same thread:
-
Not fix(indexer): collect shared dictionary blobs, run the collector periodically, batch storage deletes #1862. bplatz's leak is per-publish reverse-dict-leaf rewriting. This is about which coverage envelope reaches the builder, not how much the builder writes.
-
Not the fixed-cost behaviour (the ~5 s / ~190 MiB floor on an incremental merge). I ran the control rather than assume it — two single-triple ledgers, one annotated and one not, same machine, same moment, each given one insert and then an incremental
fluree index:first index annotated 0.073s plain 0.044s incremental annotated 92.5s plain 91.2sIdentical. Whatever the incremental branch is spending, the annotation path is not in it. (Those absolutes are inflated — that box was at load average ~12 with four builds running, and the cost is reported elsewhere as ~4.4 s of
sys, so it is contention-sensitive. The pairing is the point, not the number.) -
They do share one property, and it is the only reason to mention them together: all three are
fluree indexdoing the wrong amount of work — one too much, one too little — and all three land in or next to the CLI's coverage resolution. If that code gets reworked, it is worth looking at them as a set.
Separately: named-graph bundles never reach the arena at all
I found this next to the above and it is a distinct defect, but it is the same subsystem and I'd rather it were in one place than lost. This one is the cause of the gap left open in #1859 — fluree export cannot emit RDF 1.2 annotation syntax for an annotation written inside a named graph, and this is why. That makes it the half with a user-visible capability loss today, not just a slow path.
An annotation written inside a named graph is never sealed into the arena, even on the paths that seal correctly:
$ cat src/a.trig
@prefix ex: <http://example.org/> .
GRAPH <http://example.org/g1> { ex:x ex:p ex:y ~ ex:cG {| ex:src ex:d |} . }
$ fluree create shapes --from src
info: Annotation arena sealed. # it did seal — for the default graph
$ fluree query shapes --sparql 'SELECT ?r ?s WHERE { GRAPH <http://example.org/g1> {
ex:x ex:p ex:y ~ ?r . ?r ex:src ?s } }'
ex:cG ex:d # the rows are there, SPARQL reads them
but the arena has no entry for ex:cG — current_targets_for(cG) returns empty, while the three default-graph reifiers on the same ledger are all present. The bundle is in the base index with a correct f:reifiesGraph ex:g1, so the loss is in the read that feeds the seal: scan_base_index_for_attachment_events_in (indexer_attachment_provider.rs:330) walks every graph in the registry and issues a PSOT range per reserved predicate, and for a named graph that range comes back empty. Setting FLUREE_EXPORT_ANNOTATION_SCAN=1 to force export down that same scan confirms it: it misses the named-graph bundle too, which puts the defect in the scan rather than in the arena builder.
I did not chase why the PSOT range is empty for a named graph — whether the order isn't built per named graph, or the range is scoped wrong. That's the next step for whoever picks this up.
The user-visible consequence today is in fluree export: annotations inside a named graph can't be represented in the output, because the forward lookup can't see them. Export counts them and says so rather than dropping them quietly, and --raw-reifies gets the bundles out verbatim, but that's a workaround for this, not a fix.
Activity
bplatz commentedon Nov 19, 2026
Not fixing on 4.x. Sealing the arena from
fluree indexneeds a full ledger load before every build, a cost every ledger would pay, annotated or not, for a speed-up only: after the #1859 fix (#1887), a ledger without an arena reads and exports annotations correctly through the base-index scan. The next major removes the annotation arena and derives annotation links in its own index build, so this does not arise there.