You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RESTORE DOCUMENT/VERTEX/EDGE does not re-add the record's index entries: an indexed query returns 0 rows while a full scan returns 1 #6120
Spun off from #6096 (PR #6119), where it was found and confirmed but deliberately left out of scope.
Summary
RESTORE DOCUMENT/VERTEX/EDGE puts the record back in its bucket but never adds its index entries, so after a restore a query resolved through an index misses the record while a full scan returns it. Same failure shape as #6069 and #6096: a wrong answer returned with an ordinary success and nothing a caller can act on - except this one is worse than a count, because it silently drops the record from every indexed query, including a UNIQUE index's own duplicate check.
Cause
The three RESTORE statements call LocalBucket.restoreRecordAtPosition() directly (through RestoreStatementSupport.restoreRecordAndUpdateCount()), bypassing LocalDatabase.createRecord() - which is where a normal insert indexes the document. GraphEngine.restoreVertexAt() does the same. #6082 folded the bucket record-count delta the same way for #6069; the index entries are the other half of that bookkeeping and were not folded.
Reproduction
Engine API, arcadedb-engine on current main (with PR #6119 applied - the gap is independent of it):
database.transaction(() -> {
finalvart = database.getSchema().createDocumentType("T", 1);
t.createProperty("k", Type.STRING);
t.createTypeIndex(Schema.INDEX_TYPE.LSM_TREE, true, "k");
});
finalRID[] rid = newRID[1];
database.transaction(() -> rid[0] = database.newDocument("T").set("k", "a").save().getIdentity());
database.transaction(() -> database.command("sql", "DELETE FROM " + rid[0]));
database.transaction(() -> database.command("sql", "RESTORE DOCUMENT T RID " + rid[0] + " SET k = 'a'"));
// SELECT FROM T WHERE k = 'a' -> 0 rows (index lookup)// SELECT FROM T -> 1 row (full scan)
The other option is to index the restored record the way createRecord does. On a UNIQUE index that also gives RESTORE a duplicate check it currently does not have: today a restore can create a second record carrying a key value the unique index already holds, and the index never learns about it.
Whichever way it goes, GraphEngine.restoreVertexAt() needs the same treatment as the SQL statements.
Activity
fix(#6120): give restoreRecord auto-transaction and persistent-record…
fix(#6120): register the restored record before indexing it
test(#6120): fold the no-arg countByScan into the parametrized one
fix(#6120): hold one read lock across the restore and its implicit co…
fix(#6120): fold the index entries on RESTORE DOCUMENT/VERTEX/EDGE (#…
ArcadeData#6096 and ArcadeData#6120 fixed: flip the xfail, pin the in…