Repository navigation
Description
I've found a reproducible server-side NullPointerException when running a Lucene fuzzy query through SEARCH_INDEX on an existing FULL_TEXT index that has accumulated deletes/updates.
The same index works for plain term queries and prefix/wildcard queries. The failure appears specific to the fuzzy-query path (~), which scans the underlying full-text index and assumes IndexCursor.next() always returns a non-null Identifiable.
This was reproduced from the ArcadeDB console, so it does not appear to depend on a Java client/driver.
Environment
- ArcadeDB server banner:
26.7.2-SNAPSHOT - Local source checked against current
main:f36230666 fix(#5099): HA bootstrap first-formation survives leadership transfer (#5113) - Query executed through
bin/console.sh - Index type:
FULL_TEXT - Similarity: default full-text configuration
Reproduction
I can reproduce it with a small synthetic database if the full-text index is first stressed with repeated inserts, deletes, and updates.
The following script creates a generic Doc type, adds a full-text index on body, performs repeated inserts/deletes/updates, and then runs a Lucene fuzzy query:
#!/usr/bin/env bash
set -euo pipefail
CONSOLE=/path/to/arcadedb/bin/console.sh
DB=fulltext_fuzzy_stress
"$CONSOLE" -b "drop database remote:localhost/$DB root password" >/dev/null 2>&1 || true
cmds=(
"create database remote:localhost/$DB root password"
"create document type Doc"
"create property Doc.body string"
"create index on Doc (body) full_text"
)
for i in $(seq 1 400); do
cmds+=("insert into Doc set body = 'juncos rogelio alpha $i'")
cmds+=("insert into Doc set body = 'junco alfredo beta $i'")
if (( i % 2 == 0 )); then
cmds+=("delete from Doc where body = 'juncos rogelio alpha $i'")
fi
if (( i % 3 == 0 )); then
cmds+=("update Doc set body = 'juncos updated gamma $i' where body = 'junco alfredo beta $i'")
fi
done
cmds+=("select count(*) as total from Doc where search_index('Doc[body]', 'juncos~') = true")
"$CONSOLE" -b "${cmds[@]}"On my machine, the final query fails with the NPE below.
The same fuzzy query did not fail on a tiny clean database with only a couple of inserts and one delete, so the issue seems to require enough repeated delete/update activity.
Minimal Failing Query Shape
Once the index is in that state, the failing query shape is:
SELECT count(*) AS total
FROM Document
WHERE SEARCH_INDEX('Document[body]', 'sample~') = true;Expected Behavior
The query should return matching records or zero rows.
It should not throw an internal server error after repeated deletes and updates.
Actual Behavior
The query fails with:
RemoteException: Error on executing remote operation
SELECT count(*) AS total
FROM Document
WHERE SEARCH_INDEX('Document[body]', 'sample~') = true
cause: java.lang.NullPointerException
detail: Cannot invoke "com.arcadedb.database.Identifiable.getIdentity()"
because the return value of "com.arcadedb.index.IndexCursor.next()" is null
What Works
On the same index, these query shapes work:
SELECT count(*) AS total
FROM Document
WHERE SEARCH_INDEX('Document[body]', 'sample') = true;SELECT count(*) AS total
FROM Document
WHERE SEARCH_INDEX('Document[body]', 'sampl*') = true;This points to the fuzzy-query code path rather than SEARCH_INDEX or the full-text index in general.
Source-Level Clues
The stack trace and source suggest the null comes from a full-text index cursor:
SQLFunctionSearchIndex.performSearch(...)iterates the cursor returned byFullTextQueryExecutor.search(...)and callsmatch.getIdentity()without checking whethercursor.next()returnednull.FullTextQueryExecutor.collectFuzzyMatches(...)delegates toiterateAndMatch(...).FullTextQueryExecutor.iterateAndMatch(...)also callscursor.next().getIdentity()directly while scanning the underlying index.LSMTreeIndexCursor.next()can returnnulleven after a previoushasNext()check while internal iterators are still considered alive.
Activity
fix(#5118): guard full-text query cursor against null next() on stres…
lvca commentedon Jul 8, 2026
Confirmed and fixed in
main(commit ab208cd).The problem was specific to fuzzy queries (
term~). A fuzzy search scans the whole full-text index, and once the index has accumulated enough deletes/updates it can hand back an empty (tombstoned) entry mid-scan. The query code assumed every entry was a real record and dereferenced it, which is what produced theNullPointerException. It now skips those empty entries, so the query completes and returns the matching rows (or zero) as expected.A regression test reproduces the scenario and also verifies no real matches are dropped by the fix. Thanks for the clear reproduction and the source-level pointers, they made this quick to pin down. The fix will ship in the next release.
fix(#5118): guard full-text query cursor against null next() on stres…