Repository navigation
fix(engine) #5764: a refused vertex delete names the command that repairs it, and the conflict keeps its cause - #5767
Conversation
…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.
|
Tick the box to add this pull request to the merge queue (same as
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 11 |
🟢 Coverage 80.95% diff coverage · -6.85% coverage variation
Metric Results Coverage variation ✅ -6.85% coverage variation Diff coverage ✅ 80.95% diff coverage 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.
|
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. The Javadoc states "a record flagged twice is one corrupted record". That holds while This is NOT reachable from the type-wide 2. Corrupted set is bounded by
3. Test reflection on the
Things done well worth calling out
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.
ReviewCareful, 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
Minor observations (non-blocking)
TestsGood 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 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.
Review: #5764 - refused vertex delete names its repair command, conflict keeps its causeI read the full diff plus the surrounding code in A few observations, all minor - nothing blocking. Correctness / robustness
|
…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.
Code ReviewReviewed the full diff and traced the touched code paths in Strengths
Minor observations (non-blocking)
Test coverageExcellent. 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 / conventionsConsistent with the repo: Nice work closing this cleanly with proving-not-fixing on item 4. |
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
…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)
Closes #5764.
Follow-ups from #5680, whose two halves landed separately (#5707 made
deleteVertexstrict, #5710 added theCHECK DATABASE RECORDscope). 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.deleteVertexemitted 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 wasgetEdgeHeadChunkForWrite's "concurrent commit in flight", which says nothing about recovery.Departure from the report's suggestion. Naming
CHECK DATABASE RECORD <rid> FIXat 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. Theforcearms 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:
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.
ConcurrentModificationExceptioncarries the failure that produced itNeedRetryExceptionalready declared(message, cause); the subclass exposed only(String), so eight sites acrossGraphEngine,EdgeLinkedListandStripedEdgeListkept 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
detailchain in a development-mode error body gets longer.3.
checkDocumentsandcheckScopedDocumentsreport a finding identicallyThe type-wide arm added to the
warnings/corruptedRecordssets without touchingtotalWarnings/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 (corruptedRecordsonly drives the end-of-run index rebuild).Two things the report did not mention, fixed while there: the type-wide arm honoured no
maxWarningscap 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 sharedaddWarning/addCorrupted.Behaviour change worth noting for anyone parsing
CHECK DATABASEoutput: the message text for an unloadable document, andtotalWarnings/totalCorruptedRecordsnow 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.
lookupByRIDis the raw-view materialisation the type-wide bucket scan does - the samenewImmutableRecord(type, rid, bucket.getRecord(rid).copyOfContent())- andcheckConnectivityopens with the sameasVertex(true), whoseloadContentflag is what forces the buffer decode. Both halves of the type-wide first pass therefore run per listed RID.LocalBucket.getRecordandLocalBucket.scanresolve 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 theforcearm never hands out a RID-substituted scoped command.Two tests added to
CheckDatabaseRecordScopeTestfor items 3 and 4.Green: 371
com.arcadedb.graphtests, 802com.arcadedb.database+com.arcadedb.enginetests, 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