Repository navigation
Description
Collected while fixing #6324 (merged as PR #6350, ea91db591). Item 1 is the gap that issue's PR named and
deliberately left open, item 2 is a parser defect its work uncovered and only papered over locally, item 3 is a
build-infrastructure trap that makes a local multi-module run read as a regression. None of them was #6324's to fix.
The last section records something that was investigated and turned out NOT to be a bug, so nobody spends the time
again.
Item 1 - an index propagated to a super type's existing buckets still misses uncommitted records
#6324 item 1 made CREATE INDEX see the writes of the transaction it runs in: the index component is created and
committed on its own, and the BUILD then joins the caller's transaction, because a bucket scan reads the transaction
it runs in. That went through TypeIndexBuilder and BucketIndexBuilder.
LocalDocumentType does not use either. It calls LocalSchema.createBucketIndex directly in two places, so both
still build in a transaction of their own and are back where CREATE INDEX was:
LocalDocumentType.java:1965-1984(addSuperType) - propagates the super type's indexes over
buckets that already hold records, wrapped inschema.getDatabase().transaction(..., false). A caller that
inserts and then links a super type in one transaction gets exactly Follow-ups from #6303: a same-transaction CREATE INDEX loses its own inserts, two tests that assert the wrong thing, and four copies of one pool #6324's shape back: the records are not
committed, the scan does not see them, and they were saved before the index existed to stage an entry for. Result
is an index that is readable, reported healthy byCHECK DATABASE, and answers the lookup it exists for with
nothing.LocalDocumentType.java:1481-1493(createBucket) - the sibling call, and this one is safe, for a reason
worth writing down so it is not "fixed" by symmetry: 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.
The shape of the fix is the one #6324 settled on, and the pieces are already there: ask
IndexBuilder#buildSharesCallerTransaction (or the same predicate), split the component creation from the build when
the answer is yes, and pass the permission through IndexInternal.build(int, boolean, BuildIndexCallback) so the
build does not commit a transaction it does not own. The awkward part is that these two call sites bypass the
builders entirely, so either they start going through a builder or the split has to be written a third time - the
first is the one that stops this recurring.
Worth a regression test in the shape of Issue6324SameTransactionIndexBuildTest: insert, addSuperType, and assert
the propagated index answers the lookup.
Item 2 - a negative numeric literal renders as 0 - 1, and it escapes as a raw NumberFormatException
SQLASTBuilder.visitUnary (engine/src/main/java/com/arcadedb/query/sql/antlr/SQLASTBuilder.java:2879-2910) models
a unary minus as a subtraction from zero:
} else if (ctx.MINUS() != null) {
// Unary minus: create 0 - expression
...
result.childExpressions.add(zeroExpr);
result.childExpressions.add(innerExpr);
result.operators.add(MathExpression.Operator.MINUS);So the AST for -1 is 0 - 1, and that is what Expression.toString() renders. Measured, via
REBUILD INDEX ... WITH batchSize = -1:
java.lang.NumberFormatException: For input string: "0 - 1"
Two separate things are wrong here.
The rendering does not round-trip. Any caller that reads a setting or an option by rendering its expression back
to text - which RebuildIndexStatement does deliberately, because Expression.value is null for the integer in
WITH batchSize = 1000 and toString() is the only reliable accessor for all literals - gets an arithmetic
expression instead of the number the user typed. toString() is also what statement caching keys and EXPLAIN
output are built from, so this is wider than one statement.
The fix that suggests itself is folding a unary minus applied to a plain numeric literal into a negative literal at
parse time, which is what tryFoldLongMinValueLiteral a few lines above already does for
-9223372036854775808 (it has to, since 9223372036854775808 does not fit a positive long). Generalising that fold
would make the rendering honest and save an evaluation per read.
And the failure was a raw JDK exception. Integer.parseInt let a NumberFormatException out carrying the raw
rendering, naming neither the setting nor the problem. PR #6350 fixed that for RebuildIndexStatement alone
(parsePositiveSetting, which also refuses a value below 1). Every other statement that parses a numeric setting the
same way still has it; a sweep for Integer.parseInt( over the parser package would find them.
Item 3 - graphql and gremlin cannot share one Maven invocation
GraphQLGremlinDirectivesTest fails when the two modules are built in the same reactor invocation:
mvn -o test -pl gremlin,graphql -DexcludedGroups=benchmark,vector,slow
[ERROR] GraphQLGremlinDirectivesTest>AbstractGraphQLNativeLanguageDirectivesTest.customDefinitionForReturn
» CommandParsing Error on initializing Gremlin query engine
[ERROR] GraphQLGremlinDirectivesTest>AbstractGraphQLNativeLanguageDirectivesTest.useTypeDefinitionForReturn
» CommandParsing Error on initializing Gremlin query engine
[ERROR] Tests run: 45, Failures: 0, Errors: 2, Skipped: 0
The same tests pass on their own, both ways:
mvn -o test -pl graphql -> Tests run: 45, Failures: 0, Errors: 0
mvn -o test -pl graphql -Dtest=GraphQLGremlinDirectivesTest -> green
Pre-existing, and NOT caused by #6324 - it reproduced with that branch's changes reverted and it is invisible in CI,
where the lanes run each module separately. What it costs is local verification: anyone running a multi-module
subset before pushing sees two red tests that have nothing to do with their change, and the message
("Error on initializing Gremlin query engine") points at the engine rather than at the build. Worth either fixing the
module setup or, if it is inherent to how the gremlin shaded artifact is resolved in a shared reactor, saying so
where somebody running that command will find it (CLAUDE.md's build-traps section).
Checked, and NOT a bug: unique-index enforcement
While adapting DropIndexTest.dropAndRecreateTypeWithIndex in #6324, a duplicate key on a UNIQUE index turned out to
have been going undetected there (the test writes a second record with the same id; it only started failing once
the index build shared the writer's transaction and the in-transaction check caught it at save()).
That looked like it might be a hole in commit-time uniqueness validation, so three shapes were measured against
merged main. All three are correctly rejected with DuplicatedKeyException:
- a staged duplicate against an entry already persisted;
- a staged duplicate against an entry committed by a nested transaction while the outer one is still open;
- a duplicate landing in a different bucket of a multi-bucket unique type index (round-robin selection).
So enforcement is sound and there is nothing to fix. The test was simply relying on a duplicate that the old
separate-transaction build never gave anything the chance to compare. Recorded here so the next person who notices
that test change does not re-open the question.
Activity
fix(#6359): a propagation that refuses hands the super type link back…
fix(#6359): a vector index answers which TypeIndex it belongs to, and…
fix(#6359): the propagation holds the async workers, and its two list…
fix(#6359): the super type link is handed back on every refusal, not …
fix(#6359): the propagated indexes go back on every refusal too, not …
test(#6359): say why the async propagation test's timeout is generous…
test(#6359): pin the vector index's TypeIndex wiring on the DROP path…
docs(#6359): name the limit of the propagation fix, and pin what nest…
docs(#6359): record the REBUILD setting behaviour change in the relea…
fix(#6359): a numeric setting reads one value the same way in every s…
docs(#6359): keep the invariants in the code and let the docs page ca…
fix(#6359): a propagated index joins the transaction that wrote the r…
merge main: six more commits, one release-notes conflict, both sectio…
fix(#6401): a hash code is a property of the value, and an expression…