Repository navigation
fix(#6359): a propagated index joins the transaction that wrote the records, a negative literal is a number, and two modules that cannot share a Maven invocation - #6364
Conversation
…ecords, and a negative literal is a number Three findings collected while fixing #6324, none of which was that issue's to fix. Item 1 - an index propagated to a super type's existing buckets missed uncommitted records. #6324 made CREATE INDEX see the writes of the transaction it runs in, through TypeIndexBuilder and BucketIndexBuilder. LocalDocumentType.addSuperType uses neither: it calls LocalSchema.createBucketIndex directly, over buckets that ALREADY hold records, and still built in a transaction of its own. A caller that inserts and then links a super type in one transaction got exactly #6324's shape back - an index that is readable, reported healthy by CHECK DATABASE, and answers the lookup it exists for with nothing. It now takes the same two-transaction split: the components are created and committed on their own, then the builds join the caller's transaction. The predicate and the two steps it needs live once in IndexBuilder (callerTransactionHasChanges, buildCreatedIndex, dropPartiallyBuiltIndex) rather than being written a third time, and BucketIndexBuilder's private copy of the cleanup is gone. The transaction half of the predicate has to be asked BEFORE anything is opened: inside the component-creation transaction there is always one, it is empty, and the answer would always be no. The sibling call site in createBucket() is left alone deliberately, and now says why: the bucket it indexes has just been created, so no transaction can hold uncommitted writes into it and there is nothing for the scan to miss. Item 2 - a negative numeric literal rendered as an arithmetic expression. A unary minus was modelled as a subtraction from zero, so the AST for -1 was 0 - 1 and that is what Expression.toString() produced. The rendering is not cosmetic: it is what EXPLAIN prints, what an unaliased projection is named after, and what a statement re-reading one of its own settings parses - REBUILD INDEX ... WITH batchSize = -1 reached Integer.parseInt as the string "0 - 1" and came back as a raw NumberFormatException naming neither the setting nor the problem. The minus is now folded into the literal. It negates the already-parsed value rather than re-parsing a "-"-prefixed text, so the folded literal keeps exactly the numeric type 0 - X used to produce and the sign lands correctly on every literal shape; a literal carrying a modifier is left alone, since a suffix binds tighter than the sign. The parentheses a statement was written with are kept too, for the same round-trip reason: (1 + 2) * 3 rendered as 1 + 2 * 3, which is 7 rather than 9 when read back. Only parentheses that carry meaning are printed - around an atom they are decoration, and printing them would rename every unaliased projection written that way (SELECT (name) FROM V has always been a column called name). And the numeric-setting readers are unified on DDLStatement.parsePositiveIntSetting, next to the boolean one that was already shared. That also fixes REBUILD TYPE ... WITH batchSize, which read Expression.value - null for every numeric literal the parser builds - and so refused every value it was given, legal ones included, with "got: null". Item 3 - graphql and gremlin could not share one Maven invocation. Pre-existing and invisible in CI, where the lanes run each module separately. It is the trap already documented for arcadedb-gremlin-it, one module wider: Maven substitutes the reactor module for the shaded-classified dependency, the test phase never runs the shade plugin, and the plain target/classes that stands in for it carries no TinkerPop. mvn -o verify -pl gremlin,graphql is green where mvn -o test is not. Documented in CLAUDE.md's build-traps section, and the engine now names the real problem instead of leaving a NoClassDefFoundError under a message that points at the engine.
|
Tick the box to add this pull request to the merge queue (same as
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 29 |
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.
ReviewI read through the three fixes end-to-end (index propagation transaction split, negative-literal/parentheses rendering, Gremlin classpath hint) plus the new regression tests. Overall this is careful, well-reasoned work with strong regression coverage for the exact failure shapes described in the issue. A few notes, nothing I'd call a hard blocker. Item 1 —
|
…, so the refusal reaches the caller Both points from the code review on PR #6364, and the first one turned out to be a bug rather than a coverage gap. The review asked for a regression test on the DuplicatedKeyException the join-transaction catch block already anticipates - a caller that inserts two records violating a unique super-type index and then links the super type. Writing it showed the exception never reached the caller at all: LocalDatabase.transaction retries a duplicate exactly once (#4959), and on that retry addSuperType found the super type already in superTypes, returned early without propagating anything, and let the transaction COMMIT. Measured result was a linked super type with entries=0 whose lookup answered nothing - this issue's own defect, reached through the retry instead of through the scan. So the failure path now hands the in-memory linkage back too, not only the half-built components: unlinkSuperType undoes superTypes/subTypes and the polymorphic bucket caches, passing back exactly the lists that were handed over (the caches are replaced rather than mutated). The retry is then a real attempt, and its refusal is what the caller gets. The paired external buckets ensureExternalBucketsRecursive may have created are deliberately left: additive, idempotent, and reused by the next attempt. The second point was a diagnostic asymmetry: DuplicatedKeyException and NeedRetryException are not IndexException, so they escaped the catch that names which super type's propagation they came out of. The catch is RuntimeException now, so every failure shape gets the context line. Issue6359SuperTypeIndexPropagationTest gains a sixth test asserting all of it: the exception reaches the caller, the type is left unlinked, the caller's records went with the rollback, no sub-index survives on the bucket the failed build scanned, the super type's own index still works, and the link can still be made once the conflict is gone.
ReviewReviewed all three items in this PR (index propagation transaction split, negative-literal/parenthesis rendering, gremlin/graphql classpath diagnosis) plus the two new/updated test suites. Overall this is a well-documented, well-tested PR; the comments in the diff do a lot of the reviewer's work already. A few things worth a second look before merge. 1. Possible incomplete cleanup on a partial
|
… a numeric setting is evaluated rather than rendered Both points from the second code review on PR #6364. The first asked whether a mixed-family propagation can leave an orphaned component: a super type carrying both a vector index and an ordinary one, where the vector sub-index is built INLINE during component creation (its family cannot share the caller's transaction) while the ordinary one fails the joined build. It can, and measuring it found two causes rather than one. The cleanup was keyed on the pending-build list, which by construction never contains an index that was built inline. It now tracks every sub-index the propagation created, and that is the list the refusal takes away. The larger cause was underneath: LSMVectorIndex.getTypeIndex() answered null, with the comment "Not applicable for this index type", which was never true - a vector index IS registered under a TypeIndex, and LSMSparseVectorIndex has always wired it. The null made two callers do the wrong thing. LocalSchema.dropIndexInternal skips parentTypeIndex.removeIndexOnBucket(...) when it is null, so a dropped vector sub-index stayed listed by its wrapper - a reference to an index that no longer exists, on EVERY path that drops one, not only this one. And LocalDocumentType.addSuperType compares it to decide whether a super type's index is already propagated to a bucket, so it never recognised one and minted a duplicate on every attempt. Measured before the fix: two orphaned vector sub-indexes on the subtype's bucket, one per attempt. The second point was that the numeric-setting reader renders the expression, so a bound parameter resolves to its placeholder text rather than to the number bound. Rendering was only ever a workaround for Expression.value being null on numeric literals; EVALUATING covers literals and parameters alike, which is what parseBooleanSetting next to it has always taken. parsePositiveIntSetting now takes the evaluated value, its callers pass expression.execute((Result) null, context), and REBUILD INDEX's statsOnly moves to parseBooleanSetting for the same reason - Boolean.parseBoolean on a rendered placeholder silently answered false. Two regression tests: the mixed vector/LSM refusal leaving neither wrapper holding a sub-index on the subtype's bucket, and a bound parameter accepted for batchSize on both REBUILD statements and refused by its bound value when it is not a legal batch size.
|
Review of #6364 Reviewed the three items in this PR (super-type index propagation transaction split, negative-literal/parentheses rendering, gremlin/graphql Maven-invocation trap). The negative-literal folding, parentheses tracking, and the shared parsePositiveIntSetting/parseBooleanSetting readers all look correct - traced the overflow-literal interaction (tryFoldLongMinValueLiteral runs before tryNegateNumericLiteral and short-circuits, so no double-handling), the copy()/splitForAggregation() propagation of the new parenthesized flag, and the gremlin classpath-hint matching. Good test coverage on those two items. Two things worth a look on item 1 (LocalDocumentType.addSuperType, engine/src/main/java/com/arcadedb/schema/LocalDocumentType.java): 1. The propagation build isn't quiesced against async writers, unlike its siblings TypeIndexBuilder.create() and BucketIndexBuilder.create() both wrap their build in try (AsyncQuiesce asyncPaused = database.quiesceAsync()) specifically because of issue #6303: a record written by an async worker in the window between the barrier and the index's registration is invisible to both the scan and the index, since it started before registration but wasn't committed at scan time either. The new propagation path in addSuperType (lines ~1999-2069) calls schema.createBucketIndex(...) directly and never calls quiesceAsync(). Since this path exists specifically to close the same class of index-misses-records gap that #6324/#6359 item 1 is about, it looks like it reopens the #6303 sub-case for async-inserted records specifically: a database.async() insert into a bucket that's mid-propagation could land in the same missed window TypeIndexBuilder was fixed to avoid. Worth confirming this is intentionally out of scope (e.g. because addSuperType is assumed never to race an async writer) or adding the same quiesceAsync() guard for consistency. None of the new regression tests exercise an async writer, so this wouldn't currently be caught either way. 2. created/toBuild accumulate across an internal retry of the component-creation transaction The relevant shape (around line 2006 onward): created/toBuild are declared outside the database.transaction(..., false) call, so if that inner transaction internally retries on NeedRetryException (e.g. a page-version conflict from a concurrent schema mutation - checkForSchemaMutation() only checks permissions, it doesn't take a lock), the lambda re-runs from scratch on the next attempt but the two lists are never cleared. The failed attempt's Index objects (now rolled back and non-existent) stay in both lists alongside the successful attempt's objects. For created this is harmless (dropPartiallyBuiltIndex guards with schema.existsIndex(...)), but toBuild entries feed straight into IndexBuilder.buildCreatedIndex(subIndex, ...) -> internal.setStatus(...) / internal.build(...) with no existence check, on an Index object whose backing component was already rolled back. That's a plausible source of a confusing failure unrelated to the actual conflict, in an admittedly narrow window (needs the component-creation transaction itself to retry, not the caller's transaction - TypeIndexBuilder's equivalent loop avoids this by assigning into a pre-sized array by index rather than appending to a list, so a retry just overwrites rather than accumulates). Neither of these came up in the three commits' own regression tests (which is expected given both need a concurrent/async trigger to manifest), but given how carefully the transaction-sharing semantics were reasoned about elsewhere in this PR, they seemed worth flagging rather than assuming out of scope. Everything else - the IndexBuilder refactor (callerTransactionHasChanges/buildCreatedIndex/dropPartiallyBuiltIndex consolidation), the unlinkSuperType rollback-of-linkage-on-failure logic (nice catch on the retry-swallows-the-exception case in the second commit), and the LSMVectorIndex.getTypeIndex() fix - all check out against the code they touch. |
…s start empty on every attempt Both points from the third code review on PR #6364. The propagation build was not quiesced against async writers, unlike TypeIndexBuilder and BucketIndexBuilder, which hold quiesceAsync() for exactly this (issue #6303, item 2): the barrier answers about the past, and a build needs the other half too - that nothing WRITES during the scan. A record an async worker saves in the window between the barrier and the sub-index's registration is in neither the scan nor the index, which is the gap this propagation exists to close, reopened for async writers. WHERE the quiescence is taken is the whole of it, and the first attempt got it wrong in a way the new test caught. Taken around the propagation itself it sits inside recordFileChanges, which runs under the database WRITE LOCK - the lock an async worker needs to commit its batch. The quiescence then waits for workers that cannot proceed until it returns, and gives up sixty seconds later with a NeedRetryException. It is taken around the recordFileChanges call instead, which is where both builders take it, and only when there are indexes to propagate: the schema-load path passes createIndexes=false and scans nothing. The regression test went from failing at 85s to passing at 0.44s. The second point was that `created` and `toBuild` were declared outside the component-creation transaction and never cleared, so an internal retry of that transaction - a NeedRetryException from a concurrent schema mutation re-runs the lambda from scratch - left the rolled-back attempt's indexes in both lists. For `created` that is harmless, since dropPartiallyBuiltIndex checks existence; `toBuild` feeds buildCreatedIndex, which does not, so the surviving attempt would report a failure that has nothing to do with the conflict that caused the retry. Both lists are emptied on entry to the lambda, which is the effect TypeIndexBuilder gets for free by assigning into a pre-sized array by position. Adds the async-writer regression test the review noted was missing: a thousand records in flight through database.async() while the super type is linked, asserting the propagated index ends with an entry for every one of them.
ReviewReviewed the full diff (engine + gremlin changes, plus the two new test classes). This is a well-scoped, well-tested PR, and the PR description itself documents that three rounds of review already caught and fixed real bugs (the Item 1 - super type index propagation (
|
…only on the one the propagation raises The one actionable note from the fourth code review on PR #6364. It was flagged as out of scope with an offer to file a follow-up, but the machinery to close it is what the previous commit already built, so it is closed here rather than left. Linking a super type applies the linkage first - superTypes, subTypes, the polymorphic bucket caches - and then does three things that can each still refuse: pairing external buckets for a super type that has external properties, propagating the super type's indexes, and inheriting its bucket selection strategy. Only the middle one rolled the linkage back, so a refusal from either of the others handed the caller a type that IS a subtype with none of what being one implies. The guard now wraps the whole post-linkage region instead of the propagation alone, and unlinkSuperType is called from there. The propagation's own catch keeps what is its own: dropping the sub-indexes it created and naming the super type in the log. Measured on the third of those paths, which is the one reachable without a fault injection: a partition that is legal on the super type and unsuitable for the subtype, whose own index on the partition key is declared COLLATE CI (#5637). It refuses with that message and now leaves both sides of the link as it found them, and a subtype the partition IS suitable for still links afterwards - the refusal takes nothing away permanently.
ReviewThis is a well-scoped, well-tested fix (five commits, each closing a gap the previous review round found — the commit messages document that process clearly). I focused on the parts most likely to still hide something after four review passes: the transaction-splitting logic in Correctness: a later refusal in
|
…only on the propagation's own The point from the fifth code review on PR #6364, and it was right: the previous commit widened the LINK rollback to cover every refusal but left the INDEX cleanup where it was. `created` was scoped to the index-propagation block, so it only reached the cleanup when the propagation itself was what refused. The step after it can refuse too - inheriting a bucket selection strategy the subtype cannot take (#5637) - and by then the propagated sub-indexes are committed and attached to the super type's TypeIndex. The outer guard unlinked the type and left them there: a super type whose index points at buckets belonging to a type that is no longer its subtype, which is the same "healthy-looking index inconsistent with the schema" shape this issue exists to close, reached through the third failure path instead of the first. It is hoisted to the outer guard's scope, and the outer catch drops every sub-index the propagation attached before handing the link back. The propagation's own catch keeps only what is its own: naming which super type's propagation the failure came out of. The regression test for that path already existed - it asserted the link went back - and simply did not look at the indexes. It does now, and it fails without this commit.
ReviewI went through this diff (all 6 commits collapsed) independently of the review rounds already recorded in the commit history. Summary: the fixes are well-targeted, each is backed by a focused regression test, and I did not find a new correctness bug. A few observations below, none blocking. Item 1 - addSuperType index propagation
Item 2 - negative literal folding
Item 3 - Gremlin/GraphQL classpath hint
LSMVectorIndex.getTypeIndex() - worth double-checking scope The PR description calls out two callers this fix affects (LocalSchema.dropIndexInternal, LocalDocumentType.addSuperType), but getTypeIndex() on a vector bucket sub-index previously always returned null, and it has quite a few more callers across the engine: DatabaseChecker's CHECK-FIX rebuild path, RebuildIndexStatement's owner-name preservation, FetchFromSchemaIndexesStep's typeIndexName reporting, and three call sites in TransactionIndexContext for unique-index handling. I traced through each:
So nothing looks broken, but since this is a null-to-non-null change on a shared interface method with more call sites than the PR body enumerates, it'd be worth explicitly confirming the vector-index test suite (rebuild, CHECK DATABASE FIX, and Studio's index listing if it's exercised) was run, beyond the two call sites named in the description. Tests Good coverage matching the PR description - 8 tests in Issue6359SuperTypeIndexPropagationTest (including rollback survival and the mixed vector/LSM partial-cleanup case), 6 in Issue6359NegativeLiteralRenderingTest, 2 in GremlinQueryEngineFactoryClasspathHintTest. The async-writer test is @timeout(180) - worth confirming it's not also meant to carry @tag("slow") per CLAUDE.md's convention for multi-second functional regression tests, since a thousand records in flight through database.async() sounds like it belongs in that lane. I didn't see a @tag on it in the diff. Minor
Nothing here blocks merging as far as I can tell; the vector-index scope note above is the one thing I'd actually ask about before approving. |
… and why it is not in the slow lane The reviewable half of the sixth code review on PR #6364, which asked whether the async-writer test belongs in the slow lane given its @timeout(180). It does not, and the number is the reason it looked like it might. Measured, the test runs in 12 ms: the thousand records go through database.async() as QUEUED tasks, so the test never waits for them - the quiescence the propagation takes is what settles them. The timeout is sized as a hang detector, not as a latency bound: a quiescence that cannot park a worker gives up only after its own 60-second budget, and the failure has to arrive as that refusal, naming the worker it could not park, rather than as a bare timeout that names nothing. Tagging a 12 ms test `slow` would route it to a lane it does not belong in and say the opposite of what is true. Written down in the test rather than answered once in a review thread.
ReviewI read through the full diff (schema/index changes, the negative-literal/parentheses rendering fix, Code quality / maintainability
Testing
Minor / non-blocking
Nice work tracking down the transaction-timing subtleties in item 1 — the |
…, independently of addSuperType The one actionable note from the seventh code review on PR #6364: LSMVectorIndex.getTypeIndex() was only covered indirectly, through the mixed vector/ordinary propagation-cleanup test that happened to exercise it. The drop path is the wider half of that fix and deserves to be asserted on its own. LocalSchema.dropIndexInternal skips parentTypeIndex.removeIndexOnBucket(...) when getTypeIndex() answers null, so before this every path that dropped a vector sub-index - DROP INDEX, REBUILD INDEX, CHECK DATABASE ... FIX, removing a bucket - left the wrapper holding a reference to an index that no longer existed. None of that has anything to do with linking a super type. Two buckets, so dropping one sub-index leaves the wrapper alive to be asked about the other: each sub-index names the wrapper it was registered under, and the wrapper lets go of the one that was dropped while keeping the one that was not. It needs no vector rebuild, so it stays out of the vector lane and runs in 0.27 s.
ReviewWent through all three items in detail, including tracing the transaction-join semantics ( Item 1 -
|
…ed parentheses render as Both notes from the eighth code review on PR #6364, neither of which was a defect. The first is a scope statement that was easy to over-read from the title. An index family that cannot share the caller's transaction - the vector ones - is built inline inside the component-creation transaction, and that one does not join the caller's, so a propagated vector index sees the caller's uncommitted writes no more than it did before. Nothing regressed, since no vector build has ever joined a caller's transaction, but "the propagated index now covers uncommitted records" is true of the families that can share one, not of every family. Said at the decision site, where the per-family split is made, rather than left to be inferred from it. The second pins what redundant parentheses render as, since a great deal now rides on that renderer - EXPLAIN, the name of an unaliased projection, and the round trip of a WITH setting. Each layer is judged on the operand it wraps, so a layer around an already-parenthesised block wraps something that renders as one atom and prints nothing: `((a + b)) * c` renders `(a + b) * c`, `(((1 + 2))) * 3` renders `(1 + 2) * 3`, and `((a))` renders `a`. Redundancy collapses to the one pair that carries the meaning, and the worst case was only ever a spare pair of parentheses rather than a change of meaning - now asserted instead of assumed.
ReviewThis PR bundles three independent fixes discovered while working #6324; all three are self-contained, well-scoped, and each carries its own regression tests. The PR description and inline comments are unusually thorough, and the commit history shows the three items already went through 8 rounds of review with real bugs caught and fixed along the way (the retry-swallows-the-exception bug, the vector-index cleanup gap, the async-quiescence deadlock-by-lock-ordering, the outer-vs-inner rollback scope). I re-checked the current diff end to end rather than re-litigating what's already been fixed; notes below are what's left. Item 1 — index propagation on
|
…se notes The second note from the ninth code review on PR #6364: the boolean setting reader used to coerce anything it did not recognise to false, and now refuses it, which is a user-visible change worth stating rather than leaving to be discovered. `REBUILD INDEX i WITH statsOnly = yes` did not fail before - Boolean.parseBoolean answers false for anything unrecognised, so the typo silently selected the OTHER behaviour, and for statsOnly that is the difference between recomputing index statistics and rebuilding the whole index. Anyone carrying such a typo has been getting the expensive path all along and now gets told. Added to docs/release-26.9.1.md along with the two numeric fixes that come with it and the negative-literal and parentheses rendering change, plus a docs/6359-*.md page with the before/after table for the three statement shapes whose behaviour differs.
ReviewI read through the full diff (all 8 files under Correctness (looked but found no bugs)
Minor observations (optional, not required)
Test coverageGood coverage of the tricky cases: uncommitted-record propagation (API + SQL script), update-in-same-transaction, rollback-then-reuse, duplicate-key refusal with full cleanup verification (both the index side and the link side), the mixed vector/ordinary-index cleanup gap, the async-quiescence race, and the "refusal from a later step" case. The negative-literal test suite is thorough on the rendering/reparse round-trip. I didn't find gaps worth calling out. Not independently verifiedI did not re-run |
…hape it arrives in The one taken note from the tenth code review on PR #6364. The other two - the substring match in the Gremlin classpath hint, and the density of addSuperTypeInternal - were raised and dismissed by the reviewer, and the second by two reviewers before it; neither is changed. parsePositiveIntSetting had two branches that disagreed. A Number went through a whole-number test, so 1000.0 was accepted as 1000; anything else went through Integer.valueOf, so the string "1000.0" was refused while "1000" was not. Which branch a value took is an accident of how it reached the reader - a literal, a bound parameter, a quoted setting - and not something a user chooses, so the two shapes of one value have to give one answer. Both now go through the same test: read as a double, refuse anything absent, unparseable, fractional, out of int range, or below one. NaN fails the whole-number test as surely as 1.5 does, and infinity fails the range test. The test asserts the equivalence directly rather than the branches: 1000, 1000.0 and '1000' are all accepted, 1000.5, '1000.5', 'not a number' and 0 are all refused by name.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 28 |
🟢 Coverage 88.79% diff coverage · -6.58% coverage variation
Metric Results Coverage variation ✅ -6.58% coverage variation Diff coverage ✅ 88.79% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (1c219a7) 160695 127699 79.47% Head commit (411a0ef) 193095 (+32400) 140736 (+13037) 72.88% (-6.58%) 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 (#6364) 107 95 88.79% 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.
ReviewThis PR bundles three fixes discovered while working #6324 (index propagation on Code quality
Potential bugs / correctness
Performance
Security
Test coverage
Nothing here is blocking; this reads like a PR that's already been through its adversarial review rounds. The comment-trimming point is the one thing I'd actually act on before merge. |
…rry the history The one point the eleventh code review on PR #6364 said it would act on: several comment blocks narrated how the bug behaved and how an earlier attempt got it wrong, which is worth writing once but not worth carrying in the code once docs/6359-rebuild-setting-validation.md and the release notes entry exist to hold it. Trimmed to the invariant a future editor has to not break, keeping the issue numbers - they are how a reader finds the full story, and they are the convention in every neighbouring comment in these files. What went is the retelling: which of the three post-linkage steps used to roll the link back and which did not, the step-by-step of how a record saved before the index existed ends up in neither the scan nor the index, and the walk-through of the retry that used to swallow the duplicate. What stayed is why the predicate is asked before any transaction opens, why the cleanup cannot hang off a transaction's error callback, why the link has to go back for the retry to be a real attempt, and the limit of the fix for the vector families. Net 25 lines of comment removed, 18 added; no code change.
ReviewI read through the full diff (engine, gremlin, docs) against the current CorrectnessI did not find a remaining bug. Specifically, I verified:
Code qualityVery good. The two-transaction split, the shared Test coverageStrong. The new tests cover the propagation over uncommitted/updated records, rollback survival, the duplicate-key refusal path (both the simple and mixed-vector/ordinary shapes), the async-writer race, the deliberately-untouched Minor/non-blocking observations
Security / PerformanceNo concerns. No new dependencies, no new I/O or network surface. The added Nice work — this is a thorough fix with the regression tests to back it up. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6364 +/- ##
==========================================
+ Coverage 70.74% 70.76% +0.02%
==========================================
Files 1851 1852 +1
Lines 160695 160715 +20
Branches 33779 33773 -6
==========================================
+ Hits 113687 113736 +49
+ Misses 33037 33019 -18
+ Partials 13971 13960 -11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…'s value is every field that carries one (#6407) * fix(#6401): a hash code is a property of the value, and an expression's value is every field that carries one Four follow-ups from #6359, and two of them turned out to be each other's cover. `SimpleNode.hashCode()` hashed the ARRAY that `getIdentityElements()` returns instead of its contents: there is no `Objects.hashCode(Object...)` overload, so an `Object[]` binds to `Objects.hashCode(Object)` and the answer was the array's identity hash - of an array allocated fresh on every call. So a node did not agree with itself twice in a row, and two nodes `equals()` to each other hashed differently, which is the `Object.hashCode` contract broken outright. `Arrays.hashCode` is what the code reads as if it says. The other half is that identity left out fields that carry a value. `BaseExpression` omitted `number` and `expression`, so `SELECT 1` and `SELECT 2` parsed to nodes that were `equals()`; `Expression` omitted `whereCondition` and the inherited `value` slot, and `value` is where `IMPORT`, `EXPORT` and `BACKUP DATABASE` park a setting NAME - so every key of a `WITH` clause was equal to every other key. `PNumber` gained an identity of its own for the same reason `PInteger` has always had one: without it, listing `number` would compare two literals by object identity and say "not equal" for two parses of the same statement. Neither fix is safe alone. `equals()` said yes where it should have said no, the hash codes said no to everything, and a `HashMap` keyed on a parsed node came out almost right by accident: fixing the hash first collapses the five `Map<Expression, Expression> settings` maps to one entry, which is exactly what `ImportDatabaseStatementTestParserTest` caught. Also here, from the same batch: - the external-bucket arm of `addSuperType`'s rollback gets its regression test. It needs no fault injection: `ensureExternalBucketFor` refuses to adopt a bucket that is already some user type's primary bucket, so naming a primary bucket after the one the subtype's pairing would want reaches the refusal from step one, before an index is propagated or a strategy inherited. The link has to go back on both sides, and nothing may be half-adopted; - `addSuperTypeInternal` is split along the two seams four review rounds on #6364 asked for once the logic stopped moving: `linkSuperType` (symmetric with `unlinkSuperType`), `applyPostLinkageSteps`, `propagateSuperTypeIndexes` and `createSubIndexesFor`. No behaviour change; the ordering constraints that were only in comments are now the method's javadoc checklist. * docs(#6401): ValueExpression carries its meaning in the value slot, so it inherits the identity that now reads it Answers the one substantive point of the review on #6407: ValueExpression extends Expression without an identity of its own, so adding 'value' to Expression's identity changes how it compares. That is the right answer for it - it stores a pre-calculated value in exactly that slot, and before the change every ValueExpression was equals() to every other one - but the class said nothing about it. The caveat worth remembering is now written down: the identity is only as well-behaved as the wrapped object's own equals/hashCode.
Closes #6359.
Three findings collected while fixing #6324, none of which was that issue's to fix.
Item 1 - an index propagated to a super type's existing buckets missed uncommitted records
#6324 made
CREATE INDEXsee the writes of the transaction it runs in, throughTypeIndexBuilderandBucketIndexBuilder.LocalDocumentType.addSuperTypeuses neither: it callsLocalSchema.createBucketIndexdirectly, over buckets that already hold records, and still built in a transaction of its own. A caller that
inserts and then links a super type in one transaction got exactly #6324's shape back - an index that is readable,
reported healthy by
CHECK DATABASE, and answers the lookup it exists for with nothing.It now takes the same two-transaction split: the components are created and committed on their own, then the builds
join the caller's transaction.
The issue offered two shapes for the fix - route the call site through a builder, or write the split a third time.
Neither is what landed, because the first is not free:
BucketIndexBuilder.create()re-derives the key types fromthe type's properties (the propagation has them on the index being propagated), passes
nullfor theTypeIndextoattach to (so a propagated sub-index would mint a NEW wrapper on the subtype instead of joining the super type's),
and quiesces the async executor once per call - N full quiesce cycles for one
addSuperType. What is shared insteadis the three things the split actually needs, now written once in
IndexBuilder:callerTransactionHasChanges(database)- the transaction half of the predicate, on its own because this call sitehas to ask it before it knows which index families it is about to create;
buildCreatedIndex(index, batchSize, shares, callback)- theUNAVAILABLE->AVAILABLEstep;dropPartiallyBuiltIndex(schema, index)-BucketIndexBuilder's private copy is gone.Timing is the trap this cost the most on: the predicate has to be asked before anything is opened, because inside
the component-creation transaction there is always one, it is empty, and the answer would always be no. Asked from
the wrong place, the fix compiles, passes four of five tests, and does nothing.
The sibling call site in
createBucket()is left alone deliberately, and now says why: the bucket it indexes hasjust been created, so no transaction can hold uncommitted writes into it and there is nothing for the scan to miss.
Item 2 - a negative numeric literal rendered as an arithmetic expression
A unary minus was modelled as a subtraction from zero, so the AST for
-1was0 - 1and that is whatExpression.toString()produced. The rendering is not cosmetic: it is whatEXPLAINprints, what an unaliasedprojection is named after, and what a statement re-reading one of its own settings parses -
REBUILD INDEX ... WITH batchSize = -1reachedInteger.parseIntas the string"0 - 1".The minus is now folded into the literal. It negates the already-parsed value rather than re-parsing a
"-"-prefixed text, so the folded literal keeps exactly the numeric type0 - Xused to produce (-2147483648stays a
Long, anL-suffixed literal stays aLong, a bare decimal stays aFloat) and the sign lands correctlyon every literal shape the visitors accept, not only on plain decimal. A literal carrying a modifier is left alone,
since a suffix binds tighter than the sign.
Measuring that turned up the other half of the same defect, which the fold alone does not reach: the parentheses a
statement was written with were dropped as well.
SELECT 2 * -1SELECT 2 * 0 - 1SELECT (1 + 2) * 3SELECT 1 + 2 * 3SELECT -(1 + 2)SELECT 0 - 1 + 2BaseExpression.expressioncould not say on its own whether it held a parenthesised block - the builder also parksmap literals, array literals and CASE expressions there - so the node now records that the parentheses were written,
and prints them only where dropping them could change the meaning: around a compound arithmetic operand. Around
an atom they are decoration, and printing them would rename every unaliased projection written that way
(
SELECT (name) FROM Vhas always been a column calledname, andSELECT distinct(name), which the parser readsas
DISTINCT (name), with it).And the numeric-setting readers are unified on
DDLStatement.parsePositiveIntSetting, next to the boolean one thatwas already shared - the sweep the issue asked for, done by removing the duplicate rather than by fixing each copy.
That also fixes
REBUILD TYPE ... WITH batchSize, which readExpression.value- null for every numeric literalthe parser builds - and so refused every value it was given, legal ones included, with
got: null.Item 3 -
graphqlandgremlincould not share one Maven invocationPre-existing and invisible in CI, where the lanes run each module separately. Measured cause:
It is the trap already documented for
arcadedb-gremlin-it, one module wider.graphqlconsumesarcadedb-gremlin'sshadedclassifier with a wildcard exclusion, so the uber-jar is self-contained; Mavensubstitutes the reactor module for a classified dependency whose module is in the same invocation, the
testphasenever runs the shade plugin, and the plain
target/classesthat stands in for it carries no TinkerPop.Inherent to how the artifact is resolved, so it is documented in CLAUDE.md's build-traps section where somebody
running that command will find it. What is fixed is the message: the failure named the engine ("Error on
initializing Gremlin query engine") rather than the classpath, and now names the classpath.
Checked, and NOT a bug
The issue's last section records that unique-index enforcement was measured and is sound. Nothing to do, not
re-opened.
Testing
Issue6359SuperTypeIndexPropagationTest(5): the propagation over uncommitted inserts through the API and throughone SQL script, a record updated in the same transaction indexed under its new key, the propagated component
surviving a rollback of the transaction that propagated it and still being writeable, and the
createBucket()sibling asserted rather than merely asserted about.
Issue6359NegativeLiteralRenderingTest(6): the rendering of every negative literal shape, the parentheses ruleboth ways, a render-and-reparse round trip asserted on the computed VALUE, the column name of an unaliased
parenthesised projection, and the setting readers refusing
-1by the value the user typed.GremlinQueryEngineFactoryClasspathHintTest(2): the missing-TinkerPop message, and that an unrelated failure -including a missing class that is not TinkerPop - is not mislabelled as it.
mvn -o -pl engine -am test: 12587 tests, 0 failures.mvn -o verify -pl gremlin,graphql,server,postgresw -amandmvn -o verify -pl gremlin-it -am: green.🤖 Generated with Claude Code
https://claude.ai/code/session_01QF6LJaiD6ZRr6oA9WZxVBK