Skip to content

fix(server): correct graph synchronization bug#74

Merged
imbajin merged 6 commits intohugegraph:1.7-rebasefrom
koi2000:graph-sync
Oct 28, 2025
Merged

fix(server): correct graph synchronization bug#74
imbajin merged 6 commits intohugegraph:1.7-rebasefrom
koi2000:graph-sync

Conversation

@koi2000
Copy link
Copy Markdown

@koi2000 koi2000 commented Oct 28, 2025

Purpose of the PR

  • close #xxx

Main Changes

Added a monitoring mechanism for metadata changes, supporting graph creation, deletion, updates, and clearing operations.

Introduced the listenMetaChanges method in GraphManager to register various graph change handlers.
Implemented graphAddHandler, graphRemoveHandler, graphUpdateHandler, and graphClearHandler processing functions
Supported permission verification via PD authentication configuration
Added started status setting interface to control graph service startup state
Optimized graph creation logic to prevent duplicate initialization and enhance error handling mechanisms

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • 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?

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

Summary by CodeRabbit

发布说明

  • 新增功能

    • 增强元数据事件监听,支持图的添加、移除、更新与清除的实时处理并能动态响应这些事件。
    • 新增可设置的启动状态接口,可对实例的启动/停止状态进行外部修改。
  • 安全改进

    • 启动状态的修改引入权限校验,强化对启动/停止状态变更的控制。
    • 在 PD 客户端与初始化流程中加入认证授权配置,提升分布式元数据存储的安全性。
  • 测试/初始化

    • 测试与初始化流程同步了 PD 授权配置,确保本地/测试环境行为与运行时一致。

Copilot AI review requested due to automatic review settings October 28, 2025 12:18
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 28, 2025
@github-actions
Copy link
Copy Markdown

@codecov-ai-reviewer review

@codecov-ai
Copy link
Copy Markdown

codecov-ai bot commented Oct 28, 2025

On it! We are reviewing the PR and will provide feedback shortly.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 28, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

新增对图启动状态的 setter 方法 started(boolean),在基于 PD 的元数据加载路径中注册图元数据事件监听(增删改清),并在多个初始化位置为 PD 客户端注入/设置认证/权限信息(PDAuthConfig/ServiceConstant)。

Changes

Cohort / File(s) 变更摘要
图状态管理
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeGraphAuthProxy.java, hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java, hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/StandardHugeGraph.java
新增 public void started(boolean started) setter(同时保留原 boolean started());AuthProxy 对 setter 做管理员权限校验并委托到底层 Graph 实现;StandardHugeGraph 同步设置内部 started 标志。
元数据事件监听
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java
在 PD 基于的元数据加载路径调用 listenMetaChanges() 并新增四个私有处理器:graphAddHandlergraphRemoveHandlergraphUpdateHandlergraphClearHandler,分别处理图的创建、删除、更新(如读模式调整)与清理通知。
PD 配置与认证(驱动/初始化)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java, hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImpl.java
构造 PDConfig 时注入权限:调用 setAuthority(ServiceConstant.SERVICE_NAME, ServiceConstant.AUTHORITY) / setAuthority(PDAuthConfig.service(), PDAuthConfig.token()),并用该配置构造 KvClient/PDClient(内部初始化改动)。
启动流程权限设置
hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java
在 InitStore 启动流程中新增对 PDAuthConfig.setAuthority(ServiceConstant...) 的调用以设置 PD 权限。
测试框架权限设置
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java
在测试初始化 init() 中加入 PdMetaDriver.PDAuthConfig.setAuthority(ServiceConstant.SERVICE_NAME, ServiceConstant.AUTHORITY),为测试中的 PD 客户端配置权限。

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PdMetaDriver
    participant GraphManager
    participant MetaEventBus
    participant EventHandler
    participant HugeGraphAuthProxy
    participant HugeGraph

    Note over PdMetaDriver: PDConfig 构造时注入 PDAuthConfig/ServiceConstant 权限
    Client->>PdMetaDriver: 请求初始化/加载 PD 元数据
    PdMetaDriver->>GraphManager: 返回元数据
    GraphManager->>GraphManager: register listenMetaChanges() -> MetaEventBus

    Note over MetaEventBus,EventHandler: PD 元数据事件(add/remove/update/clear)
    MetaEventBus->>EventHandler: graphAdd / graphRemove / graphUpdate / graphClear

    alt graphAdd
        EventHandler->>GraphManager: create graph from meta
        GraphManager->>HugeGraph: instantiate & start graph
    end

    alt graphUpdate
        EventHandler->>HugeGraph: update config (e.g., read mode)
    end

    Client->>HugeGraphAuthProxy: started(true)
    HugeGraphAuthProxy->>HugeGraphAuthProxy: verifyAdminPermission()
    HugeGraphAuthProxy->>HugeGraph: started(true)
    HugeGraph->>HugeGraph: 更新 started 标志
Loading

Estimated code review effort

🎯 3 (中等) | ⏱️ ~25 分钟

需要特别关注:

  • GraphManager 中四个事件处理器的并发/错误处理与权限校验(创建/删除时的 race 条件和异常恢复策略)。
  • 新增的 started(boolean) 在多线程场景下的同步/可见性(StandardHugeGraph 已同步,但需核查调用方一致性)。
  • PDConfig.setAuthority 的调用时序,确保在任何 PD client/KvClient 构造之前完成设置。

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • Pengzna
  • imbajin

Poem

🐰 我在元数据间轻跳,听见事件叮咚响,
权限已系好小带,图的生灭入我掌,
新的开关悄悄按,状态随心而忙,
小爪一挥,服务里春意又荡漾 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 标题"fix(server): correct graph synchronization bug"与变更相关联。从代码变更来看,主要改动包括在GraphManager中添加listenMetaChanges()方法和相应的事件处理器(graphAddHandler、graphRemoveHandler、graphUpdateHandler、graphClearHandler),这些正是为了实现元数据变更监听机制来解决图同步问题。标题准确反映了这一核心目的。虽然变更还包含其他方面(如PD身份验证配置和started状态接口),但作为拉取请求标题,无需涵盖所有细节。标题足够清晰具体,能帮助开发者扫描历史时理解主要变更。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d8b8d0b and 73adf0a.

⛔ Files ignored due to path filters (1)
  • hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/dist/HugeGraphServer.java is excluded by !**/dist/**
📒 Files selected for processing (3)
  • hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (6 hunks)
  • hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/StandardHugeGraph.java (1 hunks)
  • hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java
  • hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/StandardHugeGraph.java
🧰 Additional context used
🧬 Code graph analysis (1)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java (2)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/constant/ServiceConstant.java (1)
  • ServiceConstant (26-29)
hugegraph-pd/hg-pd-client/src/main/java/org/apache/hugegraph/pd/client/PDConfig.java (1)
  • PDConfig (28-136)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: store
  • GitHub Check: build-server (hbase, 11)
  • GitHub Check: build-server (rocksdb, 11)
  • GitHub Check: build-server (memory, 11)
  • GitHub Check: build-commons (11)
  • GitHub Check: cluster-test
  • GitHub Check: dependency-check
  • GitHub Check: Analyze (java)
🔇 Additional comments (2)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java (2)

27-27: 导入必要的常量类

导入 ServiceConstant 是为了在构造函数中使用认证配置常量,符合预期。


51-53: 需要进一步验证代码中是否存在认证配置不一致的问题。

Based on the script execution results, I can now provide a comprehensive analysis:

确认代码更改有实际的集成问题

此更改引入了认证配置的不一致性。您的代码在第 51-53 行使用 ServiceConstant.AUTHORITY(空字符串)直接初始化认证,但脚本结果显示:

  1. PDAuthConfig 仍在被主动使用

    • HstoreSessionsImpl.java 第 115 行调用 PDAuthConfig.service()PDAuthConfig.token()
    • GraphManager.java 第 350-351、829-830 行调用 PdMetaDriver.PDAuthConfig.service().token()
  2. 初始化流程问题

    • InitStoreCoreTestSuite 会调用 PDAuthConfig.setAuthority() 来设置静态字段
    • 其他组件随后读取这些静态字段获取认证信息
    • 新的 PdMetaDriver 代码完全忽略 PDAuthConfig 的共享状态

这种设计可能导致运行时不一致:如果某处代码调用 PDAuthConfig.setAuthority() 设置不同的认证值(例如自定义密码),PdMetaDriver 仍会使用默认的空字符串,而不是更新后的值。

建议

  • 确认 PdMetaDriver 是否应该尊重 PDAuthConfig 的动态设置,或者该改变意在表示 PD 通信始终使用默认认证
  • 如果后者是有意设计,应在代码中添加明确的注释说明为什么跳过 PDAuthConfig 机制
  • 如果两个代码路径需要不同的认证策略,应通过参数化而非硬编码常量来实现

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @koi2000, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a graph synchronization bug by introducing a robust metadata change monitoring system. It enables the server to react dynamically to graph lifecycle events such as creation, deletion, updates, and clearing, ensuring that the graph state remains consistent across the system. The changes also incorporate PD authentication for secure permission verification and refine the graph creation process for better stability.

Highlights

  • Metadata Change Monitoring: Implemented a mechanism to monitor metadata changes for graph creation, deletion, updates, and clearing operations.
  • Graph Lifecycle Handlers: Introduced the listenMetaChanges method in GraphManager to register and process specific handlers for graph add, remove, update, and clear events.
  • Permission Verification: Integrated PD authentication configuration to support permission verification for graph operations.
  • Graph Service State Control: Added a started status setting interface to control the startup state of graph services.
  • Graph Creation Optimization: Optimized graph creation logic to prevent duplicate initialization and improve error handling.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a graph synchronization bug by adding a metadata change monitoring mechanism. The changes enable the HugeGraph server to listen for and respond to graph lifecycle events (creation, deletion, updates, and clearing) propagated through the metadata store.

Key Changes:

  • Added authentication support for PD (Placement Driver) client connections across multiple components
  • Implemented metadata change listeners in GraphManager to handle graph lifecycle events
  • Added a started(boolean) setter method to control graph startup state

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
GraphManager.java Added listenMetaChanges() and four handler methods to process graph add/remove/update/clear events from metadata store
HugeGraph.java Added started(boolean) setter interface for controlling graph startup state
StandardHugeGraph.java Implemented the new started(boolean) setter method
HugeGraphAuthProxy.java Added authorization wrapper for the new started(boolean) setter
PdMetaDriver.java Configured PD client to use authentication credentials
HstoreSessionsImpl.java Added authentication configuration to PD client initialization
InitStore.java Added setPdAuthority() helper method to configure PD authentication
CoreTestSuite.java Set PD authentication in test setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2191 to +2195
LOG.warn(String.format("Listen event: graph [%s] add was discarded because " +
"it did " +
"not belong to the graph space [%s] registered by " +
"the" + " current server", graphName,
this.serviceGraphSpace));
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string formatting has awkward line breaks that split words ('did' on line 2192 and 'the' on line 2194). Consider reformatting for better readability, such as: LOG.warn(\"Listen event: graph [{}] add was discarded because it did not belong to the graph space [{}] registered by the current server\", graphName, this.serviceGraphSpace);

Suggested change
LOG.warn(String.format("Listen event: graph [%s] add was discarded because " +
"it did " +
"not belong to the graph space [%s] registered by " +
"the" + " current server", graphName,
this.serviceGraphSpace));
LOG.warn(String.format(
"Listen event: graph [%s] add was discarded because it did not belong to the graph space [%s] registered by the current server",
graphName, this.serviceGraphSpace));

Copilot uses AI. Check for mistakes.
Comment on lines +2230 to +2231
boolean grpcThread = Thread.currentThread().getName().contains("grpc");
if (grpcThread) {
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name grpcThread is misleading because it stores a boolean indicating whether the current thread name contains 'grpc', not the thread itself. Consider renaming to isGrpcThread to better reflect its boolean nature.

Suggested change
boolean grpcThread = Thread.currentThread().getName().contains("grpc");
if (grpcThread) {
boolean isGrpcThread = Thread.currentThread().getName().contains("grpc");
if (isGrpcThread) {

Copilot uses AI. Check for mistakes.
Comment on lines +2188 to +2194
// it will only receive graph creation events under the registered schemas.
if (!"DEFAULT".equals(this.serviceGraphSpace) &&
!parts[0].equals(this.serviceGraphSpace)) {
LOG.warn(String.format("Listen event: graph [%s] add was discarded because " +
"it did " +
"not belong to the graph space [%s] registered by " +
"the" + " current server", graphName,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic error: The 'return' statement at line 2193 should be 'continue'. When a graph doesn't belong to the registered service graph space, the handler should skip that graph and continue processing other graphs in the list, not return from the entire method. This will cause the handler to exit prematurely without processing all remaining graphs in the response.
Severity: CRITICAL

💡 Suggested Fix

Suggested change
// it will only receive graph creation events under the registered schemas.
if (!"DEFAULT".equals(this.serviceGraphSpace) &&
!parts[0].equals(this.serviceGraphSpace)) {
LOG.warn(String.format("Listen event: graph [%s] add was discarded because " +
"it did " +
"not belong to the graph space [%s] registered by " +
"the" + " current server", graphName,
continue;

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines +2178 to +2180
private <T> void graphAddHandler(T response) {
List<String> names = this.metaManager
.extractGraphsFromResponse(response);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent delimiter usage: The graphAddHandler uses 'DELIMITER' to split graph names (line 2180), but graphUpdateHandler uses 'MetaManager.META_PATH_JOIN' (line 2243). This inconsistency could cause parsing errors if the two constants have different values. Use the same delimiter consistently across all handlers for graph name parsing.
Severity: HIGH

🤖 Prompt for AI Agent

Fix this code. In
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java#L2178-L2180:
Inconsistent delimiter usage: The graphAddHandler uses 'DELIMITER' to split graph names
(line 2180), but graphUpdateHandler uses 'MetaManager.META_PATH_JOIN' (line 2243). This
inconsistency could cause parsing errors if the two constants have different values. Use
the same delimiter consistently across all handlers for graph name parsing.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines +2210 to +2230
if (config == null) {
LOG.error("The graph config not exist: {}", graphName);
continue;
}
Object objc = config.get("creator");
String creator = null == objc ?
GraphSpace.DEFAULT_CREATOR_NAME :
String.valueOf(objc);

// Create graph without init
try {
HugeGraph graph;
// TODO: add alias graph
// if (config.containsKey(CoreOptions.ALIAS_NAME.name())) {
// //graph = this.createAliasGraph(parts[0], parts[1], config, true);
// LOG.info("Add aliasGraph space:{} graph:{}", parts[0], parts[1]);
// } else {
// }
graph = this.createGraph(parts[0], parts[1], creator, config, false);
LOG.info("Add graph space:{} graph:{}", parts[0], parts[1]);
boolean grpcThread = Thread.currentThread().getName().contains("grpc");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential null pointer exception: At line 2226, 'config.get("creator")' could return null, and while there is a null check, the subsequent String.valueOf() on line 2228 should ensure null safety. However, accessing 'this.metaManager.getGraphConfig()' at line 2215 could return null, which is checked at line 2217, but ensure all paths that could return null are properly validated before use.
Severity: MEDIUM

🤖 Prompt for AI Agent

Fix this code. In
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java#L2210-L2230:
Potential null pointer exception: At line 2226, 'config.get("creator")' could return
null, and while there is a null check, the subsequent String.valueOf() on line 2228
should ensure null safety. However, accessing 'this.metaManager.getGraphConfig()' at
line 2215 could return null, which is checked at line 2217, but ensure all paths that
could return null are properly validated before use.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines +2238 to +2243
} catch (HugeException e) {
if (!this.startIgnoreSingleGraphError) {
throw e;
}
LOG.error(String.format(
"Failed to create graph '%s'", graphName), e);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential resource leak: In graphAddHandler, if an exception occurs after 'graph.tx()' is opened (between line 2240 and line 2242), the transaction may not be properly closed. The current code only closes the transaction if it's open after calling 'graph.started(true)', but this assumes the graph startup completed successfully. Consider using try-with-resources or a finally block to ensure the transaction is always closed.
Severity: HIGH

🤖 Prompt for AI Agent

Fix this code. In
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java#L2238-L2243:
Potential resource leak: In graphAddHandler, if an exception occurs after 'graph.tx()'
is opened (between line 2240 and line 2242), the transaction may not be properly closed.
The current code only closes the transaction if it's open after calling
'graph.started(true)', but this assumes the graph startup completed successfully.
Consider using try-with-resources or a finally block to ensure the transaction is always
closed.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines +2251 to +2261
for (String graphName : graphNames) {
if (!this.graphs.containsKey(graphName) ||
this.removingGraphs.contains(graphName)) {
this.removingGraphs.remove(graphName);
continue;
}

// Remove graph without clear
String[] parts = graphName.split(DELIMITER);
if (parts.length < 2) {
LOG.error("The graph name format is incorrect: {}", graphName);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing null check: In graphUpdateHandler at line 2253, 'this.graphs.get(graphName)' could return null before checking 'instanceof HugeGraph'. Additionally, configs returned from 'this.metaManager.getGraphConfig()' at line 2255 is not null-checked before calling 'getOrDefault()'. Add proper null validation.
Severity: MEDIUM

🤖 Prompt for AI Agent

Fix this code. In
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java#L2251-L2261:
Missing null check: In graphUpdateHandler at line 2253, 'this.graphs.get(graphName)'
could return null before checking 'instanceof HugeGraph'. Additionally, configs returned
from 'this.metaManager.getGraphConfig()' at line 2255 is not null-checked before calling
'getOrDefault()'. Add proper null validation.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines +50 to +51
PDConfig pdConfig =
PDConfig.of(pdPeer).setAuthority(PDAuthConfig.service(), PDAuthConfig.token());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thread safety issue: The PDAuthConfig.service() and PDAuthConfig.token() are being called at initialization time in the PdMetaDriver constructor (line 50). If PDAuthConfig.setAuthority() is called after this constructor executes, this will use stale values. The constructor should either be called after authority is set, or the authority retrieval should be deferred until needed (lazy initialization). This pattern is repeated across multiple files (InitStore.java, HugeGraphServer.java, HstoreSessionsImpl.java).
Severity: HIGH

🤖 Prompt for AI Agent

Fix this code. In
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java#L50-L51:
Thread safety issue: The PDAuthConfig.service() and PDAuthConfig.token() are being
called at initialization time in the PdMetaDriver constructor (line 50). If
PDAuthConfig.setAuthority() is called after this constructor executes, this will use
stale values. The constructor should either be called after authority is set, or the
authority retrieval should be deferred until needed (lazy initialization). This pattern
is repeated across multiple files (InitStore.java, HugeGraphServer.java,
HstoreSessionsImpl.java).

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines +72 to +77
RegisterUtil.registerServer();

HugeConfig restServerConfig = new HugeConfig(restConf);
setPdAuthority(restServerConfig);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialization order issue: The 'setPdAuthority()' method is called at line 76, but it's not guaranteed that this will be called before PdMetaDriver instances are created. If any other code path creates a PdMetaDriver before reaching line 76, it will use uninitialized authority values. This should be called as early as possible, ideally before any code that might instantiate PdMetaDriver.
Severity: HIGH

🤖 Prompt for AI Agent

Fix this code. In
hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java#L74-L77:
Initialization order issue: The 'setPdAuthority()' method is called at line 76, but it's
not guaranteed that this will be called before PdMetaDriver instances are created. If
any other code path creates a PdMetaDriver before reaching line 76, it will use
uninitialized authority values. This should be called as early as possible, ideally
before any code that might instantiate PdMetaDriver.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines 63 to 68
setPdAuthority();
//this.metaManager.connect(cluster, MetaManager.MetaDriverType.PD,
// caFile, clientCaFile, clientKeyFile,
// metaEndpoints);
try {
// Start HugeRestServer
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialization order issue: Similar to InitStore.java, 'setPdAuthority()' is called at line 64 after several other initialization steps. However, this is called before the actual service creation at lines 70-72, which is better. However, there's commented-out code at lines 65-67 that suggests incomplete implementation. Either complete the implementation or remove the commented code to reduce confusion.
Severity: MEDIUM

🤖 Prompt for AI Agent

Fix this code. In
hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/dist/HugeGraphServer.java#L63-L68:
Initialization order issue: Similar to InitStore.java, 'setPdAuthority()' is called at
line 64 after several other initialization steps. However, this is called before the
actual service creation at lines 70-72, which is better. However, there's commented-out
code at lines 65-67 that suggests incomplete implementation. Either complete the
implementation or remove the commented code to reduce confusion.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines 112 to +115
if (!initializedNode) {
PDConfig pdConfig = PDConfig.of(config.get(CoreOptions.PD_PEERS))
.setAuthority(PDAuthConfig.service(), PDAuthConfig.token())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialization order issue: Similar to the other files, PDAuthConfig authority is being set at class initialization time (line 114), but this pattern depends on 'setPdAuthority()' being called first in HugeGraphServer or InitStore. This tight coupling creates a fragile initialization sequence that's easy to break during refactoring. Consider using a lazy-loading pattern or dependency injection instead.
Severity: MEDIUM

🤖 Prompt for AI Agent

Fix this code. In
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImpl.java#L113-L115:
Initialization order issue: Similar to the other files, PDAuthConfig authority is being
set at class initialization time (line 114), but this pattern depends on
'setPdAuthority()' being called first in HugeGraphServer or InitStore. This tight
coupling creates a fragile initialization sequence that's easy to break during
refactoring. Consider using a lazy-loading pattern or dependency injection instead.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines 73 to +77
public static void init() {
PdMetaDriver.PDAuthConfig.setAuthority(ServiceConstant.SERVICE_NAME,
ServiceConstant.AUTHORITY);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialization order issue: 'PDAuthConfig.setAuthority()' is called in the 'init()' method which is a @BeforeClass static method. However, if tests are run in parallel or in a different order, other tests that use PdMetaDriver might instantiate it before this method is called. Consider using @BeforeClass annotation consistently and ensure this is called very early in the test lifecycle.
Severity: MEDIUM

🤖 Prompt for AI Agent

Fix this code. In
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java#L75-L77:
Initialization order issue: 'PDAuthConfig.setAuthority()' is called in the 'init()'
method which is a @BeforeClass static method. However, if tests are run in parallel or
in a different order, other tests that use PdMetaDriver might instantiate it before this
method is called. Consider using @BeforeClass annotation consistently and ensure this is
called very early in the test lifecycle.

Did we get this right? 👍 / 👎 to inform future reviews.

@dosubot dosubot bot added the bug Something isn't working label Oct 28, 2025
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a metadata change monitoring mechanism to fix a graph synchronization bug. It adds listeners for graph creation, deletion, updates, and clearing, along with their respective handlers in GraphManager. It also adds PD authentication support and an interface to control the graph's started state. The changes are generally good, but I've identified a critical bug in the graphAddHandler logic that could prevent some graphs from being processed. I've also pointed out several areas for improvement regarding code maintainability and readability, including a brittle thread identification mechanism, a very long method that should be refactored, and some duplicated code.

"the" + " current server", graphName,
this.serviceGraphSpace));
// TODO: further confirmation is required
return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

In the graphAddHandler method, the return statement within the for loop will cause the method to exit prematurely if a graph from a different graph space is encountered. This prevents the processing of any subsequent graphs in the same event. This should be changed to continue to skip only the current graph and proceed with the next one in the list.

                continue;

Comment on lines +2230 to +2233
boolean grpcThread = Thread.currentThread().getName().contains("grpc");
if (grpcThread) {
HugeGraphAuthProxy.setAdmin();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Relying on the thread name containing 'grpc' to identify a gRPC thread is brittle and not a reliable practice. Thread names can be changed or managed by thread pools in ways that would break this logic. A more robust approach would be to use a ThreadLocal context that is set by a gRPC interceptor at the beginning of a request and cleared at the end. This would provide a reliable way to determine the request context.

Comment on lines +2191 to +2195
LOG.warn(String.format("Listen event: graph [%s] add was discarded because " +
"it did " +
"not belong to the graph space [%s] registered by " +
"the" + " current server", graphName,
this.serviceGraphSpace));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The string concatenation for this log message is difficult to read. It can be simplified by using a single format string for better clarity.

                LOG.warn(String.format("Listen event: graph [%s] add was discarded because " +
                                       "it did not belong to the graph space [%s] " +
                                       "registered by the current server",
                                       graphName, this.serviceGraphSpace));

Comment on lines +2178 to +2246
private <T> void graphAddHandler(T response) {
List<String> names = this.metaManager
.extractGraphsFromResponse(response);
for (String graphName : names) {
String[] parts = graphName.split(DELIMITER);
if (parts.length < 2) {
LOG.error("The graph name format is incorrect: {}", graphName);
continue;
}
// If the current server is not registered to the DEFAULT schema,
// it will only receive graph creation events under the registered schemas.
if (!"DEFAULT".equals(this.serviceGraphSpace) &&
!parts[0].equals(this.serviceGraphSpace)) {
LOG.warn(String.format("Listen event: graph [%s] add was discarded because " +
"it did " +
"not belong to the graph space [%s] registered by " +
"the" + " current server", graphName,
this.serviceGraphSpace));
// TODO: further confirmation is required
return;
}
LOG.info("Accept graph add signal from etcd for {}", graphName);
if (this.graphs.containsKey(graphName) ||
this.creatingGraphs.contains(graphName)) {
this.creatingGraphs.remove(graphName);
continue;
}

LOG.info("Not exist in cache, Starting construct graph {}",
graphName);
Map<String, Object> config =
this.metaManager.getGraphConfig(parts[0], parts[1]);
if (config == null) {
LOG.error("The graph config not exist: {}", graphName);
continue;
}
Object objc = config.get("creator");
String creator = null == objc ?
GraphSpace.DEFAULT_CREATOR_NAME :
String.valueOf(objc);

// Create graph without init
try {
HugeGraph graph;
// TODO: add alias graph
// if (config.containsKey(CoreOptions.ALIAS_NAME.name())) {
// //graph = this.createAliasGraph(parts[0], parts[1], config, true);
// LOG.info("Add aliasGraph space:{} graph:{}", parts[0], parts[1]);
// } else {
// }
graph = this.createGraph(parts[0], parts[1], creator, config, false);
LOG.info("Add graph space:{} graph:{}", parts[0], parts[1]);
boolean grpcThread = Thread.currentThread().getName().contains("grpc");
if (grpcThread) {
HugeGraphAuthProxy.setAdmin();
}
graph.started(true);
if (graph.tx().isOpen()) {
graph.tx().close();
}
} catch (HugeException e) {
if (!this.startIgnoreSingleGraphError) {
throw e;
}
LOG.error(String.format(
"Failed to create graph '%s'", graphName), e);
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The graphAddHandler method is quite long and handles multiple responsibilities like filtering, validation, configuration fetching, and graph creation. To improve readability and maintainability, consider refactoring this method into several smaller, more focused private methods. For example:

  • A method to perform initial checks and filtering.
  • A method to fetch and prepare the graph configuration.
  • A method to handle the actual graph construction and registration.

Comment on lines +2281 to +2296
String[] values =
graphName.split(MetaManager.META_PATH_JOIN);
if (values.length < 2) {
LOG.error("The graph name format is incorrect: {}", graphName);
continue;
}
Map<String, Object> configs =
this.metaManager.getGraphConfig(values[0],
values[1]);
String readMode = configs.getOrDefault(
CoreOptions.GRAPH_READ_MODE.name(),
CoreOptions.GRAPH_READ_MODE.defaultValue()).toString();
hugeGraph.readMode(GraphReadMode.valueOf(readMode));
// TODO: update alias graph
//this.updateAliasGraph(hugeGraph, configs);
LOG.info("Update graph space:{} graph:{}", values[0], values[1]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In graphUpdateHandler, the split parts of the graph name are used directly as values[0] and values[1]. For better readability, it would be clearer to assign these to named variables like graphSpace and graphName.

                    String[] parts =
                            graphName.split(MetaManager.META_PATH_JOIN);
                    if (parts.length < 2) {
                        LOG.error("The graph name format is incorrect: {}", graphName);
                        continue;
                    }
                    String graphSpace = parts[0];
                    String graphNameInSpace = parts[1];
                    Map<String, Object> configs =
                            this.metaManager.getGraphConfig(graphSpace,
                                                            graphNameInSpace);
                    String readMode = configs.getOrDefault(
                            CoreOptions.GRAPH_READ_MODE.name(),
                            CoreOptions.GRAPH_READ_MODE.defaultValue()).toString();
                    hugeGraph.readMode(GraphReadMode.valueOf(readMode));
                    // TODO: update alias graph
                    //this.updateAliasGraph(hugeGraph, configs);
                    LOG.info("Update graph space:{} graph:{}", graphSpace, graphNameInSpace);

Comment on lines +96 to +100
private void setPdAuthority() {
PdMetaDriver.PDAuthConfig.setAuthority(
ServiceConstant.SERVICE_NAME,
ServiceConstant.AUTHORITY);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The setPdAuthority method is also present in hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java. To avoid code duplication and improve maintainability, this logic should be extracted into a shared utility class or method that both classes can use.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java (1)

214-231: 线程安全问题:PDAuthConfig 使用非同步的静态可变状态

PDAuthConfig 类使用静态字段 servicetoken 存储认证信息,但没有提供线程安全保障:

  1. 缺少同步:setAuthority 和 getter 方法都没有同步机制
  2. 缺少 volatile:静态字段没有声明为 volatile,跨线程可见性无法保证
  3. 缺少空值检查:没有验证输入参数,可能导致下游 NPE

建议改进:

 public static class PDAuthConfig {

-    private static String service;
-    private static String token;
+    private static volatile String service;
+    private static volatile String token;

-    public static void setAuthority(String service, String token) {
+    public static synchronized void setAuthority(String service, String token) {
+        E.checkArgumentNotNull(service, "service cannot be null");
+        E.checkArgumentNotNull(token, "token cannot be null");
         PDAuthConfig.service = service;
         PDAuthConfig.token = token;
     }

     public static String service() {
+        String s = service;
+        E.checkState(s != null, "PDAuthConfig not initialized, call setAuthority first");
-        return service;
+        return s;
     }

     public static String token() {
+        String t = token;
+        E.checkState(t != null, "PDAuthConfig not initialized, call setAuthority first");
-        return token;
+        return t;
     }
 }
🧹 Nitpick comments (4)
hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java (1)

77-77: 移除 setPdAuthority 方法中的未使用参数

方法 setPdAuthority(HugeConfig config) 的参数 config 从未被使用。方法体仅调用 PDAuthConfig.setAuthority() 并传递 ServiceConstant 中的静态值,不依赖传入的配置参数。

建议简化方法签名并移除调用点的参数:

-private static void setPdAuthority(HugeConfig config) {
+private static void setPdAuthority() {
     PDAuthConfig.setAuthority(
             ServiceConstant.SERVICE_NAME,
             ServiceConstant.AUTHORITY);
 }

调用点修改(第 77 行):

-setPdAuthority(restServerConfig);
+setPdAuthority();
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImpl.java (1)

42-42: 添加初始化顺序的文档注释和防御性检查

验证确认,PDAuthConfig.setAuthority() 在生产和测试环境中都在 HstoreSessionsImpl 创建前被调用,初始化顺序由代码设计保证。具体流程为:

  • 生产环境:InitStore.main() 第 77 行调用 setPdAuthority() → 随后第 82+ 行进行图初始化 → HstoreSessionsImpl 被创建
  • 测试环境:@BeforeClass 中调用 setAuthority()Utils.open()HstoreSessionsImpl 被创建

虽然初始化顺序正确,但代码在第 115 行对 PDAuthConfig.service()PDAuthConfig.token() 的调用缺少防御性检查。建议添加:

  1. 文档注释明确说明此类依赖于 PDAuthConfig 已被初始化
  2. 空值检查,防止 servicetoken 为 null 时导致 NullPointerException
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java (1)

244-245: <!-- [scratchpad_start]
[task verify_review_comment]
验证原始审查注释中关于线程安全和文档的建议

[observations]

  • StandardHugeGraph.java 第 180 行:private volatile boolean started; - 字段使用 volatile 修饰
  • StandardHugeGraph.java 第 377-379 行:实现直接赋值 this.started = started;
  • HugeGraphAuthProxy.java 第 789-792 行:实现添加权限检查后委托给代理对象
  • HugeGraph.java 第 242 行:存在 getter 方法 boolean started();
  • HugeGraph.java 第 244-245 行:新增 setter 方法声明 void started(boolean started);
  • 两个方法都缺少 JavaDoc 文档

[analysis]
原始审查注释的两个主要关注点:

  1. 线程安全问题:已通过 volatile 关键字在 StandardHugeGraph 中妥善处理,无需额外关注
  2. 缺少 JavaDoc 文档:确实存在,这是有效的改进建议

原始审查注释中提出的线程安全验证实际上已被解决,不需要额外措施。

[pending]

[actions]
生成中文的重写审查注释,标记为可选重构建议,因为 JavaDoc 是文档改进而非关键修复

[done]
验证完成,确认线程安全已通过 volatile 处理,仅需补充 JavaDoc
[scratchpad_end]

为新增 setter 方法补充 JavaDoc 文档。

线程安全已通过 volatile 关键字妥善处理,但建议为公共接口方法添加清晰的文档说明使用场景和调用约束:

  • 方法的用途(标记图的启动状态)
  • 调用所需权限(管理员权限)
  • 有效的状态转换规则
    /**
     * 标记图的启动状态。此方法用于控制图服务启动态,
     * 通常在图同步操作(创建、删除、更新)中使用。
     * 需要管理员权限。
     *
     * @param started true 表示图已启动,false 表示未启动
     * @throws SecurityException 如果调用者缺少管理员权限
     */
    void started(boolean started);
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (1)

1726-1732: 监听注册缺少成对释放与统一升权策略

  • 建议在 GraphManager 生命周期结束时成对释放 Meta 监听,避免潜在资源泄露(若 MetaManager 提供 unlistenGraph* 能力)。若当前不支持,请在类注释或销毁路径注明由进程生命周期托管。
  • 另建议对元数据监听回调统一在 ConsumerWrapper 内部进行权限升权(而非依赖线程名包含“grpc”),以确保诸如 graph.started(true) 或模式更新在开启鉴权时不会偶发失败。

如需调整 ConsumerWrapper,可参考示例(仅供思路,按实际 API 命名调整):

// 示例:统一升权,确保 finally 恢复
@Override
public void accept(T t) {
    var prev = HugeGraphAuthProxy.getContext(); // 读取旧上下文
    try {
        HugeGraphAuthProxy.setAdmin();          // 无条件或按 requireAuthentication() 条件升权
        consumer.accept(t);
    } catch (Throwable e) {
        LOG.error("Listener exception occurred.", e);
    } finally {
        HugeGraphAuthProxy.setContext(prev);    // 恢复原上下文
    }
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c90f6a6 and 2922cd3.

⛔ Files ignored due to path filters (1)
  • hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/dist/HugeGraphServer.java is excluded by !**/dist/**
📒 Files selected for processing (8)
  • hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeGraphAuthProxy.java (1 hunks)
  • hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (5 hunks)
  • hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java (1 hunks)
  • hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/StandardHugeGraph.java (1 hunks)
  • hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java (1 hunks)
  • hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java (3 hunks)
  • hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImpl.java (2 hunks)
  • hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java (2)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/constant/ServiceConstant.java (1)
  • ServiceConstant (26-29)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java (2)
  • PdMetaDriver (43-232)
  • PDAuthConfig (214-231)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java (1)
hugegraph-pd/hg-pd-client/src/main/java/org/apache/hugegraph/pd/client/PDConfig.java (1)
  • PDConfig (28-136)
hugegraph-server/hugegraph-hstore/src/main/java/org/apache/hugegraph/backend/store/hstore/HstoreSessionsImpl.java (1)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java (2)
  • PdMetaDriver (43-232)
  • PDAuthConfig (214-231)
hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java (2)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/constant/ServiceConstant.java (1)
  • ServiceConstant (26-29)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/PdMetaDriver.java (2)
  • PdMetaDriver (43-232)
  • PDAuthConfig (214-231)
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (4)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/AbstractBackendStoreProvider.java (1)
  • AbstractBackendStoreProvider (37-243)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/space/GraphSpace.java (1)
  • GraphSpace (29-515)
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeGraphAuthProxy.java (1)
  • HugeGraphAuthProxy (114-2211)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/MetaManager.java (1)
  • MetaManager (63-1349)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: dependency-check
  • GitHub Check: build-commons (11)
  • GitHub Check: struct
  • GitHub Check: Analyze (java)
  • GitHub Check: build-server (memory, 11)
  • GitHub Check: build-server (hbase, 11)
  • GitHub Check: build-server (rocksdb, 11)
  • GitHub Check: cluster-test
🔇 Additional comments (5)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/StandardHugeGraph.java (1)

376-380: LGTM!实现正确且线程安全

实现简洁明了,直接赋值给 volatile 字段 started。由于 started 字段声明为 volatile(第 180 行),这个简单的赋值操作具有线程安全性和跨线程可见性保证。

hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeGraphAuthProxy.java (1)

788-792: LGTM!权限检查实现正确

实现遵循了该代理类的一贯模式:

  1. 通过 verifyAdminPermission() 验证管理员权限
  2. 委托给底层的 hugegraph 实例

与同文件中其他管理操作(如第 778 行的 serverStarted)保持一致。

hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CoreTestSuite.java (1)

76-77: 测试权限配置验证结果:无问题发现

代码审查中的两项关切已得到验证:

  1. 权限值为空字符串是正确的:ServiceConstant.AUTHORITY 在 hugegraph-core/src/main/java/org/apache/hugegraph/constant/ServiceConstant.java:28 定义为空字符串 "",这是测试环境的预期配置。

  2. 无需担心测试隔离问题:CoreTestSuite.java 使用 @RunWith(Suite.class) 注解,表示测试套件按顺序执行,不支持并行执行。因此,全局静态状态设置不会导致测试隔离问题。

代码实现是正确的,无需修改。

hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (2)

373-374: 在加载图后再注册元数据监听,顺序合理

位置与时机得当,避免监听早于本地缓存初始化。无阻塞问题。


2248-2271: 删除事件处理基本正确

存在并发自护(removingGraphs 标记)和健壮性检查。无明显阻塞或一致性问题。

请确认 MetaManager.remove 通知与本地 dropGraph 时序在多节点下不会产生“二次删除”竞态(当前通过标记规避,看起来可接受)。

Comment on lines +2231 to +2235
if (grpcThread) {
HugeGraphAuthProxy.setAdmin();
}
graph.started(true);
if (graph.tx().isOpen()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

重复 setAdmin 且未复原上下文,存在潜在越权/上下文污染

ConsumerWrapper 已负责(在部分线程)升权与复原;此处再次 setAdmin() 且无对应 reset,易造成上下文不一致。建议移除本段重复升权逻辑,统一由 ConsumerWrapper 托管。

最小变更:

-                boolean grpcThread = Thread.currentThread().getName().contains("grpc");
-                if (grpcThread) {
-                    HugeGraphAuthProxy.setAdmin();
-                }
                 graph.started(true);
                 if (graph.tx().isOpen()) {
                     graph.tx().close();
                 }

并配合上条建议,改进 ConsumerWrapper 以无条件(或按需)升权。

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java
around lines 2231-2235, remove the duplicated HugeGraphAuthProxy.setAdmin() call
(and any related unpaired elevation) so this method no longer performs privilege
elevation without a matching reset; instead ensure ConsumerWrapper is
responsible for performing elevation and restoring context reliably (modify
ConsumerWrapper to unconditionally or conditionally call
HugeGraphAuthProxy.setAdmin() before work and always reset the auth context in a
finally block) so privilege elevation is centralized and no context pollution
remains.

Comment on lines +2281 to +2297
String[] values =
graphName.split(MetaManager.META_PATH_JOIN);
if (values.length < 2) {
LOG.error("The graph name format is incorrect: {}", graphName);
continue;
}
Map<String, Object> configs =
this.metaManager.getGraphConfig(values[0],
values[1]);
String readMode = configs.getOrDefault(
CoreOptions.GRAPH_READ_MODE.name(),
CoreOptions.GRAPH_READ_MODE.defaultValue()).toString();
hugeGraph.readMode(GraphReadMode.valueOf(readMode));
// TODO: update alias graph
//this.updateAliasGraph(hugeGraph, configs);
LOG.info("Update graph space:{} graph:{}", values[0], values[1]);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

分隔符常量不一致与 readMode 解析缺乏健壮性

  • 其它处使用 DELIMITER,这里改用 MetaManager.META_PATH_JOIN,虽当前同为 "-",但不一致易埋雷。
  • 直接 valueOf(readMode) 未兜底非法/缺失值,可能抛 IllegalArgumentException。

建议:

-                    String[] values =
-                            graphName.split(MetaManager.META_PATH_JOIN);
+                    String[] values = graphName.split(DELIMITER);
                     if (values.length < 2) {
                         LOG.error("The graph name format is incorrect: {}", graphName);
                         continue;
                     }
-                    Map<String, Object> configs =
-                            this.metaManager.getGraphConfig(values[0],
-                                                            values[1]);
-                    String readMode = configs.getOrDefault(
-                            CoreOptions.GRAPH_READ_MODE.name(),
-                            CoreOptions.GRAPH_READ_MODE.defaultValue()).toString();
-                    hugeGraph.readMode(GraphReadMode.valueOf(readMode));
+                    Map<String, Object> configs =
+                            this.metaManager.getGraphConfig(values[0], values[1]);
+                    if (configs == null) {
+                        LOG.warn("Skip update for '{}' since graph config not found", graphName);
+                        continue;
+                    }
+                    Object rm = configs.get(CoreOptions.GRAPH_READ_MODE.name());
+                    GraphReadMode mode;
+                    try {
+                        mode = (rm instanceof GraphReadMode)
+                               ? (GraphReadMode) rm
+                               : GraphReadMode.valueOf(String.valueOf(rm));
+                    } catch (Exception ignore) {
+                        mode = CoreOptions.GRAPH_READ_MODE.defaultValue();
+                        LOG.warn("Invalid GRAPH_READ_MODE '{}' for '{}', fallback to {}", rm, graphName, mode);
+                    }
+                    hugeGraph.readMode(mode);
                     // TODO: update alias graph
                     //this.updateAliasGraph(hugeGraph, configs);

另:若更新读模式需要权限,请配合 ConsumerWrapper 统一升权。

Comment on lines +2302 to +2315
private <T> void graphClearHandler(T response) {
List<String> graphNames = this.metaManager
.extractGraphsFromResponse(response);
for (String graphName : graphNames) {
if (this.graphs.containsKey(graphName)) {
Graph graph = this.graphs.get(graphName);
if (graph instanceof HugeGraph) {
HugeGraph hugeGraph = (HugeGraph) graph;
((AbstractBackendStoreProvider) hugeGraph.storeProvider())
.notifyAndWaitEvent(Events.STORE_CLEAR);
}
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

强制类型转换风险:为 storeProvider 增加 instanceof 防护

直接强转 AbstractBackendStoreProvider 可能在不同实现下抛出 ClassCastException。

-                    ((AbstractBackendStoreProvider) hugeGraph.storeProvider())
-                            .notifyAndWaitEvent(Events.STORE_CLEAR);
+                    Object provider = hugeGraph.storeProvider();
+                    if (provider instanceof AbstractBackendStoreProvider) {
+                        ((AbstractBackendStoreProvider) provider)
+                                .notifyAndWaitEvent(Events.STORE_CLEAR);
+                    } else {
+                        LOG.warn("Skip STORE_CLEAR for graph {} due to incompatible provider: {}",
+                                 hugeGraph.spaceGraphName(), provider.getClass().getName());
+                    }
🤖 Prompt for AI Agents
In
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java
around lines 2302 to 2315, the code unconditionally casts
hugeGraph.storeProvider() to AbstractBackendStoreProvider which can throw
ClassCastException for other storeProvider implementations; modify the code to
first retrieve the storeProvider into a local variable, check it for null and
that it instanceof AbstractBackendStoreProvider before casting, only call
notifyAndWaitEvent when the instanceof check passes, and otherwise skip or log a
debug/warn message to avoid the class cast risk.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (3)

2302-2308: 类型转换缺少安全检查

直接将 hugeGraph.storeProvider() 强制转换为 AbstractBackendStoreProvider(2306行)存在风险:

  • storeProvider 可能返回 null
  • 可能返回其他 BackendStoreProvider 实现

建议添加防护:

                 if (graph instanceof HugeGraph) {
                     HugeGraph hugeGraph = (HugeGraph) graph;
-                    ((AbstractBackendStoreProvider) hugeGraph.storeProvider())
-                            .notifyAndWaitEvent(Events.STORE_CLEAR);
+                    Object provider = hugeGraph.storeProvider();
+                    if (provider instanceof AbstractBackendStoreProvider) {
+                        ((AbstractBackendStoreProvider) provider)
+                                .notifyAndWaitEvent(Events.STORE_CLEAR);
+                    } else {
+                        LOG.warn("Skip STORE_CLEAR for graph {} due to incompatible provider: {}",
+                                 hugeGraph.spaceGraphName(), 
+                                 provider != null ? provider.getClass().getName() : "null");
+                    }
                 }

基于之前的评审意见。


2275-2293: 分隔符不一致与缺少健壮性检查

发现两个问题:

  1. 分隔符不一致:此处使用 MetaManager.META_PATH_JOIN(2276行),而 graphAddHandler 使用 DELIMITER(2180行)。虽然当前两者值相同,但不一致性可能导致未来维护问题。
  2. 缺少健壮性检查
    • configs 可能为 null,直接调用 getOrDefault 会抛 NPE(2286行)
    • 直接使用 valueOf 解析 readMode 未捕获异常,非法值会导致 IllegalArgumentException(2289行)

建议改进:

-                    String[] values =
-                            graphName.split(MetaManager.META_PATH_JOIN);
+                    String[] values = graphName.split(DELIMITER);
                     if (values.length < 2) {
                         LOG.error("The graph name format is incorrect: {}", graphName);
                         continue;
                     }
-                    Map<String, Object> configs =
-                            this.metaManager.getGraphConfig(values[0],
-                                                            values[1]);
-                    String readMode = configs.getOrDefault(
-                            CoreOptions.GRAPH_READ_MODE.name(),
-                            CoreOptions.GRAPH_READ_MODE.defaultValue()).toString();
-                    hugeGraph.readMode(GraphReadMode.valueOf(readMode));
+                    Map<String, Object> configs =
+                            this.metaManager.getGraphConfig(values[0], values[1]);
+                    if (configs == null) {
+                        LOG.warn("Skip update for '{}' since graph config not found", graphName);
+                        continue;
+                    }
+                    Object rm = configs.get(CoreOptions.GRAPH_READ_MODE.name());
+                    GraphReadMode mode;
+                    try {
+                        mode = (rm instanceof GraphReadMode)
+                               ? (GraphReadMode) rm
+                               : GraphReadMode.valueOf(String.valueOf(rm));
+                    } catch (Exception e) {
+                        mode = CoreOptions.GRAPH_READ_MODE.defaultValue();
+                        LOG.warn("Invalid GRAPH_READ_MODE '{}' for '{}', fallback to {}", rm, graphName, mode);
+                    }
+                    hugeGraph.readMode(mode);

基于之前的评审意见。


2224-2231: 存在权限提升冗余与事务泄漏风险

存在两个问题:

  1. 权限提升冗余:ConsumerWrapper 已在外层统一处理 admin 权限提升与恢复,此处再次调用 setAdmin(2226行)造成重复,且无配对的 reset。
  2. 潜在事务泄漏:若 graph.started(true) 抛出异常,2229-2231行的事务关闭逻辑将被跳过。

建议改进:

-                boolean grpcThread = Thread.currentThread().getName().contains("grpc");
-                if (grpcThread) {
-                    HugeGraphAuthProxy.setAdmin();
-                }
-                graph.started(true);
-                if (graph.tx().isOpen()) {
-                    graph.tx().close();
-                }
+                try {
+                    graph.started(true);
+                } finally {
+                    if (graph.tx().isOpen()) {
+                        graph.tx().close();
+                    }
+                }

基于之前的评审意见。

🧹 Nitpick comments (1)
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (1)

1726-1731: 监听器注册结构合理,但存在权限提升冗余

ConsumerWrapper 已统一处理 admin 权限提升与恢复(2161-2173行),这是良好的集中化设计。但在 graphAddHandler 中仍存在重复的 setAdmin 调用(2226行),造成权限上下文管理不一致。

建议移除各 handler 内部的重复 setAdmin 逻辑,完全依赖 ConsumerWrapper 的统一管理。

基于之前的评审意见。

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2922cd3 and d8b8d0b.

⛔ Files ignored due to path filters (1)
  • hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/dist/HugeGraphServer.java is excluded by !**/dist/**
📒 Files selected for processing (2)
  • hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (5 hunks)
  • hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • hugegraph-server/hugegraph-dist/src/main/java/org/apache/hugegraph/cmd/InitStore.java
🧰 Additional context used
🧬 Code graph analysis (1)
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (4)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/store/AbstractBackendStoreProvider.java (1)
  • AbstractBackendStoreProvider (37-243)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/space/GraphSpace.java (1)
  • GraphSpace (29-515)
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeGraphAuthProxy.java (1)
  • HugeGraphAuthProxy (114-2211)
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/MetaManager.java (1)
  • MetaManager (63-1349)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build-commons (11)
  • GitHub Check: build-server (hbase, 11)
  • GitHub Check: check-license
  • GitHub Check: cluster-test
🔇 Additional comments (2)
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java (2)

2198-2217: 配置获取与 creator 解析逻辑正确

正确处理了配置不存在的情况(2209-2211行),并为 creator 提供了合理的默认值回退逻辑。


2242-2265: 图删除处理器逻辑正确

正确处理了重复删除检测(2246-2250行)和异常情况,使用 clear=false 避免重复清理数据。


@Override
public void started(boolean started) {
this.started = started;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‼️ Critical: 并发安全问题

StandardHugeGraph.started(boolean) 方法直接修改 this.started 字段,但该字段可能在多线程环境下被并发访问(例如从 gRPC 线程和主服务线程)。

建议

Suggested change
this.started = started;
@Override
public synchronized void started(boolean started) {
this.started = started;
}

或者将 started 字段声明为 volatile

private volatile boolean started;

try {
HugeGraph graph;
// TODO: add alias graph
graph = this.createGraph(parts[0], parts[1], creator, config, false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‼️ Critical: 异常处理不完整

graphAddHandler 中,如果图创建失败且 startIgnoreSingleGraphError=false,会抛出异常。但在此之前,creatingGraphs 集合没有被清理,可能导致内存泄漏和状态不一致。

建议:使用 try-finally 确保清理逻辑:

Suggested change
graph = this.createGraph(parts[0], parts[1], creator, config, false);
try {
HugeGraph graph;
graph = this.createGraph(parts[0], parts[1], creator, config, false);
LOG.info("Add graph space:{} graph:{}", parts[0], parts[1]);
boolean grpcThread = Thread.currentThread().getName().contains("grpc");
if (grpcThread) {
HugeGraphAuthProxy.setAdmin();
}
graph.started(true);
if (graph.tx().isOpen()) {
graph.tx().close();
}
} catch (HugeException e) {
this.creatingGraphs.remove(graphName); // 确保清理
if (!this.startIgnoreSingleGraphError) {
throw e;
}
LOG.error(String.format(
"Failed to create graph '%s'", graphName), e);
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignored

if (grpcThread) {
HugeGraphAuthProxy.setAdmin();
}
graph.started(true);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‼️ Critical: 潜在的权限绕过风险

代码通过检查线程名称来判断是否设置管理员权限(Thread.currentThread().getName().contains("grpc"))。这种方式非常脆弱,因为:

  1. 线程名称可以被修改
  2. 将来 gRPC 线程命名规则可能改变
  3. 其他非 gRPC 线程也可能包含 "grpc" 字符串

建议:使用更安全的方式,例如通过 Context 或显式的权限参数:

Suggested change
graph.started(true);
// 方案 1: 通过上下文传递权限信息
boolean requiresAdminPrivilege = isMetadataTriggered();
if (requiresAdminPrivilege) {
HugeGraphAuthProxy.setAdmin();
}
// 或方案 2: 添加明确的参数
private void graphAddHandler(T response, boolean autoGrantAdmin) {
// ...
if (autoGrantAdmin) {
HugeGraphAuthProxy.setAdmin();
}
}

HugeGraphAuthProxy.setAdmin();
}
graph.started(true);
if (graph.tx().isOpen()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Important: 缺少对 graph.started(true) 操作的事务保护

graphAddHandler 中调用 graph.started(true) 后直接关闭事务,但如果 started(true) 操作本身需要事务支持(例如持久化状态),可能会出现状态不一致。

建议

  1. 明确 started() 方法是否需要事务支持
  2. 如果需要,应该在事务中执行:
Suggested change
if (graph.tx().isOpen()) {
try {
if (!graph.tx().isOpen()) {
graph.tx().open();
}
graph.started(true);
graph.tx().commit();
} catch (Exception e) {
graph.tx().rollback();
throw e;
} finally {
if (graph.tx().isOpen()) {
graph.tx().close();
}
}

private <T> void graphAddHandler(T response) {
List<String> names = this.metaManager
.extractGraphsFromResponse(response);
for (String graphName : names) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Minor: 逻辑重复

在多个处理器中都有类似的 split 和验证逻辑。可以提取为通用方法以提高代码复用性和可维护性。

建议

Suggested change
for (String graphName : names) {
private String[] parseAndValidateGraphName(String graphName) {
String[] parts = graphName.split(DELIMITER);
if (parts.length < 2 || parts[0].isEmpty() || parts[1].isEmpty()) {
throw new HugeException("Invalid graph name format: %s", graphName);
}
return parts;
}
// 在各个处理器中使用
private void graphAddHandler(T response) {
List names = this.metaManager.extractGraphsFromResponse(response);
for (String graphName : names) {
try {
String[] parts = parseAndValidateGraphName(graphName);
// 处理逻辑...
} catch (HugeException e) {
LOG.error(e.getMessage());
continue;
}
}
}

graph.started(true);
if (graph.tx().isOpen()) {
graph.tx().close();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Important: 资源清理不充分

graphAddHandler 中设置了 HugeGraphAuthProxy.setAdmin(),但如果后续操作失败,没有清理这个权限设置。这可能导致权限提升泄漏。

建议:使用 try-finally 确保权限清理:

boolean grpcThread = Thread.currentThread().getName().contains("grpc");
if (grpcThread) {
    HugeGraphAuthProxy.setAdmin();
}
try {
    graph.started(true);
    if (graph.tx().isOpen()) {
        graph.tx().close();
    }
} finally {
    if (grpcThread) {
        HugeGraphAuthProxy.clearAdmin(); // 假设有这个方法
    }
}


private <T> void graphRemoveHandler(T response) {
List<String> graphNames = this.metaManager
.extractGraphsFromResponse(response);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Important: 缺少错误边界检查

在所有的事件处理器中(graphAddHandler, graphRemoveHandler, graphUpdateHandler, graphClearHandler),对 graphName.split(DELIMITER) 的结果只检查了长度,但没有检查 parts 数组元素是否为空字符串。

示例问题场景

  • ":graph1"["", "graph1"] (graphSpace 为空)
  • "space1:"["space1", ""] (graphName 为空)

建议

String[] parts = graphName.split(DELIMITER);
if (parts.length < 2 || parts[0].isEmpty() || parts[1].isEmpty()) {
    LOG.error("The graph name format is incorrect: {}", graphName);
    continue;
}

}
}

private <T> void graphAddHandler(T response) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Important: 事件处理器可能阻塞主流程

graphAddHandler 等事件处理器在监听器回调中执行图创建等耗时操作,可能阻塞元数据监听线程,影响其他事件的及时处理。

建议:考虑将实际的图操作提交到异步线程池执行:

private <T> void graphAddHandler(T response) {
    List<String> names = this.metaManager.extractGraphsFromResponse(response);
    for (String graphName : names) {
        // 快速验证
        String[] parts = graphName.split(DELIMITER);
        if (parts.length < 2) {
            LOG.error("The graph name format is incorrect: {}", graphName);
            continue;
        }
        
        // 提交到异步执行
        this.eventExecutor.submit(() -> {
            try {
                processGraphAdd(graphName, parts);
            } catch (Exception e) {
                LOG.error("Failed to process graph add event for: " + graphName, e);
            }
        });
    }
}

}
// If the current server is not registered to the DEFAULT schema,
// it will only receive graph creation events under the registered schemas.
if (!"DEFAULT".equals(this.serviceGraphSpace) &&
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Minor: 日志消息可以改进

警告日志的格式不一致,使用了 String.format 而其他地方使用占位符。建议统一使用 SLF4J 的占位符格式以提高性能(避免不必要的字符串拼接)。

建议

LOG.warn("Listen event: graph [{}] add was discarded because " +
         "it did not belong to the graph space [{}] " +
         "registered by the current server",
         graphName, this.serviceGraphSpace);

"it did not belong to the graph space [%s] " +
"registered by the current server",
graphName, this.serviceGraphSpace));
// TODO: further confirmation is required
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Minor: TODO 注释缺少具体信息

代码中有两处 TODO 注释但缺少必要的上下文信息(例如 issue 编号、为什么需要确认等)。

建议

// TODO(#issue-number): Confirm whether non-matching graph space events 
// should be completely ignored or require additional processing
continue;

对于第二个 TODO(在 graphUpdateHandler 中):

// TODO(#issue-number): Implement alias graph update logic after 
// alias graph feature is fully designed and implemented
//this.updateAliasGraph(hugeGraph, configs);

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 10.90909% with 98 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (1.7-rebase@c90f6a6). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...n/java/org/apache/hugegraph/core/GraphManager.java 6.12% 92 Missing ⚠️
.../org/apache/hugegraph/auth/HugeGraphAuthProxy.java 0.00% 3 Missing ⚠️
...n/java/org/apache/hugegraph/StandardHugeGraph.java 0.00% 2 Missing ⚠️
.../main/java/org/apache/hugegraph/cmd/InitStore.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             1.7-rebase      #74   +/-   ##
=============================================
  Coverage              ?   31.06%           
  Complexity            ?      500           
=============================================
  Files                 ?      812           
  Lines                 ?    68573           
  Branches              ?     8947           
=============================================
  Hits                  ?    21300           
  Misses                ?    44928           
  Partials              ?     2345           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@koi2000 koi2000 requested a review from imbajin October 28, 2025 15:05
@koi2000 koi2000 requested a review from imbajin October 28, 2025 15:05
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 28, 2025
@imbajin imbajin merged commit 02dc04b into hugegraph:1.7-rebase Oct 28, 2025
14 of 15 checks passed
imbajin pushed a commit that referenced this pull request Oct 29, 2025
* feat(server): implement dynamic monitoring and management of graph instance

* refactor(server): consolidate authority setting in PdMetaDriver and HugeGraphServer

* refactor(service): enhance comments for clarity and synchronize graph start method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants