Repository navigation
Description
A unique index created with NULL_STRATEGY INDEX accepts several records whose key is null (an all-null key is exempt from uniqueness, as the docs say for the sorted build: "As with online unique indexes, an all-null key is exempt (SQL NULL != NULL)", indexes.adoc L270). It keeps an entry for each of them (iterating such an LSM_TREE index lists one null entry per record), but WHERE p IS NULL answered through that index returns only one record, and SELECT count(*) ... WHERE p IS NULL counts one. The same type without an index, and a NOTUNIQUE index with NULL_STRATEGY INDEX, return all of them, and so do p <=> null and openCypher WHERE n.p IS NULL on every type.
In the repro each type holds four records, two with p null, one without p, and one with p = 1, each written in its own transaction. Through UniqueIdx (LSM_TREE) and UniqueHashIdx the query returns the last one written.
Where (at 1addb51950): FetchFromIndexStep.processIsNullCondition answers IS NULL with index.get(new Object[keyCount]), the point lookup of a key. On a unique index that lookup returns one entry for the null key (the repro prints index.get([null]) returning 1 entry on both unique indexes and 3 on the NOTUNIQUE one), although three records have the null key.
Repro
# lib/ holds the engine jar built at the commit under test and its dependencies
javac -cp 'lib/*' -d cls UniqueNullIsNull.java
java -Xmx2g -XX:+UseCompactObjectHeaders --add-modules=jdk.incubator.vector --enable-native-access=ALL-UNNAMED -cp 'lib/*:cls' UniqueNullIsNull ./dbimport com.arcadedb.database.*;
import com.arcadedb.index.*;
import com.arcadedb.query.sql.executor.*;
import java.util.*;
public class UniqueNullIsNull {
public static void main(String[] args) {
System.out.println("ArcadeDB " + com.arcadedb.Constants.getRawVersion() + " (" + com.arcadedb.Constants.getBuildNumber() + "), Java "
+ System.getProperty("java.version"));
try (Database db = new DatabaseFactory(args[0]).create()) {
final String[][] types = { { "Scan", null }, { "NotUniqueIdx", "NOTUNIQUE" }, { "UniqueIdx", "UNIQUE" }, { "UniqueHashIdx", "UNIQUE_HASH" } };
for (String[] t : types) {
db.command("sql", "CREATE VERTEX TYPE " + t[0]);
db.command("sql", "CREATE PROPERTY " + t[0] + ".id INTEGER");
db.command("sql", "CREATE PROPERTY " + t[0] + ".p INTEGER");
if (t[1] != null)
db.command("sql", "CREATE INDEX ON " + t[0] + " (p) " + t[1] + " NULL_STRATEGY INDEX");
db.transaction(() -> db.newVertex(t[0]).set("id", 1, "p", 1).save());
db.transaction(() -> db.newVertex(t[0]).set("id", 2, "p", null).save());
db.transaction(() -> db.newVertex(t[0]).set("id", 3).save()); // p not set
db.transaction(() -> db.newVertex(t[0]).set("id", 4, "p", null).save());
}
System.out.println("Each type holds (id, p) = (1, 1), (2, null), (3, not set), (4, null), one transaction per record");
for (String q : new String[] { "SELECT id FROM %s WHERE p IS NULL", "SELECT id FROM %s WHERE p IS NULL AND id > 0",
"SELECT id FROM %s WHERE p <=> null", "SELECT count(*) AS id FROM %s WHERE p IS NULL", "MATCH (n:%s) WHERE n.p IS NULL RETURN n.id AS id" }) {
final StringBuilder sb = new StringBuilder();
for (String[] t : types)
sb.append(String.format("%s %-12s ", t[0], ids(db, q.startsWith("MATCH") ? "cypher" : "sql", String.format(q, t[0]))));
System.out.printf(" %-46s %s%n", q.replace("%s", "T"), sb);
}
for (String[] t : types)
if (t[1] != null) {
final TypeIndex index = db.getSchema().getType(t[0]).getIndexByProperties("p");
int entries = 0;
for (IndexCursor c = index.get(new Object[] { null }); c.hasNext(); c.next())
entries++;
try (ResultSet rs = db.query("sql", "EXPLAIN SELECT id FROM " + t[0] + " WHERE p IS NULL")) {
System.out.printf(" %-10s index.get([null]) returns %d entries; plan of p IS NULL: %s%n", t[0], entries,
rs.next().<String>getProperty("executionPlanAsString").split("\n")[0].trim());
}
}
}
}
static String ids(Database db, String language, String query) {
try (ResultSet rs = db.query(language, query)) {
final List<Long> ids = new ArrayList<>();
rs.forEachRemaining(r -> ids.add(((Number) r.getProperty("id")).longValue()));
Collections.sort(ids);
return ids.toString();
} catch (Exception e) {
return e.getClass().getSimpleName();
}
}
}Output on main 1addb51950 (the engine jar's build stamp is 1addb51950), Temurin 25.0.4 with -XX:+UseCompactObjectHeaders:
ArcadeDB 26.10.1-SNAPSHOT (1addb519505253cbad99d1744d1abd23972928a8), Java 25.0.4
Each type holds (id, p) = (1, 1), (2, null), (3, not set), (4, null), one transaction per record
SELECT id FROM T WHERE p IS NULL Scan [2, 3, 4] NotUniqueIdx [2, 3, 4] UniqueIdx [4] UniqueHashIdx [4]
SELECT id FROM T WHERE p IS NULL AND id > 0 Scan [2, 3, 4] NotUniqueIdx [2, 3, 4] UniqueIdx [4] UniqueHashIdx [4]
SELECT id FROM T WHERE p <=> null Scan [2, 3, 4] NotUniqueIdx [2, 3, 4] UniqueIdx [2, 3, 4] UniqueHashIdx [2, 3, 4]
SELECT count(*) AS id FROM T WHERE p IS NULL Scan [3] NotUniqueIdx [3] UniqueIdx [1] UniqueHashIdx [1]
MATCH (n:T) WHERE n.p IS NULL RETURN n.id AS id Scan [2, 3, 4] NotUniqueIdx [2, 3, 4] UniqueIdx [2, 3, 4] UniqueHashIdx [2, 3, 4]
NotUniqueIdx index.get([null]) returns 3 entries; plan of p IS NULL: + FETCH FROM INDEX NotUniqueIdx[p] ()
UniqueIdx index.get([null]) returns 1 entries; plan of p IS NULL: + FETCH FROM INDEX UniqueIdx[p] ()
UniqueHashIdx index.get([null]) returns 1 entries; plan of p IS NULL: + FETCH FROM INDEX UniqueHashIdx[p] ()
Temurin 21.0.12 printed the same lines apart from the Java version on the first line.
Versions affected: main 417314c18d (2026-09-17) printed the same lines apart from the first line, on Temurin 25 and 21.
Expected: p IS NULL returns every record whose p is null or missing (2, 3, and 4) through the unique indexes as it does on Scan and NotUniqueIdx, and count(*) counts 3. Either the null-key lookup of a unique index returns every entry of the null key, or IS NULL on a unique index reads the null key's entries as a range.
Duplicates checked: gh search issues --repo ArcadeData/arcadedb for "UNIQUE null", "unique index null keys", "unique NULL_STRATEGY INDEX", "IS NULL index", and "NULL_STRATEGY". Near misses: #2453 (closed: IS NULL returned nothing through a NOTUNIQUE index with the default null strategy), #9032 (closed: IN with a null element through an index), #9074 (open: a HASH index with NULL_STRATEGY ERROR stores null keys), and the equality with a null parameter (#9238). I found no issue for IS NULL through a unique index.
Activity
Merge pull request #9252 from ArcadeData/fix/9245-9241-9236-9237-9240…
lvca commentedon Oct 5, 2026
Fixed in #9252 (26.10.1).
p IS NULLthrough aUNIQUEorUNIQUE_HASHindex withNULL_STRATEGY INDEXnow returns every record with a null key, andcount(*)counts them all. Related fixes: deleting one null-keyed record no longer drops the index entries of the others, and several null-keyed records added in one transaction are all kept.❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
bindings: ArcadeData#9237 and ArcadeData#9236 tripwires become plain …
tae898 commentedon Oct 5, 2026
Checked on upstream main 3543960 (the commit that contains #9252, #9250 and #9251; engine jars built by CI from that commit, no ha-raft shaded jar on the classpath) against 9fbef12 (main before those three merges). The repro is the one filed in this issue, unchanged. One JVM per run, in a container limited to 2 cores and 2 GB (-Xmx1g), on Temurin 25.0.4 with -XX:+UseCompactObjectHeaders and on Temurin 21.0.12.
Verdict: fixed on both JDKs. WHERE p IS NULL through the UNIQUE index and through the UNIQUE_HASH index returns all three null-keyed records, count(*) counts three, and index.get([null]) returns three entries on every kind of index, as the filed repro prints.
SELECT id FROM T WHERE p IS NULLSELECT id FROM T WHERE p IS NULL AND id > 0SELECT id FROM T WHERE p <=> nullSELECT count(*) AS id FROM T WHERE p IS NULLindex.get([null])entries (3 records have a null key)The other things the pull request says, measured with six and then nine records on a UNIQUE and a UNIQUE_HASH index with NULL_STRATEGY INDEX: deleting one null-keyed record keeps the others (on UNIQUE_HASH it returned none before), updating one null-keyed record to a value keeps the others, three records added with p not set in one transaction are all found, the null-keyed records are all there after a close and reopen, and a second record with p = 1 is still refused with DuplicatedKeyException. All 16 cases are right after the fix on both JDKs (0 of 16 wrong, against 12 of 16 wrong before).
Thanks for the quick fix.
fix(ArcadeData#9245,ArcadeData#9241,ArcadeData#9236,ArcadeData#9237,A…
bindings: known issues and strict xfail tripwires for upstream Arcade…
fix(#9245,#9241,#9236,#9237,#9240): DML positional plan key, vector s…