Repository navigation
fix(#11182): analysing a Gremlin command never runs it - #11186
Conversation
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.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
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. |
|
Review of #11186 (Gremlin analysis no longer executes the statement) Summary: The approach is sound. Building each statement from the parse tree with a 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 Notes (non-blocking):
I didn't run the tests locally. Overall LGTM. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 34 |
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.
… bounded cause walk
📜 License Compliance Check✅ License check passed. See artifacts for full report. License Summary (first 50 lines) |
|
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
Notes (non-blocking)
Security: no new hazard. This reduces unintended write execution during analysis, and no new dependencies are added. LGTM. |
📜 License Compliance Check✅ License check passed. See artifacts for full report. License Summary (first 50 lines) |
* 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)
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 aConcurrentModificationException.Fix
GremlinStatementAnalyzerbuilds each statement from the gremlin-lang parse tree (aGremlinAntlrToJavasubclass) and runs none of them:g.tx()controls are never appliedg.addV('X').iterate(); g.V().count()was read as a readg.V(g.V().has('name','a').id().next())) can only be built by running it. A write-refusingVerificationStrategyon 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 writeauto/groovyengines, 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 readsThe now-unused analysis script engine is removed from
ArcadeGraph.Related bugs fixed
g.V().count().next()) was refused with a 400CommandParsingException, because the analysis got a value instead of a traversalquerypath 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 mainIssue11182GremlinWriteThroughFollowerIT: a 3-node Raft cluster, Gremlin over HTTP to a follower. On main the write gets a 503ConcurrentModificationExceptionand thenext()read a 400. With the fix, one vertex lands on every node and the read answers. The test needsarcadedb-ha-raft(test scope) in gremlin and gremlin-it, the same pattern bolt/grpcw already use-Pintegration): 724 unit and 1963 IT, 0 failuresSummary by CodeRabbit