imbajin commented on code in PR #3220:
URL: https://github.com/apache/hugegraph/pull/3220#discussion_r4053285762
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -727,19 +727,38 @@ public void destroy() {
}
private void initMetaManager(HugeConfig conf) {
+ if (conf.get(ServerOptions.META_USE_CA)) {
+ this.ca = new K8sDriver.CA(conf.get(ServerOptions.META_CA),
+ conf.get(ServerOptions.META_CLIENT_CA),
+
conf.get(ServerOptions.META_CLIENT_KEY));
+ }
+ connectMetaManager(conf);
+ }
+
+ /**
+ * Connect the MetaManager under the cluster name of rest-server.properties
+ * (option 'cluster'). Idempotent, and it fails when the MetaManager was
+ * connected earlier under another name: the meta keys are prefixed with
+ * the cluster, so the server would otherwise read an empty tree. Called
+ * from HugeGraphServer before any graph is opened, because opening an
+ * hstore graph connects the MetaManager with the graph's 'pd.cluster'
+ * (default 'hg') if nothing connected it yet.
+ */
+ public static void connectMetaManager(HugeConfig conf) {
+ String cluster = conf.get(ServerOptions.CLUSTER);
String endpoints = conf.get(ServerOptions.PD_PEERS);
- boolean useCa = conf.get(ServerOptions.META_USE_CA);
String ca = null;
String clientCa = null;
String clientKey = null;
- if (useCa) {
+ if (conf.get(ServerOptions.META_USE_CA)) {
ca = conf.get(ServerOptions.META_CA);
clientCa = conf.get(ServerOptions.META_CLIENT_CA);
clientKey = conf.get(ServerOptions.META_CLIENT_KEY);
- this.ca = new K8sDriver.CA(ca, clientCa, clientKey);
}
- this.metaManager.connect(this.cluster, MetaManager.MetaDriverType.PD,
- ca, clientCa, clientKey, endpoints);
+ MetaManager manager = MetaManager.instance();
+ manager.connect(cluster, MetaManager.MetaDriverType.PD,
+ ca, clientCa, clientKey, endpoints);
+ manager.ensureCluster(cluster);
Review Comment:
‼️ Critical. In a `usePD=false` HStore startup, `HugeGraphServer` skips the
pre-bind at its `usePD` guard, while `HugeGremlinServer.prepare()` opens the
graph before `HugeRestServer.start()`; the graph then binds `MetaManager`
through the `pd.cluster` fallback (default `hg`).
`GraphManager.initMetaManager()` subsequently calls this method
unconditionally, and the default server `cluster` is `hg-test`, so
`ensureCluster(cluster)` throws instead of preserving the graph-level binding.
This regresses the usePD=false compatibility path described by the PR. Please
gate this check to the explicit usePD=true server bind, or otherwise use the
already-bound graph cluster for usePD=false, and add a startup test covering
that path.
--
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]