Skip to content

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

Closed

Description

@lvca

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(() -> {
  final var t = database.getSchema().createDocumentType("T", 1);
  t.createProperty("k", Type.STRING);
  t.createTypeIndex(Schema.INDEX_TYPE.LSM_TREE, true, "k");
});

final RID[] rid = new RID[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)

Observed: viaIndex=0 viaScan=1.

Notes for whoever picks it up

Activity

  1. added 5 commits that reference this issue on Aug 13, 2026
  2. added a commit that references this issue on Aug 13, 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions