byteayan opened a new pull request, #3351:
URL: https://github.com/apache/hugegraph/pull/3351

   ## Purpose of the PR
   
   - close #3228
   
   Gremlin Server opens the graphs in `conf/graphs` itself, once, inside 
`HugeGremlinServer.prepare()`. TinkerPop's `DefaultGraphManager` logs and drops 
any graph whose open throws. That open runs before the REST `GraphManager` 
exists, so it also runs before the `pd.stores_wait_timeout` wait. When PD is 
briefly unreachable at that point, the Gremlin open fails. A few seconds later 
REST opens the same graph successfully, after its wait. 
`GraphManager.loadGraph(String, String)` then stored the graph without firing 
`GRAPH_CREATE`, which is the only way `ContextGremlinServer` binds a graph 
after startup. The Server answered REST and passed readiness, and every Gremlin 
call on that graph failed with `Could not rebind [DEFAULT-hugegraph]` until the 
process restarted.
   
   Graphs created through the API or loaded from PD meta don't have this 
problem, because `createGraph()` and `createGraphLocal()` already notify 
`GRAPH_CREATE`.
   
   ## Main Changes
   
   - `GraphManager.loadGraph()` calls a new `bindLocalGraph()`, which fires 
`GRAPH_CREATE` for the loaded graph through the same `notifyEvent()` the create 
paths use. This resolves the TODO from #3260.
   - In the normal case Gremlin's open succeeded and the rebind is harmless. 
Both opens go through the same `gremlin.graph` factory, `HugeFactory` caches 
graphs by name, and `HugeFactoryAuthProxy` caches one proxy per graph, so 
Gremlin is handed the instance it already holds. `injectGraph()` overwrites the 
binding, the `__g_` traversal source and the global binding, and it runs before 
`startPrepared()`, so no request can see a half-updated binding.
   - The event is skipped, with a WARN, when the graph's `spaceGraphName()` 
differs from `DEFAULT-<conf file name>`: the `store` value differs from the 
file name, or `graphspace` isn't `DEFAULT`. Gremlin binds that file as 
`DEFAULT-<file>`, so firing the event would add a second binding and a second 
REST entry under the other name.
   - A failed bind is logged at ERROR and the graph stays loaded in REST. 
Rethrowing would end up in the `catch (Throwable)` in `loadGraphsFromLocal()` 
with the same result, and failing startup over it is a separate decision.
   - `reload()` drops graphs with `GRAPH_DROP`, which removes their Gremlin 
binding, and the local reload never brought it back. It does now.
   - `helm/hugegraph/docs/operations.md`: the `Could not rebind` row now says 
which log lines to check on images with this fix. The per-Pod Gremlin check in 
`helm test` stays, since older images still need it.
   
   ## Verifying these changes
   
   - [x] Need tests and can be verified as follows:
       - New `GraphManagerLocalGraphBindTest`, registered in `UnitTestSuite`, 
uses the memory backend and needs no PD. It checks that a local load fires 
`GRAPH_CREATE` once, and that loading again keeps the same instance. A graph 
whose store name differs from its file name is not rebound. With a real 
`ContextGremlinServer` and no static graph (the failed-open case), the graph 
ends up bound along with its `__g_` traversal source. When Gremlin opened the 
graph itself, its instance stays the one REST holds.
       - With the `bindLocalGraph()` call removed, 3 of the 5 tests fail.
       - `mvn test -pl hugegraph-server/hugegraph-test -P unit-test`: 1170 
tests, 0 failures.
       - `run-api-test.sh rocksdb` (packaged Server with auth, as in CI): 189 
tests, 0 failures, and the runtime log check passes.
       - Not reproduced end to end: the original failure needs a 3 PD + 3 Store 
cluster rolled during Server start and showed up in 4 of 12 starts in the issue.
   
   ## Does this PR potentially affect the following parts?
   
   - [ ]  Dependencies ([add/update 
license](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/#321-check-licenses)
 info & 
[regenerate_known_dependencies.sh](../install-dist/scripts/dependency/regenerate_known_dependencies.sh))
   - [ ]  Modify configurations
   - [ ]  The public API
   - [x]  Other affects (typed here): Server startup now offers each graph in 
`conf/graphs` to Gremlin Server a second time; graphs Gremlin already holds are 
unchanged
   - [ ]  Nope
   
   ## Documentation Status
   
   - [ ] `Doc - TODO`: required documentation is pending; complete it before 
merging.
   - [x] `Doc - Done`: documentation is included here or linked below.
   - [ ] `Doc - No Need`: no user-visible documentation is affected.
   
   Documentation files in this PR or paired hugegraph-doc PR:
   - `helm/hugegraph/docs/operations.md`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to