You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "JisoLya (via GitHub)" <gi...@apache.org> on 2026/05/15 06:26:22 UTC

[PR] fix(server): different graph name share the same backend [hugegraph]

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

   …ackend
   
   <!-- 
     Thank you very much for contributing to Apache HugeGraph, we are happy that you want to help us improve it!
   
     Here are some tips for you:
       1. If this is your first time, please read the [contributing guidelines](https://github.com/apache/hugegraph/blob/master/CONTRIBUTING.md)
   
       2. If a PR fix/close an issue, type the message "close xxx" (xxx is the link of related 
   issue) in the content, GitHub will auto link it (Required)
   
       3. Name the PR title in "Google Commit Format", start with "feat | fix | perf | refactor | doc | chore", 
         such like: "feat(core): support the PageRank algorithm" or "fix: wrong break in the compute loop" (module is optional)
         skip it if you are unsure about which is the best component.
   
       4. One PR address one issue, better not to mix up multiple issues.
   
       5. Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]` (or click it directly after 
   published)
   -->
   
   ## Purpose of the PR
   
   - close #3007 
   
   <!--
   Please explain more context in this section, clarify why the changes are needed. 
   e.g:
   - If you propose a new API, clarify the use case for a new API.
   - If you fix a bug, you can clarify why it is a bug, and should be associated with an issue.
   -->
   
   During backend initialization, the server creates two graphs — ~sys_graph and hugegraph (default) — that share the same store backend. This leads to a key collision:
   
   - ~sys_graph writes server node info with id server-1 
   - ~sys_graph reads back server-1 successfully 
   - hugegraph writes server node info with the same id server-1 
   - hugegraph reads from the shared table — retrieves ~sys_graph's record instead → type mismatch → parse error
   
   
   
   ## Verifying these changes
   
   <!-- Please pick the proper options below -->
   
   - [ ] Trivial rework / code cleanup without any test coverage. (No Need)
   - [x] Already covered by existing tests, such as *(please modify tests here)*.
   - [ ] Need tests and can be verified as follows:
       - xxx
   
   ## Does this PR potentially affect the following parts?
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ]  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)) <!-- Don't forget to add/update the info in "LICENSE" & "NOTICE" files (both in root & dist module) -->
   - [ ]  Modify configurations
   - [ ]  The public API
   - [ ]  Other affects (typed here)
   - [x]  Nope
   
   
   ## Documentation Status
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ]  `Doc - TODO` <!-- Your PR changes impact docs and you will update later -->
   - [ ]  `Doc - Done` <!-- Related docs have been already added or updated -->
   - [x]  `Doc - No Need` <!-- Your PR changes don't impact/need docs -->
   


-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] fix(server): different graph name share the same backend [hugegraph]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #3027:
URL: https://github.com/apache/hugegraph/pull/3027#discussion_r3246541875


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java:
##########
@@ -162,7 +163,9 @@ public Id selfNodeId() {
         if (this.globalNodeInfo == null) {
             return null;
         }
-        return this.globalNodeInfo.nodeId();
+        // Scope server id to graph to avoid cross-graph collision
+        return IdGenerator.of(this.graph.spaceGraphName() + "/" +
+                             this.globalNodeInfo.nodeId().asString());
     }

Review Comment:
   ‼️ **Critical:`initServerInfo()` 中读写路径 ID 不一致(阻塞性问题)**
   
   此处修改后 `selfNodeId()` 返回命名空间化的 ID(如 `DEFAULT-hugegraph/server-1`),但调用方 `initServerInfo()` 的存在性检查仍使用原始裸 ID,两条路径的 key 不同:
   
   ```java
   // initServerInfo()(本 PR 未修改这部分)
   Id serverId = nodeInfo.nodeId();                        // ❌ 裸 ID:"server-1"
   HugeServerInfo existed = this.serverInfo(serverId);    // ❌ 用 "server-1" 查询
   // ...
   this.globalNodeInfo = nodeInfo;                        // line 140,赋值后 selfNodeId() 才变
   this.saveServerInfo(this.selfNodeId(), ...);            // ✅ 保存 "DEFAULT-hugegraph/server-1"
   ```
   
   **后果:**
   - lines 109–122 的 alive 检查(防止同名节点重复启动的保护)永远查不到已命名空间化的旧记录,保护逻辑被静默跳过
   - 重启时旧的命名空间记录不会被正确识别,会直接写入新记录,旧记录成为孤儿数据积累在 backend 中
   
   **建议修法:** 在 `initServerInfo()` 入口先设置 `globalNodeInfo`,再统一用 `selfNodeId()` 做后续查询,保持读写 key 一致:
   
   ```java
   public synchronized void initServerInfo(GlobalMasterInfo nodeInfo) {
       E.checkArgument(nodeInfo != null, "The global node info can't be null");
       this.globalNodeInfo = nodeInfo;   // 先赋值,selfNodeId() 立即返回命名空间 ID
       Id serverId = this.selfNodeId();  // ✅ 与 save / remove 路径使用同一个 key
       HugeServerInfo existed = this.serverInfo(serverId);
       if (existed != null && existed.alive()) {
           // ... 存活检查 & 等待逻辑不变 ...
       }
       E.checkArgument(existed == null || !existed.alive(),
                       "The server with name '%s' already in cluster", serverId);
       // master 唯一性检查不变 ...
       this.saveServerInfo(serverId, this.selfNodeRole());
   }
   ```
   
   这样读取和写入始终使用同一个 ID,alive 检查和 master 唯一性保护才能真正生效。



-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] fix(server): different graph name share the same backend [hugegraph]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #3027:
URL: https://github.com/apache/hugegraph/pull/3027#issuecomment-4457987128

   ## [Codecov](https://app.codecov.io/gh/apache/hugegraph/pull/3027?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 29.42%. Comparing base ([`e108076`](https://app.codecov.io/gh/apache/hugegraph/commit/e108076aca60c06735fc1b315a4dd6c15f7562c1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`52df303`](https://app.codecov.io/gh/apache/hugegraph/commit/52df3037a9b8f274fac8961994b65ae17abb41eb?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 1 commits behind head on master.
   > :exclamation:  There is a different number of reports uploaded between BASE (e108076) and HEAD (52df303). Click for more details.
   > 
   > <details><summary>HEAD has 2 uploads less than BASE</summary>
   >
   >| Flag | BASE (e108076) | HEAD (52df303) |
   >|------|------|------|
   >||3|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3027      +/-   ##
   ============================================
   - Coverage     35.85%   29.42%   -6.44%     
   + Complexity      338      264      -74     
   ============================================
     Files           802      803       +1     
     Lines         67995    68040      +45     
     Branches       8902     8905       +3     
   ============================================
   - Hits          24381    20020    -4361     
   - Misses        41008    45700    +4692     
   + Partials       2606     2320     -286     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/hugegraph/pull/3027?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] fix(server): different graph name share the same backend [hugegraph]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin merged PR #3027:
URL: https://github.com/apache/hugegraph/pull/3027


-- 
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: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org