Skip to content

fix(engine) #5764: a refused vertex delete names the command that repairs it, and the conflict keeps its cause - #5767

Merged
lvca merged 4 commits into
mainfrom
issue-5764-deletevertex-repair-advice
Aug 2, 2026
Merged

lvca merged 4 commits into
mainfrom
issue-5764-deletevertex-repair-advice

Conversation

@lvca

@lvca lvca commented Aug 2, 2026

Copy link
Copy Markdown
Member

Closes #5764.

Follow-ups from #5680, whose two halves landed separately (#5707 made deleteVertex strict, #5710 added the CHECK DATABASE RECORD scope). Neither is defective; the seams between them were never closed.

Three of the four items needed code. The fourth turned out to be a non-issue that needed proving rather than fixing.

1. The repair advice names the scoped command, with the RID substituted

Every recovery hint GraphEngine.deleteVertex emitted predated the scope it was written for, so they all pointed at a whole-database or whole-type run - two full passes over the vertex type plus an edge sweep - while the operator was holding the one piece of information that makes the repair cheap. The retryable arm rethrew the conflict bare, so what actually reached a human was getEdgeHeadChunkForWrite's "concurrent commit in flight", which says nothing about recovery.

Departure from the report's suggestion. Naming CHECK DATABASE RECORD <rid> FIX at all four sites would be wrong at three of them. The scoped form is the right answer only where the delete was refused and the vertex is still there to repair. The force arms log after the record is gone, so a scoped check would name a record that no longer exists - they keep the whole-database form and say what the scoped form buys when run first. And at the other-end conflict the broken list belongs to the neighbour, so that is the RID named; repairing the healthy vertex under delete would do nothing.

A refused delete now answers with:

Edge list IN of vertex #12:3 is not fully visible yet (concurrent commit in flight): ...
  If it persists once the retries are spent the list is genuinely broken: run `CHECK DATABASE RECORD #12:3 FIX`
  to rebuild its edge list from the surviving edge records, then retry the delete (the scope saves the vertex
  passes, not the edge sweep the rebuild needs)

The limit is stated in the same breath because the scope does not bound everything: the edge sweep the rebuild needs still runs once per distinct vertex type named.

2. ConcurrentModificationException carries the failure that produced it

NeedRetryException already declared (message, cause); the subclass exposed only (String), so eight sites across GraphEngine, EdgeLinkedList and StripedEdgeList kept the message and dropped the stack. A conflict is normally absorbed by the retry and never seen, so the single run that does surface one is the retry-exhausted run - exactly the one whose trace has to be diagnosable.

The wrapper preserves the exception class when the retryable is not a conflict (a lock timeout, replication back-pressure), so re-typing to improve a message cannot throw that distinction away. The class on the wire is unchanged, so nothing about HTTP status mapping or the remote driver's typed reconstruction moves; only the detail chain in a development-mode error body gets longer.

3. checkDocuments and checkScopedDocuments report a finding identically

The type-wide arm added to the warnings/corruptedRecords sets without touching totalWarnings/totalCorruptedRecords, so a run listed the finding while reporting zero of both. It also called a document a "vertex" it was "removing", when nothing on that path removes anything (corruptedRecords only drives the end-of-run index rebuild).

Two things the report did not mention, fixed while there: the type-wide arm honoured no maxWarnings cap at all, and its accumulators were declared outside the type loop and re-added to the result after every type (the sets absorbed it; the re-insertions were quadratic in the type count). Both paths now go through a shared addWarning/addCorrupted.

Behaviour change worth noting for anyone parsing CHECK DATABASE output: the message text for an unloadable document, and totalWarnings/totalCorruptedRecords now being non-zero on a type-wide run that finds one.

4. The scoped vertex check runs one pass where the type-wide runs two - and that is correct

Documented, not changed. lookupByRID is the raw-view materialisation the type-wide bucket scan does - the same newImmutableRecord(type, rid, bucket.getRecord(rid).copyOfContent()) - and checkConnectivity opens with the same asVertex(true), whose loadContent flag is what forces the buffer decode. Both halves of the type-wide first pass therefore run per listed RID. LocalBucket.getRecord and LocalBucket.scan resolve placeholders and multi-page chains identically and skip the same slot markers, so no corruption shape reaches one enumeration and not the other.

Adding the pass would have doubled the cost of the scope that exists to be cheap. Pinned by a test that corrupts a record and asserts both scopes report it, so a future change that breaks the equivalence fails there.

Tests

New Issue5764DeleteVertexRepairAdviceTest (4 tests) pins the advice by executing it: the command is parsed out of the exception the delete raised and run verbatim, and the delete must then go through. A message naming the wrong RID, or a command shape the SQL parser does not accept, fails here rather than in production. It also pins the neighbour-vs-self RID choice, the cause chain, and that the force arm never hands out a RID-substituted scoped command.

Two tests added to CheckDatabaseRecordScopeTest for items 3 and 4.

Green: 371 com.arcadedb.graph tests, 802 com.arcadedb.database + com.arcadedb.engine tests, the SQL and index packages. One unrelated flake (LSMVectorIndexRecoveryTest.vectorNeighborsShouldReturnCorrectCountAfterIncrementalInsertAndRebuild, a timing-based inactivity-rebuild assertion) passes on re-run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Puky78GhudfgTHPtYSuFPm

…airs it, and the conflict keeps its cause

Follow-ups from #5680, whose two halves landed separately: #5707 made deleteVertex strict, #5710 added the
CHECK DATABASE RECORD scope. Neither is defective; the seams between them were never closed.

1. The repair advice now names the scoped command with the RID substituted. Split in two, which the report did
   not distinguish: the RECORD scope is the right answer only where the delete was REFUSED and the vertex is
   still there to repair. The force arms log AFTER the record is gone, so a scoped check would name a record
   that no longer exists - they keep the whole-database form and say what the scoped form buys when run first.
   And at the other-end conflict the broken list belongs to the NEIGHBOUR, so that is the RID named.
   The previously bare rethrow now carries the advice instead of only getEdgeHeadChunkForWrite's
   "concurrent commit in flight", which is the diagnosis for the transient case nobody ever sees.

2. ConcurrentModificationException gains the (message, cause) constructor NeedRetryException already declared.
   Eight sites across GraphEngine, EdgeLinkedList and StripedEdgeList kept the message and dropped the stack.
   A conflict is normally absorbed by the retry, so the run that surfaces one is the retry-exhausted run -
   exactly the one whose trace has to be diagnosable. The class on the wire is unchanged.

3. checkDocuments and checkScopedDocuments report a corrupt document identically. The type-wide arm added to
   the warning and corrupted-record SETS without touching totalWarnings/totalCorruptedRecords, called a
   document a "vertex" it was "removing" when nothing on that path removes anything, and honoured no
   maxWarnings cap at all. Both now go through shared addWarning/addCorrupted.

4. The scoped vertex check running one pass where the type-wide runs two is NOT a gap: lookupByRID IS the
   raw-view materialisation (same newImmutableRecord(type, rid, bucket.getRecord(rid).copyOfContent())) and
   checkConnectivity opens with the same asVertex(true) that forces the decode, while getRecord and scan
   resolve placeholders and multi-page chains identically. Documented and pinned by a test rather than
   "fixed" by adding a second pass, which would double the cost of the scope that exists to be cheap.

The advice tests execute what the message says: the command is parsed out of the raised exception and run
verbatim, then the delete must succeed - so a wrong RID or a shape the parser rejects fails here.
@mergify

mergify Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@codacy-production

codacy-production Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 11 complexity

Metric Results
Complexity 11

View in Codacy

🟢 Coverage 80.95% diff coverage · -6.85% coverage variation

Metric Results
Coverage variation ✅ -6.85% coverage variation
Diff coverage ✅ 80.95% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (79b021d) 151294 115828 76.56%
Head commit (1d39b81) 183377 (+32083) 127830 (+12002) 69.71% (-6.85%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#5767) 42 34 80.95%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@claude

claude Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review

Reviewed the full diff. This is high-quality, carefully-reasoned work: it closes the seams between #5707 and #5710 rather than papering over them, the Javadoc explains why each of the four items was handled the way it was (including the one proven a non-issue), and the tests pin behaviour by executing the advice rather than string-matching a template. It follows the repo conventions (final everywhere, class imports, no new deps, @author, license header, tests first).

A few observations, all minor.

1. DatabaseChecker.addCorrupted - the dedup guarantee only holds under the cap

The Javadoc states "a record flagged twice is one corrupted record". That holds while corrupted.size() < maxWarnings (the set does the dedup). Once the set is full, a RID that was never retained falls into the else if (corrupted.contains(rid)) branch, contains is false, and the total is incremented - so the same not-retained RID flagged twice increments totalCorruptedRecords twice.

This is NOT reachable from the type-wide checkDocuments (the bucket scan visits each RID once), but it IS reachable from checkScopedDocuments if a caller names a duplicate RID in a batch that exceeds maxWarnings. Low severity - the doc just slightly overstates the invariant past the cap. If you want it airtight, dedup the scoped RID list up front or soften the method comment to "for as long as the cap allows" (which the class-level Javadoc already hedges).

2. Corrupted set is bounded by maxWarnings, not maxCorrupted

addCorrupted caps the retained set with maxWarnings, while GraphDatabaseChecker.checkVertices carries a separate maxCorrupted. This matches the pre-existing scoped code (which also used maxWarnings), so it is not a regression, but the two knobs reading from different names is easy to trip over later. Worth a one-line comment, or aligning if a follow-up ever threads maxCorrupted here.

3. Test reflection on the LogManager private logger field

readField(LogManager.instance(), "logger") couples the new test to a private field name and would break silently on a rename of that field. Acceptable for a test that has no other seam to capture WARNING output, but a small brittleness to be aware of.

Things done well worth calling out

  • Cause preservation (ConcurrentModificationException(String, Throwable)): correctly scoped - the wire class is unchanged, so HTTP status mapping and the remote driver typed reconstruction are untouched; only the detail chain grows. withRepairAdvice preserves the original class when the retryable is not a CME, so a lock-timeout / back-pressure retryable is never silently re-typed. Good call.
  • otherEndOf best-effort resolution returning null on any RuntimeException, and the caller degrading the advice rather than replacing the original failure - exactly right for enrichment-only code running where the edge read just failed.
  • Neighbour-vs-self RID choice in the other-end conflict is subtle and correct, and pinned by a test asserting the healthy vertex is not the repair target.
  • The force-arm distinction (whole-database advice because the record is already gone) is genuinely different behaviour, correctly separated, with a test asserting the RID-substituted scoped form is never handed out there.
  • Collapsing checkDocuments/checkScopedDocuments onto shared addWarning/addCorrupted fixes the real reporting bug (totals bypassed, "vertex"/"removing" wording) and removes the quadratic per-type re-insertion - a nice incidental cleanup, and the behaviour change is flagged for output parsers.

Nothing here blocks merge; item 1 is the only one I would consider addressing, and even that is a doc-vs-behaviour nuance rather than a bug on any path this PR exercises.

…eflection in the advice test

Three points from the code review on #5767, all minor and none blocking.

1. addCorrupted's "a record flagged twice is one corrupted record" holds only while the retained set is under
   the cap. Behaviour kept (the contains() check past the cap is strictly better than an unconditional
   increment); the Javadoc now says exactly what survives the cap and why closing the gap is not worth it - the
   only exact fix is a second unbounded set of every RID ever counted, i.e. the memory the cap exists to refuse.
   Also recorded that neither caller reaches it: the bucket scan visits each RID once and the RECORD scope is a
   Set, so a duplicate cannot survive as far as groupRecordsByType.

2. The reviewer flagged that the retained set is capped with maxWarnings while the graph arms take a separate
   maxCorrupted. Documented rather than changed: DatabaseChecker has no maxCorrupted field, and checkScopedRecords
   already passes the remaining maxWarnings budget into the GraphDatabaseChecker parameter of that name. Two
   names, one setting.

3. The advice test reached the LogManager logger by reflecting on the private field. LogManager exposes a public
   getLogger() for precisely this case - a caller that swaps the logger and has to put the original back - so the
   reflection helper is gone along with its rename fragility.
@claude

claude Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review

Careful, well-scoped follow-up work. I read the full diff (couldn't run Maven in this sandbox, so the notes below are from static review). Overall this is high-quality: the four items are cleanly separated, each behavioural change is called out for downstream consumers, and the tests pin behaviour by executing the advice rather than string-matching it, which is exactly the right way to keep this from rotting.

Strengths

  • ConcurrentModificationException(String, Throwable) is the right fix and correctly minimal - NeedRetryException already declared the pair, so preserving the class on the wire means HTTP status mapping and remote typed reconstruction are untouched. The retry-exhausted run being the run whose trace must be diagnosable is a good justification.
  • withRepairAdvice preserving the exception class when the retryable is not a ConcurrentModificationException (returning e unchanged) is the correct call - a lock timeout or replication back-pressure must not be re-typed into a conflict just to attach a message. The rewrap still extends NeedRetryException, so retry semantics are unchanged.
  • The neighbour-vs-self RID choice (otherEndOf) is the subtle part and it's handled well: naming the neighbour's RID when the conflict is at the far end, best-effort resolution wrapped in a catch (RuntimeException) that degrades the advice rather than replacing the original failure, and a dedicated test (aConflictRaisedByTheNeighbourNamesTheNeighbourAndNotTheVertexBeingDeleted).
  • The force-arm distinction (whole-DB CHECK DATABASE FIX because the record is already gone by the time it logs) is correct and the aForcedDeleteAdvisesTheWholeDatabaseFix... test locks in that a RID-substituted scoped command is never handed out there.
  • checkDocuments/checkScopedDocuments unification genuinely fixes three real defects: the totals divergence (findings listed but totalWarnings/totalCorruptedRecords reported zero once the sets filled), the "vertex ... removing it" message on a path that removes nothing, and the missing maxWarnings cap. Collapsing the two onto shared addWarning/addCorrupted and dropping the quadratic per-type re-addAll is a nice bonus.
  • addCorrupted's exact-under-cap / degraded-past-cap dedup is reasoned through in the Javadoc, and the reasoning (a second unbounded set is exactly the memory the cap refuses; neither caller reaches the degraded path today) holds up.

Minor observations (non-blocking)

  1. addCorrupted caps the corrupted set on maxWarnings, not maxCorrupted. This matches the pre-existing scoped-document behaviour so it's not a regression, and the Javadoc explains it ("Two names, one setting"). But it's a slightly surprising coupling: on the same run, GraphDatabaseChecker's arms bound corruptedRecords retention by maxCorrupted while the document arm bounds the same set by maxWarnings. Worth a one-line note at the field/caller level so a future reader doesn't "fix" the apparent inconsistency. Since retained corruptedRecords drives the end-of-run index rebuild, the cap choice has a real (if edge-case) effect on which corrupt documents get their indexes rebuilt.

  2. aForcedDeleteAdvisesTheWholeDatabaseFix... swaps the process-wide LogManager logger. It's correctly restored in a finally, but the global swap would interfere with any test running concurrently in the same JVM. ArcadeDB's suite runs classes sequentially per fork today, so this is fine as-is; just flagging it as a latent fragility if class-level parallelism is ever enabled. Capturing via a per-invocation hook would avoid the shared-state window.

  3. In hasNextEdgeToDelete and getEdgeHeadChunkForWrite the message already interpolates e.getMessage() and now also passes e as the cause - so the original text appears both inline and in the cause chain. Harmless, just slightly redundant; the cause is the part that matters for the trace.

Tests

Good coverage for the changed behaviour: the refused/neighbour/cause-chain/forced cases each have a dedicated test, and items 3 and 4 are pinned in CheckDatabaseRecordScopeTest. The theScopedAndTypeWideRunsAgreeOnAGenuinelyCorruptedRecord test is a good guard against a future change silently breaking the one-pass/two-pass equivalence that item 4 documents.

Nice work - the departures from the original report (three sites keeping the whole-DB form, neighbour RID at the far-end conflict) are the right calls and are each justified in code comments.

…d why the interpolated cause is not redundant

Three non-blocking observations from the second review on #5767. All three resolve to recording constraints a
future reader would otherwise have to rediscover - one of them by breaking a test.

1. maxWarnings caps the corrupted set while GraphDatabaseChecker takes a maxCorrupted for the SAME set. The
   method Javadoc said "two names, one setting"; the note now lives on the field, where a reader meets it, and
   adds the consequence the reviewer pointed out: retained corruptedRecords become affectedBuckets, so a record
   dropped past the cap does not get its bucket's indexes rebuilt under FIX.

2. The advice test swaps the process-wide LogManager logger. Restored in a finally and safe under sequential
   class execution, but it is shared state; documented as a latent constraint if class-level parallelism is ever
   enabled, along with why there is no per-invocation seam to capture through instead.

3. getEdgeHeadChunkForWrite and hasNextEdgeToDelete interpolate e.getMessage() AND keep e as the cause, which
   reads as redundant. It is not: the missing CHUNK's RID appears ONLY in the record-not-found message - the
   surrounding text names the vertex - and the top-level message is what a log line and an HTTP error body carry,
   while the cause chain surfaces only in a full trace. Removing it would drop the RID and fail
   Issue5670EdgeDeleteDanglingBackRefTest, which asserts on it. Commented at both sites.
@claude

claude Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review: #5764 - refused vertex delete names its repair command, conflict keeps its cause

I read the full diff plus the surrounding code in GraphEngine.deleteVertex / collectEdgesToDelete, DatabaseChecker, and both test files against the engine conventions. This is a careful, well-reasoned change: the four items are cleanly separated, each with a rationale that matches what the code actually does, and the split between "delete refused -> scoped CHECK DATABASE RECORD <rid>" and "force delete went through -> whole-database CHECK DATABASE FIX" is correct. The neighbour-vs-self RID choice is right, and the test that executes the emitted command (rather than just string-matching it) is exactly the kind of test that keeps advice honest. Nice work.

A few observations, all minor - nothing blocking.

Correctness / robustness

  • withRepairAdvice with a null cause message (GraphEngine.java:840): the new message is built as e.getMessage() + ". If it persists...". In practice the wrapped ConcurrentModificationException always carries a message, so this is fine today, but a null would render "null. If it persists...". Cheap to guard if you want it defensive.

  • otherEndOf and self-loops (GraphEngine.java:852): for a self-loop edge (out == in == vertexRID) this returns in, i.e. the vertex under delete. That is actually the correct answer here - the broken list is that vertex's own - so no bug, just noting it because the method name ("the endpoint that is not vertexRID") reads as if it could never return vertexRID, and a future reader might "fix" that.

  • otherEndOf computed unconditionally (GraphEngine.java:740): it runs before the if (!force) branch, so on the refused path it executes edge.asEdge() on every retry iteration, including the transient conflicts that will be silently retried. This is the exception/slow path and asEdge() is light, so the cost is negligible - flagging only for completeness.

DatabaseChecker counter semantics

  • The new shared addWarning/addCorrupted is a genuine improvement: it closes the "listed the finding but reported zero totals" divergence and removes the quadratic re-insertion of the per-type accumulators. Good catch on both.
  • addCorrupted's past-the-cap double-count is already documented in the Javadoc (DatabaseChecker.java:488), and neither current caller can reach it (bucket scan visits each RID once; the RECORD scope is a Set). Agreed it is not worth a second unbounded set. The asymmetry with addWarning (which always increments) is also fine since the two counters mean different things.
  • Behaviour change is correctly called out in the release note and the doc comment: the "document <rid> cannot be loaded" text and non-zero totals on a type-wide run are worth the heads-up for anyone parsing CHECK DATABASE output.

Cause-chain constructor

  • Adding (String, Throwable) to ConcurrentModificationException and threading e through the eight call sites is the right, minimal change. It matches the engine CLAUDE.md note that ConcurrentModificationException extends NeedRetryException and that the class on the wire must not change - preserving the class in withRepairAdvice (rather than re-typing an arbitrary NeedRetryException) respects the retryable-but-not-a-conflict distinction. Good.

Tests

  • Executing the parsed command and asserting the delete then succeeds is strong. Neighbour-vs-self, the cause chain, and the "force arm never hands out a substituted scoped RID" cases are all covered.
  • The process-wide LogManager.setLogger swap in aForcedDeleteAdvises... is honestly documented as shared state with a finally restore and CopyOnWriteArrayList. As noted, it is only safe because surefire runs classes sequentially within a fork; if class-level parallelism is ever enabled in this module it would need revisiting. Acceptable given there is no per-invocation logging seam.
  • theScopedAndTypeWideRunsAgreeOnAGenuinelyCorruptedRecord pinning the one-pass/two-pass equivalence is a good regression guard for item 4.

Notes

  • I reviewed statically and did not run the full reactor build locally; the PR reports the graph/database/engine/sql/index packages green, which covers the touched code.
  • No security or licensing concerns (no new dependencies), and the changes are confined to error/diagnostic paths and the checker's reporting, so no hot-path performance impact.

Overall: LGTM. The points above are optional polish, not requests.

…why otherEndOf can equal the vertex

Two of the three optional-polish points from the third review on #5767 (which was LGTM).

1. withRepairAdvice built the message as e.getMessage() + advice. Every conflict on this path carries a message
   today, but a message-less one would render "null. If it persists...", which reads as a bug in the advice rather
   than as a missing diagnosis. Falls back to toString(), i.e. the class name.

2. otherEndOf would answer vertexRID itself for a self-loop, which the method name reads as impossible. That is
   the correct answer - a self-loop has no other end and the list that failed to disconnect it IS the vertex's own
   - so the equality is documented rather than "simplified" away. Also recorded why there is no test: the caller
   runs only after both of the vertex's lists have been collected, and a self-loop is read out of those same two
   lists, so a list broken enough to fail the disconnection fails the collection first.

Not taken: the reviewer flagged that otherEndOf is computed before the force branch, so it runs on every retry of
a transient conflict. Both branches need the value, so moving it saves nothing - and the reviewer scoped it as
"for completeness" on an exception path where asEdge() is light.
@claude

claude Bot commented Aug 2, 2026

Copy link
Copy Markdown

Code Review

Reviewed the full diff and traced the touched code paths in GraphEngine, DatabaseChecker, and the two test classes. This is a high-quality, defensively-reasoned change that closes the seams between #5707 and #5710. Overall: LGTM. Notes below are mostly confirmations plus a few small observations, none blocking.

Strengths

  • Correct RID selection at each site. The neighbour-vs-self distinction is right: collectEdgesToDelete succeeds on the vertex's own lists before the disconnect loop runs, so a conflict from edge.asEdge().delete() is on the other end's list, and otherEndOf(edge, mostUpdatedVertex) names exactly that. The refused-own-list arm names vertex.getIdentity(). Verified against the two dedicated tests, which execute the emitted command and require the delete to then go through - a genuinely strong form of pinning.
  • Class preservation in withRepairAdvice. Guarding on instanceof ConcurrentModificationException and returning e unchanged for any other NeedRetryException (lock timeout, replication back-pressure) is the right call - it keeps HTTP status mapping and remote typed reconstruction intact while only enriching the message.
  • (message, cause) constructor. Clean, minimal, and the eight call sites are consistently updated. NeedRetryException already declared the pair, so this is purely additive.
  • addWarning/addCorrupted unification. Removing the per-type local accumulators and the quadratic re-addAll after every type is a real improvement, and routing both document paths through shared helpers fixes the totals/cap divergence. The past-cap dedup degradation in addCorrupted is documented honestly and is not reachable by either current caller.

Minor observations (non-blocking)

  1. Behaviour change to CHECK DATABASE output is real and worth the release-note callout it already got: the unloadable-document message text changed (vertex ... removing it -> document ... cannot be loaded) and totalWarnings/totalCorruptedRecords are now non-zero on a type-wide run. Anyone parsing that output programmatically will see it. Documented, so this is just a flag for reviewers.
  2. CapturingLogger swaps the process-wide LogManager singleton. The author already documented the latent constraint (safe only under sequential class execution). Agreed there's no per-invocation seam to capture through today; the finally restore plus the doc note is the reasonable choice. Just noting it as the one piece of shared-state risk in the new tests.
  3. warnings is a Set<String> while totalWarnings counts occurrences, so identical warning strings inflate the total past the retained set size. Pre-existing behaviour, not introduced here, but the new type-wide path now feeds it - worth being aware of if the totals are ever asserted for exactness.
  4. Thread-safety is fine: LocalBucket.scan is single-threaded, so the shared mutation of result/LinkedHashSet in addWarning/addCorrupted from the scan callback carries no new concurrency hazard (the prior local-collection code had the same assumption).

Test coverage

Excellent. The advice tests execute the parsed command rather than string-matching it, which catches both a wrong RID and a parser-rejected shape. The scoped-vs-type-wide equivalence test (item 4) pins the one-pass/two-pass claim so a future divergence fails loudly. The forced-delete test correctly asserts the scoped form is never handed out with a substituted RID.

Style / conventions

Consistent with the repo: final on params and locals, imported types (no FQNs), single-statement if without braces, JSON not involved. The Javadoc is unusually verbose even by this codebase's standards, but it matches the surrounding GraphEngine/DatabaseChecker idiom and every claim I spot-checked (LogManager.getLogger(), getGraphEngine(), the maxWarnings->maxCorrupted budget passing at lines 455/458) is accurate.

Nice work closing this cleanly with proving-not-fixing on item 4.

@lvca lvca self-assigned this Aug 2, 2026
@lvca lvca added this to the 26.8.1 milestone Aug 2, 2026
@lvca
lvca merged commit c7349f8 into main Aug 2, 2026
25 of 26 checks passed
@lvca
lvca deleted the issue-5764-deletevertex-repair-advice branch August 2, 2026 18:23
@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.28571% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.77%. Comparing base (79b021d) to head (1d39b81).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
.../src/main/java/com/arcadedb/graph/GraphEngine.java 60.86% 4 Missing and 5 partials ⚠️
...main/java/com/arcadedb/engine/DatabaseChecker.java 62.50% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5767      +/-   ##
==========================================
+ Coverage   67.75%   67.77%   +0.01%     
==========================================
  Files        1782     1783       +1     
  Lines      151294   151331      +37     
  Branches    32091    32100       +9     
==========================================
+ Hits       102503   102558      +55     
+ Misses      35505    35480      -25     
- Partials    13286    13293       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

robfrank pushed a commit that referenced this pull request Aug 14, 2026
…airs it, and the conflict keeps its cause (#5767)

* fix(engine) #5764: a refused vertex delete names the command that repairs it, and the conflict keeps its cause

Follow-ups from #5680, whose two halves landed separately: #5707 made deleteVertex strict, #5710 added the
CHECK DATABASE RECORD scope. Neither is defective; the seams between them were never closed.

1. The repair advice now names the scoped command with the RID substituted. Split in two, which the report did
   not distinguish: the RECORD scope is the right answer only where the delete was REFUSED and the vertex is
   still there to repair. The force arms log AFTER the record is gone, so a scoped check would name a record
   that no longer exists - they keep the whole-database form and say what the scoped form buys when run first.
   And at the other-end conflict the broken list belongs to the NEIGHBOUR, so that is the RID named.
   The previously bare rethrow now carries the advice instead of only getEdgeHeadChunkForWrite's
   "concurrent commit in flight", which is the diagnosis for the transient case nobody ever sees.

2. ConcurrentModificationException gains the (message, cause) constructor NeedRetryException already declared.
   Eight sites across GraphEngine, EdgeLinkedList and StripedEdgeList kept the message and dropped the stack.
   A conflict is normally absorbed by the retry, so the run that surfaces one is the retry-exhausted run -
   exactly the one whose trace has to be diagnosable. The class on the wire is unchanged.

3. checkDocuments and checkScopedDocuments report a corrupt document identically. The type-wide arm added to
   the warning and corrupted-record SETS without touching totalWarnings/totalCorruptedRecords, called a
   document a "vertex" it was "removing" when nothing on that path removes anything, and honoured no
   maxWarnings cap at all. Both now go through shared addWarning/addCorrupted.

4. The scoped vertex check running one pass where the type-wide runs two is NOT a gap: lookupByRID IS the
   raw-view materialisation (same newImmutableRecord(type, rid, bucket.getRecord(rid).copyOfContent())) and
   checkConnectivity opens with the same asVertex(true) that forces the decode, while getRecord and scan
   resolve placeholders and multi-page chains identically. Documented and pinned by a test rather than
   "fixed" by adding a second pass, which would double the cost of the scope that exists to be cheap.

The advice tests execute what the message says: the command is parsed out of the raised exception and run
verbatim, then the delete must succeed - so a wrong RID or a shape the parser rejects fails here.

* review: state addCorrupted's dedup guarantee honestly, and drop the reflection in the advice test

Three points from the code review on #5767, all minor and none blocking.

1. addCorrupted's "a record flagged twice is one corrupted record" holds only while the retained set is under
   the cap. Behaviour kept (the contains() check past the cap is strictly better than an unconditional
   increment); the Javadoc now says exactly what survives the cap and why closing the gap is not worth it - the
   only exact fix is a second unbounded set of every RID ever counted, i.e. the memory the cap exists to refuse.
   Also recorded that neither caller reaches it: the bucket scan visits each RID once and the RECORD scope is a
   Set, so a duplicate cannot survive as far as groupRecordsByType.

2. The reviewer flagged that the retained set is capped with maxWarnings while the graph arms take a separate
   maxCorrupted. Documented rather than changed: DatabaseChecker has no maxCorrupted field, and checkScopedRecords
   already passes the remaining maxWarnings budget into the GraphDatabaseChecker parameter of that name. Two
   names, one setting.

3. The advice test reached the LogManager logger by reflecting on the private field. LogManager exposes a public
   getLogger() for precisely this case - a caller that swaps the logger and has to put the original back - so the
   reflection helper is gone along with its rename fragility.

* review: record the maxWarnings/maxCorrupted coupling at the field, and why the interpolated cause is not redundant

Three non-blocking observations from the second review on #5767. All three resolve to recording constraints a
future reader would otherwise have to rediscover - one of them by breaking a test.

1. maxWarnings caps the corrupted set while GraphDatabaseChecker takes a maxCorrupted for the SAME set. The
   method Javadoc said "two names, one setting"; the note now lives on the field, where a reader meets it, and
   adds the consequence the reviewer pointed out: retained corruptedRecords become affectedBuckets, so a record
   dropped past the cap does not get its bucket's indexes rebuilt under FIX.

2. The advice test swaps the process-wide LogManager logger. Restored in a finally and safe under sequential
   class execution, but it is shared state; documented as a latent constraint if class-level parallelism is ever
   enabled, along with why there is no per-invocation seam to capture through instead.

3. getEdgeHeadChunkForWrite and hasNextEdgeToDelete interpolate e.getMessage() AND keep e as the cause, which
   reads as redundant. It is not: the missing CHUNK's RID appears ONLY in the record-not-found message - the
   surrounding text names the vertex - and the top-level message is what a log line and an HTTP error body carry,
   while the cause chain surfaces only in a full trace. Removing it would drop the RID and fail
   Issue5670EdgeDeleteDanglingBackRefTest, which asserts on it. Commented at both sites.

* review: guard the advice against a message-less conflict, and record why otherEndOf can equal the vertex

Two of the three optional-polish points from the third review on #5767 (which was LGTM).

1. withRepairAdvice built the message as e.getMessage() + advice. Every conflict on this path carries a message
   today, but a message-less one would render "null. If it persists...", which reads as a bug in the advice rather
   than as a missing diagnosis. Falls back to toString(), i.e. the class name.

2. otherEndOf would answer vertexRID itself for a self-loop, which the method name reads as impossible. That is
   the correct answer - a self-loop has no other end and the list that failed to disconnect it IS the vertex's own
   - so the equality is documented rather than "simplified" away. Also recorded why there is no test: the caller
   runs only after both of the vertex's lists have been collected, and a self-loop is read out of those same two
   lists, so a list broken enough to fail the disconnection fails the collection first.

Not taken: the reviewer flagged that otherEndOf is computed before the force branch, so it runs on every retry of
a transient conflict. Both branches need the value, so moving it saves nothing - and the reviewer scoped it as
"for completeness" on an exception path where asEdge() is light.

(cherry picked from commit c7349f8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-ups from #5680: point the repair advice at CHECK DATABASE RECORD, keep the conflict's cause, and two checker asymmetries

1 participant