Skip to content

Conversation

@mxsm
Copy link
Owner

@mxsm mxsm commented Nov 2, 2025

Which Issue(s) This PR Fixes(Closes)

Fixes #4234

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • New Features
    • Added RocketMQ Controller module with Raft-based high-availability support to the workspace
    • Broker registration, heartbeat, and lifecycle management
    • Topic creation, update, and deletion functionality
    • Configuration storage and management
    • Master election and replica synchronization support
    • RPC server for handling client requests
    • Multiple storage backend options (file, RocksDB, in-memory)

…gement, RPC handling, and configuration management
Copilot AI review requested due to automatic review settings November 2, 2025 06:41
@rocketmq-rust-robot rocketmq-rust-robot added the feature🚀 Suggest an idea for this project. label Nov 2, 2025
@rocketmq-rust-bot
Copy link
Collaborator

🔊@mxsm 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 2, 2025

Warning

Rate limit exceeded

@mxsm has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 35 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f17e5d8 and a29c678.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (29)
  • Cargo.toml (1 hunks)
  • rocketmq-controller/Cargo.toml (1 hunks)
  • rocketmq-controller/README.md (1 hunks)
  • rocketmq-controller/benches/controller_bench.rs (1 hunks)
  • rocketmq-controller/src/config.rs (1 hunks)
  • rocketmq-controller/src/error.rs (1 hunks)
  • rocketmq-controller/src/lib.rs (1 hunks)
  • rocketmq-controller/src/manager.rs (1 hunks)
  • rocketmq-controller/src/metadata/broker.rs (1 hunks)
  • rocketmq-controller/src/metadata/config.rs (1 hunks)
  • rocketmq-controller/src/metadata/mod.rs (1 hunks)
  • rocketmq-controller/src/metadata/replica.rs (1 hunks)
  • rocketmq-controller/src/metadata/topic.rs (1 hunks)
  • rocketmq-controller/src/processor/broker_processor.rs (1 hunks)
  • rocketmq-controller/src/processor/metadata_processor.rs (1 hunks)
  • rocketmq-controller/src/processor/mod.rs (1 hunks)
  • rocketmq-controller/src/processor/request.rs (1 hunks)
  • rocketmq-controller/src/processor/topic_processor.rs (1 hunks)
  • rocketmq-controller/src/raft/mod.rs (1 hunks)
  • rocketmq-controller/src/raft/network.rs (1 hunks)
  • rocketmq-controller/src/raft/node.rs (1 hunks)
  • rocketmq-controller/src/raft/storage.rs (1 hunks)
  • rocketmq-controller/src/raft/transport.rs (1 hunks)
  • rocketmq-controller/src/rpc/codec.rs (1 hunks)
  • rocketmq-controller/src/rpc/mod.rs (1 hunks)
  • rocketmq-controller/src/rpc/server.rs (1 hunks)
  • rocketmq-controller/src/storage/file_backend.rs (1 hunks)
  • rocketmq-controller/src/storage/mod.rs (1 hunks)
  • rocketmq-controller/src/storage/rocksdb_backend.rs (1 hunks)

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.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature-4234

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.

Copy link
Contributor

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 introduces a new RocketMQ Controller module that replaces Java's DLedger with a Rust-based Raft consensus implementation. The controller provides high-availability cluster management including broker registration, topic configuration, and metadata synchronization.

Key changes:

  • Complete Raft-based controller implementation using raft-rs library
  • Multiple storage backends (RocksDB, file-based, in-memory) for metadata persistence
  • Comprehensive metadata management for brokers, topics, configs, and replicas
  • RPC server with codec for broker-controller communication

Reviewed Changes

Copilot reviewed 29 out of 30 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
rocketmq-controller/Cargo.toml New package manifest with raft and storage dependencies
rocketmq-controller/src/lib.rs Main library entry point with module exports
rocketmq-controller/src/config.rs Controller configuration with Raft peer settings
rocketmq-controller/src/error.rs Error types for controller operations
rocketmq-controller/src/manager.rs Main controller manager coordinating all components
rocketmq-controller/src/raft/*.rs Raft consensus layer implementation
rocketmq-controller/src/storage/*.rs Storage backend abstractions and implementations
rocketmq-controller/src/metadata/*.rs Metadata management for brokers, topics, configs, replicas
rocketmq-controller/src/processor/*.rs Request processors for broker operations
rocketmq-controller/src/rpc/*.rs RPC server and codec for network communication
Cargo.toml Adds rocketmq-controller to workspace members
Cargo.lock Dependency lock file updates

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

cargo build -p rocketmq-controller
```

### 测试
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

Chinese characters '测试' (meaning 'test') should be replaced with English 'Test' to match the rest of the documentation.

Suggested change
### 测试
### Test

Copilot uses AI. Check for mistakes.
self.index.write().insert(key.to_string(), file_path);

// Save index periodically (every 10 operations)
if self.index.read().len() % 10 == 0 {
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The modulo check len() % 10 == 0 has a subtle bug: it triggers on multiples of 10 (10, 20, 30), but also on 0 (empty index). This means it will attempt to save an empty index unnecessarily. Consider using len() > 0 && len() % 10 == 0 or moving this logic after the insert operation.

Suggested change
if self.index.read().len() % 10 == 0 {
if self.index.read().len() > 0 && self.index.read().len() % 10 == 0 {

Copilot uses AI. Check for mistakes.
// Get RocksDB property
let backend_info = db
.property_value("rocksdb.stats")
.unwrap_or(None)
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The pattern .unwrap_or(None).unwrap_or_else(...) is redundant. Since property_value returns Result<Option<String>, Error>, you should use .ok().flatten().unwrap_or_else(|| ...) or simply handle the Result directly and then use unwrap_or_else on the Option.

Suggested change
.unwrap_or(None)
.ok()
.flatten()

Copilot uses AI. Check for mistakes.
Comment on lines +473 to +481
sync_state_set.last_update_timestamp = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs();
}

Ok(new_master)
}

Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

Multiple calls to SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs() are scattered throughout the file. This pattern should be extracted into a helper function to avoid code duplication and make error handling consistent. The .unwrap() could also panic if the system clock is set before Unix epoch.

Suggested change
sync_state_set.last_update_timestamp = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs();
}
Ok(new_master)
}
sync_state_set.last_update_timestamp = Self::current_unix_timestamp();
}
Ok(new_master)
}
/// Returns the current UNIX timestamp in seconds, or 0 if system time is before UNIX_EPOCH.
fn current_unix_timestamp() -> u64 {
match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
Ok(duration) => duration.as_secs(),
Err(e) => {
warn!("System time is before UNIX_EPOCH: {:?}", e);
0
}
}
}

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

❌ Patch coverage is 39.77415% with 1440 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.67%. Comparing base (f17e5d8) to head (a29c678).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ketmq-controller/src/processor/broker_processor.rs 0.00% 169 Missing ⚠️
rocketmq-controller/src/raft/transport.rs 23.24% 142 Missing ⚠️
rocketmq-controller/src/raft/mod.rs 2.25% 130 Missing ⚠️
...cketmq-controller/src/processor/topic_processor.rs 0.00% 127 Missing ⚠️
rocketmq-controller/src/rpc/server.rs 5.45% 104 Missing ⚠️
rocketmq-controller/src/metadata/replica.rs 69.72% 99 Missing ⚠️
rocketmq-controller/src/raft/node.rs 0.00% 98 Missing ⚠️
rocketmq-controller/src/manager.rs 3.22% 90 Missing ⚠️
rocketmq-controller/src/metadata/topic.rs 33.89% 78 Missing ⚠️
rocketmq-controller/src/metadata/broker.rs 40.00% 63 Missing ⚠️
... and 11 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4235      +/-   ##
==========================================
+ Coverage   27.32%   27.67%   +0.34%     
==========================================
  Files         586      609      +23     
  Lines       83771    86162    +2391     
==========================================
+ Hits        22894    23845     +951     
- Misses      60877    62317    +1440     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…gement, RPC handling, and configuration management
@rocketmq-rust-bot
Copy link
Collaborator

🔊@mxsm 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

…gement, RPC handling, and configuration management
@rocketmq-rust-bot
Copy link
Collaborator

🔊@mxsm 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

@rocketmq-rust-bot
Copy link
Collaborator

🔊@mxsm 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

@rocketmq-rust-bot
Copy link
Collaborator

🔊@mxsm 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

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

LGTM

@rocketmq-rust-bot rocketmq-rust-bot merged commit 3be4fc7 into main Nov 2, 2025
17 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI review first Ai review pr first approved PR has approved auto merge feature🚀 Suggest an idea for this project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature🚀] Add RocketMQ Controller module; implement metadata management, RPC handling, and configuration management

4 participants