SebastianGruza opened a new pull request, #3220: URL: https://github.com/apache/hugegraph/pull/3220
## Purpose of the PR Closes #3219. A server upgraded from 1.7.0 with `usePD=true` reads an empty schema, because `StandardHugeGraph` connects the `MetaManager` under the literal `hg` before `GraphManager` gets to use the configured `cluster` (`hg-test`); since #3008 `HugeGremlinServer.prepare()` opens the graphs from `conf/graphs` before the REST server starts, so the graph-level connect wins. The meta keys are prefixed with the cluster name and `MetaManager.connect()` binds it once per process. Mechanism and key listing in the issue. ## Main Changes - `HugeGraphServer`: with `usePD=true`, connect the `MetaManager` under `ServerOptions.CLUSTER` before `HugeGremlinServer.prepare()`, through the new static `GraphManager.connectMetaManager(conf)`, which `initMetaManager()` uses as well (same CA handling, one place). - `StandardHugeGraph`: connect only when nothing connected yet (`isReady()`), and take the cluster name from the new `CoreOptions.PD_CLUSTER` (`pd.cluster`) instead of the literal. The default stays `hg`, so `usePD=false` deployments keep reading their existing keys; with `usePD=true` the server's `cluster` wins, as in 1.7.0. Startup order no longer matters. - `MetaManager`: `connect()` logs a WARN when it ignores a different cluster name; new `ensureCluster(expected)` throws `IllegalStateException` naming both clusters and the prefix the keys live under. The server calls it right after its own connect, so a conflict fails the startup instead of yielding an empty schema. ## Verifying these changes - [x] Make sure there is no significant performance impact - [x] Add new unit test(s): `MetaManagerClusterTest` (6 tests, registered in `UnitTestSuite`): the first connect wins and later names are ignored; `ensureCluster` fails with both names and requires a connection; `GraphManager.connectMetaManager` detects an earlier graph-level connect under `hg` and is idempotent under the configured name; the `pd.cluster` default is `hg`. Mocked `MetaDriver`, no PD needed. - [x] Lab, 1 PD + 3 stores, data written by the official 1.7.0 release with `usePD=true`: master without this change → 0 property keys, `Undefined vertex label`; master with this change → 13 property keys, 3 vertex labels, 3 edge labels, 4 index labels, 29 V / 63 E, 20/20 REST and Gremlin reads identical to the 1.7.0 baseline, no cluster warning in the log. With `usePD=false` the swap worked before and works after (HStore and RocksDB). Scripts and logs: https://github.com/SebastianGruza/hugegraph-validation/tree/master/results/upgrade-170-to-master ## Does this PR potentially affect the following parts? - [ ] Nope - [x] Dependencies (add/update license info) — no - [ ] Modify configurations - [x] Introduce new configurations: `pd.cluster` in `CoreOptions` - [ ] The public API - [ ] Other affected components or behavior Docs: the description of `cluster` should say that with `usePD=true` it is the prefix of the meta keys in PD and must stay the same across upgrades. ## Notes Out of scope, for a separate thread: a small migration tool for the prefix (`hg-test` → `hg` or back, about 100 keys per graph through `KvClient`), and a startup diagnostic listing the existing prefixes when the configured one is empty. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
