Skip to content

fix(#11182): analysing a Gremlin command never runs it - #11186

Merged
lvca merged 2 commits into
mainfrom
fix/11182-ha-gremlin-follower-duplicate
Nov 3, 2026
Merged

lvca merged 2 commits into
mainfrom
fix/11182-ha-gremlin-follower-duplicate

Conversation

@lvca

@lvca lvca commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #11182

Problem

ArcadeGremlin.parse() built the traversal by evaluating the script with the gremlin-lang engine, which applies the terminal step (iterate(), next(), toList()...) while it evaluates. The analysis therefore ran the write it was asked about. An HA follower analyses every command to decide whether to forward it, so one Gremlin write sent to a follower ran locally, was forwarded and ran again on the leader, then conflicted at the follower's commit, and the HTTP handler's retry repeated the whole thing: 6 vertices plus a ConcurrentModificationException.

Fix

GremlinStatementAnalyzer builds each statement from the gremlin-lang parse tree (a GremlinAntlrToJava subclass) and runs none of them:

  • terminal steps and g.tx() controls are never applied
  • every statement of a multi-statement script is classified. Before, only the last one counted, so g.addV('X').iterate(); g.V().count() was read as a read
  • a terminated traversal passed as an argument (g.V(g.V().has('name','a').id().next())) can only be built by running it. A write-refusing VerificationStrategy on the analysis source lets it run only when it reads. If it writes, it is stopped before its first step and the script is classified as a write
  • a Groovy-only script (auto/groovy engines, admin-only) is still evaluated, because Groovy is code, but with the same guarded source. A traversal the script runs during evaluation only runs if it reads

The now-unused analysis script engine is removed from ArcadeGraph.

Related bugs fixed

  • On a follower, a read ending in a terminal step (g.V().count().next()) was refused with a 400 CommandParsingException, because the analysis got a value instead of a traversal
  • On a single server, a Gremlin write sent to the read-only query path left a new label's type behind (schema changes are not transactional)

Tests

  • Issue11182GremlinAnalysisDoesNotExecuteTest: 21 cases (every terminal step, drop, multi-statement, write and read in arguments, tx control, new-label type, parameters, Groovy write and read). 17 fail on main
  • Issue11182GremlinWriteThroughFollowerIT: a 3-node Raft cluster, Gremlin over HTTP to a follower. On main the write gets a 503 ConcurrentModificationException and the next() read a 400. With the fix, one vertex lands on every node and the read answers. The test needs arcadedb-ha-raft (test scope) in gremlin and gremlin-it, the same pattern bolt/grpcw already use
  • Full gremlin-it run (-Pintegration): 724 unit and 1963 IT, 0 failures

Summary by CodeRabbit

  • Bug Fixes
    • Gremlin query analysis now identifies read and write operations without applying traversal steps or triggering write side effects.
    • Gremlin commands sent to a follower are covered for successful write forwarding and read results across servers.
    • Gremlin execution continues to apply terminal traversal steps, while query analysis handles parameters and parsing errors.

ArcadeGremlin.parse() built the traversal by evaluating the script, and
gremlin-lang applies a terminal step (iterate(), next(), toList()...) while
it evaluates: the analysis applied the write it was asked about. An HA
follower analyses a command to decide whether to forward it, so one write
sent to a follower was applied there, forwarded and applied again on the
leader, conflicted at the follower's commit, and the handler's retry
repeated it: six vertices and a ConcurrentModificationException.

GremlinStatementAnalyzer builds every statement of the script from the
gremlin-lang parse tree and runs none of them:
- terminal steps and g.tx() controls are never applied
- every statement of a multi-statement script is classified, not only the
  last one the script engine answers
- a terminated traversal passed as an argument (built only by running it)
  runs only when it reads: a write-refusing verification strategy stops a
  writing one before its first step, and the script is then a write
- a Groovy script (auto/groovy engines) is evaluated with that same
  guarded source, so a traversal it runs while evaluated only reads

Also fixes a read ending in a terminal step (g.V().count().next()) being
refused as a parsing error on a follower, and a write sent to the
read-only query path leaving a new label's type behind.
@lvca lvca added this to the 26.11.1 milestone Nov 3, 2026
@lvca lvca self-assigned this Nov 3, 2026
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

Gremlin analysis now classifies scripts without applying traversal terminal steps or transaction controls. Execution converts evaluated results separately. New tests cover analysis behavior and Gremlin requests sent to HA followers.

Changes: Gremlin analysis and follower execution

Layer / File(s) Summary
Statement analysis
gremlin/src/main/java/com/arcadedb/gremlin/GremlinStatementAnalyzer.java, gremlin/src/main/java/com/arcadedb/gremlin/ArcadeGraph.java
A new analyzer collects traversals and classifies write operations, including nested traversals. The separate Java analysis engine and its getter are removed.
Parsing and execution integration
gremlin/src/main/java/com/arcadedb/gremlin/ArcadeGremlin.java
parse() uses the analyzer for Java syntax and guarded Groovy analysis when applicable. Execution evaluates scripts with a supplied traversal source and converts traversals, Optional values, and other results into iterators.
Analysis and follower behavior tests
gremlin/src/test/java/com/arcadedb/gremlin/ArcadeGremlinAnalyzeTest.java, gremlin/src/test/java/com/arcadedb/gremlin/Issue11182GremlinAnalysisDoesNotExecuteTest.java, gremlin/src/test/java/com/arcadedb/gremlin/Issue11182GremlinWriteThroughFollowerIT.java, gremlin/pom.xml, gremlin-it/pom.xml
Tests cover analysis classification, unchanged graph and transaction state during analysis, command execution, and Gremlin requests sent to HA followers. Both Maven modules add test dependencies on the HA Raft module and its test JAR.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • ArcadeData/arcadedb#11171: Adds an MCP guard for query engines whose analyze() evaluates script text. Its commits identify the Gremlin analysis fix in this pull request.

Suggested labels: bug, ha

Merge Risk: Minimal · up to 335e7

No merge-blocking issue was identified in the reviewed change; it is ready for normal merge checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the issue and the main behavior change: analysing a Gremlin command no longer executes it. It matches the changeset, which adds GremlinStatementAnalyzer and removes execution during pa…
Description check Passed The description follows the template. It has a problem and fix section, related bugs, tests, and a link to issue #11182. The 'What does this PR do?', 'Motivation', and 'Checklist' headings are not use…
Linked Issues check Passed [#11182] GremlinStatementAnalyzer builds every script statement from the parse tree. It does not apply terminal steps or transaction controls. It uses WriteRefusingStrategy for traversals evaluate…
Out of Scope Changes check Passed The changed production code supports [#11182]. ArcadeGremlin routes analysis through GremlinStatementAnalyzer and preserves execution result handling after removal of the analysis engine. `ArcadeG…
Full details: Title check

Explanation

The title names the issue and the main behavior change: analysing a Gremlin command no longer executes it. It matches the changeset, which adds GremlinStatementAnalyzer and removes execution during parse. The title is short, single-sentence, and specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description follows the template. It has a problem and fix section, related bugs, tests, and a link to issue #11182. The 'What does this PR do?', 'Motivation', and 'Checklist' headings are not used as written, but the content covers their purpose. The checklist items are not ticked, and the description does not confirm that mvn clean package was run. The fix, related bugs, and tests sections give clear reviewer context.

Full details: Linked Issues check

Explanation

[#11182] GremlinStatementAnalyzer builds every script statement from the parse tree. It does not apply terminal steps or transaction controls. It uses WriteRefusingStrategy for traversals evaluated during construction and Groovy analysis. It classifies writes in all statements and nested traversals. The added unit test covers terminal steps, drop(), multi-statement scripts, argument traversals, transaction controls, parameters, Groovy reads and writes, the read-only query path, and command execution. The added HA integration test covers one write and a next() read sent to a follower. These changes address the duplicate-write and new-label-type requirements.

Full details: Out of Scope Changes check

Explanation

The changed production code supports [#11182]. ArcadeGremlin routes analysis through GremlinStatementAnalyzer and preserves execution result handling after removal of the analysis engine. ArcadeGraph removes the unused analysis-engine getter. The unit and follower integration tests verify the issue behavior. The added test dependencies support the follower integration test. No unrelated change is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 15 functions across 5 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.1)

ast-grep could not parse rule config: /ast-grep-rules/ast-grep-essentials/rules/rust/security/sql-injection-format-rust.yml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d1ddd0a8-f002-43de-92bd-c8366650c223
Commits

Reviewing files that changed from the base of the PR and between e09e6ef and 335e74f.

Files selected for processing: 2
  • gremlin/src/main/java/com/arcadedb/gremlin/ArcadeGremlin.java
  • gremlin/src/main/java/com/arcadedb/gremlin/GremlinStatementAnalyzer.java
Files skipped from review as they are similar to previous changes: 2
  • gremlin/src/main/java/com/arcadedb/gremlin/GremlinStatementAnalyzer.java
  • gremlin/src/main/java/com/arcadedb/gremlin/ArcadeGremlin.java

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@mergify

mergify Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@claude

claude Bot commented Nov 3, 2026

Copy link
Copy Markdown

Review of #11186 (Gremlin analysis no longer executes the statement)

Summary: The approach is sound. Building each statement from the parse tree with a GremlinAntlrToJava subclass means terminal steps are never applied. Classifying every statement, not just the last, closes a real misclassification. The WriteRefusingStrategy guard for traversals passed as arguments is a reasonable fallback.

Security: I found no new hazard. The change narrows the surface, because analysis no longer runs writes. The Groovy fallback is still evaluated, but only for admin-only engines and with the write-refusing source. The new ha-raft dependencies are test scope only and internal.

Notes (non-blocking):

  • WriteRefusingStrategy only inspects root traversals. Groovy code that mutates through non-traversal APIs (for example graph.addVertex or direct database calls) is still executed during analysis. This is acceptable for admin-only engines, but a short Javadoc note would help.
  • A Groovy script that fails for an unrelated reason falls through to a rethrow. Check that this surfaces as CommandParsingException consistently.
  • GremlinStatementAnalyzer.isWriteRefused caps the cause-chain walk at 16. That is fine, but it deserves a comment.
  • The test coverage is strong: unit tests for each terminal step, drop, multi-statement scripts, arguments, tx controls and Groovy, plus a 3-node Raft IT.

I didn't run the tests locally. Overall LGTM.

@codacy-production

codacy-production Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 34 complexity

Metric Results
Complexity 34

View in Codacy

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.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

📜 License Compliance Check

✅ License check passed. See artifacts for full report.

License Summary (first 50 lines)

Lists of 420 third-party dependencies.
     (CC0 1.0 Universal) AOP alliance (aopalliance:aopalliance:1.0 - http://aopalliance.sourceforge.net)
     (Apache License 2.0) LZ4 Java Compression (at.yawk.lz4:lz4-java:1.12.1 - https://github.com/yawkat/lz4-java)
     (EPL-2.0) (LGPL-2.1-only) Logback Classic Module (ch.qos.logback:logback-classic:1.6.6 - http://logback.qos.ch/logback-classic)
     (EPL-2.0) (LGPL-2.1-only) Logback Core Module (ch.qos.logback:logback-core:1.6.6 - http://logback.qos.ch/logback-core)
     (Apache 2) ArcadeDB BOLT Protocol (com.arcadedb:arcadedb-bolt:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-bolt/)
     (Apache 2) ArcadeDB Console (com.arcadedb:arcadedb-console:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-console/)
     (Apache 2) ArcadeDB Engine (com.arcadedb:arcadedb-engine:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-engine/)
     (Apache 2) ArcadeDB GraphQL (com.arcadedb:arcadedb-graphql:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-graphql/)
     (Apache 2) ArcadeDB Gremlin (com.arcadedb:arcadedb-gremlin:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-gremlin/)
     (Apache 2) ArcadeDB gRPC Stubs (com.arcadedb:arcadedb-grpc:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-grpc/)
     (Apache 2) ArcadeDB gRPC Client (com.arcadedb:arcadedb-grpc-client:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-grpc-client/)
     (Apache 2) ArcadeDB gRpcW (com.arcadedb:arcadedb-grpcw:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-grpcw/)
     (Apache 2) ArcadeDB HA Raft (com.arcadedb:arcadedb-ha-raft:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-ha-raft/)
     (Apache 2) ArcadeDB Integration (com.arcadedb:arcadedb-integration:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-integration/)
     (Apache 2) ArcadeDB load tests (com.arcadedb:arcadedb-load-tests:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-load-tests/)
     (Apache 2) ArcadeDB MCP Server (com.arcadedb:arcadedb-mcp:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-mcp/)
     (Apache 2) ArcadeDB Metrics (com.arcadedb:arcadedb-metrics:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-metrics/)
     (Apache 2) ArcadeDB MongoDB Wire Protocol (com.arcadedb:arcadedb-mongodbw:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-mongodbw/)
     (Apache 2) ArcadeDB Network (com.arcadedb:arcadedb-network:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-network/)
     (Apache 2) ArcadeDB PostgresW (com.arcadedb:arcadedb-postgresw:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-postgresw/)
     (Apache 2) ArcadeDB RedisW (com.arcadedb:arcadedb-redisw:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-redisw/)
     (Apache 2) ArcadeDB Server (com.arcadedb:arcadedb-server:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-server/)
     (Apache 2) ArcadeDB Studio (com.arcadedb:arcadedb-studio:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-studio/)
     (Apache 2) ArcadeDB Tracing (com.arcadedb:arcadedb-tracing:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-tracing/)
     (Apache License 2.0) HPPC Collections (com.carrotsearch:hppc:0.7.1 - http://labs.carrotsearch.com/hppc.html/hppc)
     (Apache License 2.0) Metrics Core (com.codahale.metrics:metrics-core:3.0.2 - http://metrics.codahale.com/metrics-core/)
     (The Apache License, Version 2.0) com.conversantmedia:disruptor (com.conversantmedia:disruptor:1.2.21 - https://github.com/conversant/disruptor)
     (Apache License 2.0) Jackson-annotations (com.fasterxml.jackson.core:jackson-annotations:2.22 - https://github.com/FasterXML/jackson)
     (Apache License 2.0) Jackson-core (com.fasterxml.jackson.core:jackson-core:2.22.4 - https://github.com/FasterXML/jackson-core)
     (Apache License 2.0) jackson-databind (com.fasterxml.jackson.core:jackson-databind:2.22.4 - https://github.com/FasterXML/jackson)
     (Apache License 2.0) Jackson-dataformat-YAML (com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.22.4 - https://github.com/FasterXML/jackson-dataformats-text)
     (Apache License 2.0) Jackson datatype: jdk8 (com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.22.4 - https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jdk8)
     (Apache License 2.0) Jackson datatype: JSR310 (com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.22.4 - https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jsr310)
     (Apache License 2.0) Caffeine cache (com.github.ben-manes.caffeine:caffeine:2.3.1 - https://github.com/ben-manes/caffeine)
     (Apache License 2.0) docker-java-api (com.github.docker-java:docker-java-api:3.7.1 - https://github.com/docker-java/docker-java)
     (Apache License 2.0) docker-java-transport (com.github.docker-java:docker-java-transport:3.7.1 - https://github.com/docker-java/docker-java)
     (Apache License 2.0) docker-java-transport-zerodep (com.github.docker-java:docker-java-transport-zerodep:3.7.1 - https://github.com/docker-java/docker-java)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) btf (com.github.java-json-tools:btf:1.3 - https://github.com/java-json-tools/btf)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) jackson-coreutils (com.github.java-json-tools:jackson-coreutils:2.0 - https://github.com/java-json-tools/jackson-coreutils)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) jackson-coreutils-equivalence (com.github.java-json-tools:jackson-coreutils-equivalence:1.0 - https://github.com/java-json-tools/jackson-coreutils)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) json-patch (com.github.java-json-tools:json-patch:1.13 - https://github.com/java-json-tools/json-patch)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) json-schema-core (com.github.java-json-tools:json-schema-core:1.2.14 - https://github.com/java-json-tools/json-schema-core)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) json-schema-validator (com.github.java-json-tools:json-schema-validator:2.2.14 - https://github.com/java-json-tools/json-schema-validator)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) msg-simple (com.github.java-json-tools:msg-simple:1.2 - https://github.com/java-json-tools/msg-simple)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) uri-template (com.github.java-json-tools:uri-template:0.10 - https://github.com/java-json-tools/uri-template)
     (Apache License 2.0) JCIP Annotations under Apache License (com.github.stephenc.jcip:jcip-annotations:1.0-1 - http://stephenc.github.com/jcip-annotations)
     (Apache License 2.0) Google Android Annotations Library (com.google.android:annotations:4.1.1.4 - http://source.android.com/)
     (BSD 3-Clause) API Common (com.google.api:api-common:2.53.0 - https://github.com/googleapis/sdk-platform-java)

@claude

claude Bot commented Nov 3, 2026

Copy link
Copy Markdown

Review of #11186: the analyzer no longer executes statements, which fixes #11182 at the root. Building each statement from the parse tree and never applying terminal steps is the right approach. Classifying every statement of a multi-statement script also fixes the old last-statement-only gap.

Strengths

  • WriteRefusingStrategy handles terminated traversals used as arguments, and the unknown case degrades to anyWrite(), which forwards to the leader. That is the safe direction.
  • Groovy stays admin-only (checkServerAdministrator), and it is now evaluated with a guarded source.
  • The tests cover the right cases: 21 unit cases (17 fail on main) plus a 3-node Raft IT.

Notes (non-blocking)

  1. In the Groovy path the guard sees traversals only. The Javadoc already says that g.getGraph().addVertex() or closures can still write during analysis. That is acceptable for an admin-only path, but it means the HA double-apply can still happen for such scripts. Consider a short note in the docs.
  2. analyze() depends on GremlinAntlrToJava and TraversalRootVisitor, which are TinkerPop internals. A TinkerPop upgrade could break the subclass. Pinning it with the existing unit tests is probably enough.
  3. isWriteRefused caps the cause walk at 16, which is fine.
  4. arcadedb-ha-raft is added at test scope in gremlin and gremlin-it, which matches the bolt/grpcw pattern and respects the module dependency rules.

Security: no new hazard. This reduces unintended write execution during analysis, and no new dependencies are added.

LGTM.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

📜 License Compliance Check

✅ License check passed. See artifacts for full report.

License Summary (first 50 lines)

Lists of 420 third-party dependencies.
     (CC0 1.0 Universal) AOP alliance (aopalliance:aopalliance:1.0 - http://aopalliance.sourceforge.net)
     (Apache License 2.0) LZ4 Java Compression (at.yawk.lz4:lz4-java:1.12.1 - https://github.com/yawkat/lz4-java)
     (EPL-2.0) (LGPL-2.1-only) Logback Classic Module (ch.qos.logback:logback-classic:1.6.6 - http://logback.qos.ch/logback-classic)
     (EPL-2.0) (LGPL-2.1-only) Logback Core Module (ch.qos.logback:logback-core:1.6.6 - http://logback.qos.ch/logback-core)
     (Apache 2) ArcadeDB BOLT Protocol (com.arcadedb:arcadedb-bolt:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-bolt/)
     (Apache 2) ArcadeDB Console (com.arcadedb:arcadedb-console:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-console/)
     (Apache 2) ArcadeDB Engine (com.arcadedb:arcadedb-engine:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-engine/)
     (Apache 2) ArcadeDB GraphQL (com.arcadedb:arcadedb-graphql:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-graphql/)
     (Apache 2) ArcadeDB Gremlin (com.arcadedb:arcadedb-gremlin:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-gremlin/)
     (Apache 2) ArcadeDB gRPC Stubs (com.arcadedb:arcadedb-grpc:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-grpc/)
     (Apache 2) ArcadeDB gRPC Client (com.arcadedb:arcadedb-grpc-client:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-grpc-client/)
     (Apache 2) ArcadeDB gRpcW (com.arcadedb:arcadedb-grpcw:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-grpcw/)
     (Apache 2) ArcadeDB HA Raft (com.arcadedb:arcadedb-ha-raft:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-ha-raft/)
     (Apache 2) ArcadeDB Integration (com.arcadedb:arcadedb-integration:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-integration/)
     (Apache 2) ArcadeDB load tests (com.arcadedb:arcadedb-load-tests:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-load-tests/)
     (Apache 2) ArcadeDB MCP Server (com.arcadedb:arcadedb-mcp:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-mcp/)
     (Apache 2) ArcadeDB Metrics (com.arcadedb:arcadedb-metrics:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-metrics/)
     (Apache 2) ArcadeDB MongoDB Wire Protocol (com.arcadedb:arcadedb-mongodbw:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-mongodbw/)
     (Apache 2) ArcadeDB Network (com.arcadedb:arcadedb-network:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-network/)
     (Apache 2) ArcadeDB PostgresW (com.arcadedb:arcadedb-postgresw:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-postgresw/)
     (Apache 2) ArcadeDB RedisW (com.arcadedb:arcadedb-redisw:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-redisw/)
     (Apache 2) ArcadeDB Server (com.arcadedb:arcadedb-server:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-server/)
     (Apache 2) ArcadeDB Studio (com.arcadedb:arcadedb-studio:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-studio/)
     (Apache 2) ArcadeDB Tracing (com.arcadedb:arcadedb-tracing:26.11.1-SNAPSHOT - https://arcadedata.com/arcadedb-tracing/)
     (Apache License 2.0) HPPC Collections (com.carrotsearch:hppc:0.7.1 - http://labs.carrotsearch.com/hppc.html/hppc)
     (Apache License 2.0) Metrics Core (com.codahale.metrics:metrics-core:3.0.2 - http://metrics.codahale.com/metrics-core/)
     (The Apache License, Version 2.0) com.conversantmedia:disruptor (com.conversantmedia:disruptor:1.2.21 - https://github.com/conversant/disruptor)
     (Apache License 2.0) Jackson-annotations (com.fasterxml.jackson.core:jackson-annotations:2.22 - https://github.com/FasterXML/jackson)
     (Apache License 2.0) Jackson-core (com.fasterxml.jackson.core:jackson-core:2.22.4 - https://github.com/FasterXML/jackson-core)
     (Apache License 2.0) jackson-databind (com.fasterxml.jackson.core:jackson-databind:2.22.4 - https://github.com/FasterXML/jackson)
     (Apache License 2.0) Jackson-dataformat-YAML (com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.22.4 - https://github.com/FasterXML/jackson-dataformats-text)
     (Apache License 2.0) Jackson datatype: jdk8 (com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.22.4 - https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jdk8)
     (Apache License 2.0) Jackson datatype: JSR310 (com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.22.4 - https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jsr310)
     (Apache License 2.0) Caffeine cache (com.github.ben-manes.caffeine:caffeine:2.3.1 - https://github.com/ben-manes/caffeine)
     (Apache License 2.0) docker-java-api (com.github.docker-java:docker-java-api:3.7.1 - https://github.com/docker-java/docker-java)
     (Apache License 2.0) docker-java-transport (com.github.docker-java:docker-java-transport:3.7.1 - https://github.com/docker-java/docker-java)
     (Apache License 2.0) docker-java-transport-zerodep (com.github.docker-java:docker-java-transport-zerodep:3.7.1 - https://github.com/docker-java/docker-java)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) btf (com.github.java-json-tools:btf:1.3 - https://github.com/java-json-tools/btf)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) jackson-coreutils (com.github.java-json-tools:jackson-coreutils:2.0 - https://github.com/java-json-tools/jackson-coreutils)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) jackson-coreutils-equivalence (com.github.java-json-tools:jackson-coreutils-equivalence:1.0 - https://github.com/java-json-tools/jackson-coreutils)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) json-patch (com.github.java-json-tools:json-patch:1.13 - https://github.com/java-json-tools/json-patch)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) json-schema-core (com.github.java-json-tools:json-schema-core:1.2.14 - https://github.com/java-json-tools/json-schema-core)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) json-schema-validator (com.github.java-json-tools:json-schema-validator:2.2.14 - https://github.com/java-json-tools/json-schema-validator)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) msg-simple (com.github.java-json-tools:msg-simple:1.2 - https://github.com/java-json-tools/msg-simple)
     (Apache Software License, version 2.0) (Lesser General Public License, version 3 or greater) uri-template (com.github.java-json-tools:uri-template:0.10 - https://github.com/java-json-tools/uri-template)
     (Apache License 2.0) JCIP Annotations under Apache License (com.github.stephenc.jcip:jcip-annotations:1.0-1 - http://stephenc.github.com/jcip-annotations)
     (Apache License 2.0) Google Android Annotations Library (com.google.android:annotations:4.1.1.4 - http://source.android.com/)
     (BSD 3-Clause) API Common (com.google.api:api-common:2.53.0 - https://github.com/googleapis/sdk-platform-java)

@lvca
lvca merged commit 91bf941 into main Nov 3, 2026
36 of 37 checks passed
@lvca
lvca deleted the fix/11182-ha-gremlin-follower-duplicate branch November 3, 2026 04:11
robfrank pushed a commit that referenced this pull request Nov 5, 2026
* fix(#11182): analysing a Gremlin command never runs it

ArcadeGremlin.parse() built the traversal by evaluating the script, and
gremlin-lang applies a terminal step (iterate(), next(), toList()...) while
it evaluates: the analysis applied the write it was asked about. An HA
follower analyses a command to decide whether to forward it, so one write
sent to a follower was applied there, forwarded and applied again on the
leader, conflicted at the follower's commit, and the handler's retry
repeated it: six vertices and a ConcurrentModificationException.

GremlinStatementAnalyzer builds every statement of the script from the
gremlin-lang parse tree and runs none of them:
- terminal steps and g.tx() controls are never applied
- every statement of a multi-statement script is classified, not only the
  last one the script engine answers
- a terminated traversal passed as an argument (built only by running it)
  runs only when it reads: a write-refusing verification strategy stops a
  writing one before its first step, and the script is then a write
- a Groovy script (auto/groovy engines) is evaluated with that same
  guarded source, so a traversal it runs while evaluated only reads

Also fixes a read ending in a terminal step (g.V().count().next()) being
refused as a parsing error on a follower, and a write sent to the
read-only query path leaving a new label's type behind.

* docs(#11182): document the reach of the Groovy analysis guard and the bounded cause walk

(cherry picked from commit 91bf941)
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.

HA: one Gremlin write sent to a follower is applied several times and still returns an error

1 participant