Skip to content

RESTORE follow-ups: constraint validation, create events, and re-triage of Issue5279ConcurrentUpdateTest #6127

Closed

Description

@lvca

Three follow-ups left over from the RESTORE work in #6096 / #6119 and #6120 / #6123. Filing them together since the first two share the same root cause: DatabaseInternal.restoreRecord deliberately does less than LocalDatabase.createRecordNoLock, and only the code says so.


1. RESTORE skips validate() and default values, so it can create a record that violates its type's constraints

createRecordNoLock calls setDefaultValues(record) and doc.validate() before writing. restoreRecord does neither, so:

RESTORE DOCUMENT MyType RID #1:0 SET someOptionalField = 'x'

recreates the record even when MyType declares other properties MANDATORY or NOTNULL, and without applying any declared default values. The result is a persisted record the schema says cannot exist, produced by an ordinary successful statement.

This was a deliberate choice when restoreRecord was consolidated: RESTORE is emergency repair, and its most common form is a structure-only shell restore with no SET clause at all - gating that behind a mandatory-property check would make the operation unusable in exactly the situation it exists for (recovering a RID that other records still reference). The empty-shell case is not incidental; GraphEngine.restoreVertexAt restores a property-less vertex by design.

But the trade-off is currently invisible: nothing in the SQL reference says RESTORE bypasses constraint validation, and a caller reasonably assumes the schema holds for every write path.

Options, roughly in order of preference:

  1. Document it, and have the statement's result set report that validation was skipped (so the caller has something to act on rather than a silent success).
  2. Validate only when a SET/CONTENT body is supplied, leaving the empty-shell repair path unvalidated. Splits the difference, at the cost of a rule that is harder to explain.
  3. Add an explicit opt-in/opt-out clause (RESTORE ... VALIDATE).

Related: a restored record that violates MANDATORY will also fail a later CHECK DATABASE-style consistency pass, which is worth confirming before choosing.

2. RESTORE does not fire create events, so triggers never see the restored record

createRecordNoLock fires events.onBeforeCreate / onAfterCreate plus the per-type RecordEventsRegistry callbacks. restoreRecord fires none, so a restored record is invisible to every registered trigger, including application-level ones that maintain derived state.

This was also deliberate: running user-authored triggers - JS ones included - during an emergency repair is a much larger behavioural and security surface than recreating one record, and a repair that fires side effects is hard to reason about mid-incident.

I lean toward documenting the contract rather than changing the behaviour. Either way it should be stated in the SQL reference for RESTORE DOCUMENT/VERTEX/EDGE instead of living only in a code comment, since anything that rebuilds derived state from create events will silently drift after a restore.

The javadoc on DatabaseInternal.restoreRecord already lists both this and item 1 as the two intended departures from createRecordNoLock - the gap is user-facing documentation, not internal clarity.

3. Re-triage Issue5279ConcurrentUpdateTest.growingUpdatesUnderContentionKeepTheDatabaseConsistent

Currently treated as a chronic flake. During the #6096/#6120 work it failed on every local run - full-suite and in isolation, on clean main with all changes stashed as well as with them applied. That is consistent enough to warrant a second look rather than being written off as noise.

Failure shape is stable:

N thread(s) failed, first: com.arcadedb.exception.ConcurrentModificationException:
Concurrent modification on page PageId(Issue5279ConcurrentUpdateTest/1/0)
in file 'Growing_0.1.65536.v0.bucket' (current v.187 <> database v.188).
Please retry the operation

The thread count varies run to run (2-5 observed), the page and file do not. Given #5279's slot-merge machinery is meant to absorb exactly this false conflict for in-page growing updates, the test either found a real hole in growRecordInPage/slot-rebase or its retry budget is too tight for a fast multi-core machine. Both are worth knowing which.

Worth checking whether it also fails consistently in CI or only locally - if it is machine-speed dependent, that itself points at the retry budget rather than the merge logic.


Items 1 and 2 are contained to the RESTORE statement family and its docs. Item 3 is independent and can be picked up separately.

Activity

  1. self-assigned this
    on Aug 13, 2026
  2. added this to the 26.9.1 milestone on Aug 13, 2026
  3. added theissue type on Aug 13, 2026
  4. added 6 commits that reference this issue on Aug 13, 2026
  5. added
    backup-restore
    on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backup-restorebug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions