Skip to content

[ISSUE #3871]🚀Implement sync_all method in SlaveSynchronize for comprehensive synchronization - #3872

Merged
rocketmq-rust-bot merged 1 commit into
mainfrom
feature-3871
Aug 28, 2025
Merged

rocketmq-rust-bot merged 1 commit into
mainfrom
feature-3871

Conversation

@mxsm

@mxsm mxsm commented Aug 28, 2025 •

Copy link
Copy Markdown
Owner

Which Issue(s) This PR Fixes(Closes)

Fixes #3871

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • Refactor
    • Centralized the slave synchronization workflow to invoke multiple sync steps, including a configuration-gated timer metrics step. Implementation currently logs placeholders. Maintains existing functionality while improving structure and observability.
  • Chores
    • Enhanced error logging for unimplemented synchronization tasks to aid diagnostics.
    • No changes to the public API; behavior remains the same for end users.

@coderabbitai

coderabbitai Bot commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds orchestration logic to sync_all in rocketmq-broker/src/slave/slave_synchronize.rs to invoke several new private async sync helpers and a conditional timer metrics sync. Helper methods are stubs that log “not implemented”. sync_timer_check_point remains unimplemented. Public API surface is unchanged.

Changes

Cohort / File(s) Summary
Slave synchronization orchestration
rocketmq-broker/src/slave/slave_synchronize.rs
Implemented sync_all to call internal tasks: sync_topic_config, sync_consumer_offset, sync_delay_offset, sync_subscription_group_config, sync_message_request_mode, and conditionally sync_timer_metrics based on MessageStore config. Added these private async helper stubs (log errors). sync_timer_check_point unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor BrokerSlave as Slave Node
  participant SlaveSync as SlaveSynchronize
  participant StoreCfg as MessageStore.Config
  note over BrokerSlave,SlaveSync: High-level orchestration of sync_all

  BrokerSlave->>SlaveSync: sync_all()
  activate SlaveSync
  SlaveSync->>SlaveSync: sync_topic_config()
  SlaveSync->>SlaveSync: sync_consumer_offset()
  SlaveSync->>SlaveSync: sync_delay_offset()
  SlaveSync->>SlaveSync: sync_subscription_group_config()
  SlaveSync->>SlaveSync: sync_message_request_mode()
  SlaveSync->>StoreCfg: read timer_wheel_enable
  alt timer_wheel_enable == true
    SlaveSync->>SlaveSync: sync_timer_metrics()
  else
    note over SlaveSync: Skip timer metrics sync
  end
  deactivate SlaveSync
  SlaveSync-->>BrokerSlave: return
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Implement sync_all method in SlaveSynchronize for comprehensive synchronization (#3871) ✅

Assessment against linked issues: Out-of-scope changes

None found.

Poem

I thump my paw: syncs begin to roll,
Topics, offsets—down the rabbit hole!
Subscriptions checked, delays in queue,
Request modes noted, metrics too (if due).
Though helpers squeak, “not done yet,”
The sync parade is firmly set. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature-3871

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rocketmq-rust-bot

Copy link
Copy Markdown
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-robot rocketmq-rust-robot added the feature🚀 Suggest an idea for this project. label Aug 28, 2025
@codecov

codecov Bot commented Aug 28, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.00%. Comparing base (dd2cb49) to head (32beab9).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
rocketmq-broker/src/slave/slave_synchronize.rs 0.00% 30 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3872      +/-   ##
==========================================
- Coverage   27.01%   27.00%   -0.01%     
==========================================
  Files         556      556              
  Lines       78923    78952      +29     
==========================================
  Hits        21318    21318              
- Misses      57605    57634      +29     

☔ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dd2cb49 and 32beab9.

📒 Files selected for processing (1)
  • rocketmq-broker/src/slave/slave_synchronize.rs (1 hunks)
⏰ 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). (9)
  • GitHub Check: build (windows-latest, stable)
  • GitHub Check: build (windows-latest, nightly)
  • GitHub Check: build (ubuntu-latest, stable)
  • GitHub Check: build (ubuntu-latest, nightly)
  • GitHub Check: build (macos-latest, stable)
  • GitHub Check: build (macos-latest, nightly)
  • GitHub Check: auto-approve
  • GitHub Check: build
  • GitHub Check: test

Comment on lines +60 to 73
self.sync_topic_config().await;
self.sync_consumer_offset().await;
self.sync_delay_offset().await;
self.sync_subscription_group_config().await;
self.sync_message_request_mode().await;
if self
.broker_runtime_inner
.message_store_unchecked()
.get_message_store_config()
.timer_wheel_enable
{
self.sync_timer_metrics().await;
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard when master is unset; add start/end logs; include timer checkpoint under the same gate

Avoid doing a “comprehensive sync” without a master address, and log lifecycle. Also include sync_timer_check_point() alongside metrics when the timer wheel is enabled.

Apply this diff within the shown range:

-        self.sync_topic_config().await;
-        self.sync_consumer_offset().await;
-        self.sync_delay_offset().await;
-        self.sync_subscription_group_config().await;
-        self.sync_message_request_mode().await;
-        if self
-            .broker_runtime_inner
-            .message_store_unchecked()
-            .get_message_store_config()
-            .timer_wheel_enable
-        {
-            self.sync_timer_metrics().await;
-        }
+        info!("Start sync_all");
+        if self.master_addr.is_none() {
+            warn!("Skip sync_all: master_addr is not set");
+            return;
+        }
+        self.sync_topic_config().await;
+        self.sync_consumer_offset().await;
+        self.sync_delay_offset().await;
+        self.sync_subscription_group_config().await;
+        self.sync_message_request_mode().await;
+        if self
+            .broker_runtime_inner
+            .message_store_unchecked()
+            .get_message_store_config()
+            .timer_wheel_enable
+        {
+            self.sync_timer_metrics().await;
+            self.sync_timer_check_point().await;
+        }
+        info!("Completed sync_all");

Add this import outside the range:

use tracing::warn;

Optional: run the independent syncs concurrently to reduce wall time:

-        self.sync_topic_config().await;
-        self.sync_consumer_offset().await;
-        self.sync_delay_offset().await;
-        self.sync_subscription_group_config().await;
-        self.sync_message_request_mode().await;
+        tokio::join!(
+            self.sync_topic_config(),
+            self.sync_consumer_offset(),
+            self.sync_delay_offset(),
+            self.sync_subscription_group_config(),
+            self.sync_message_request_mode(),
+        );
@@
-            self.sync_timer_metrics().await;
-            self.sync_timer_check_point().await;
+            tokio::join!(self.sync_timer_metrics(), self.sync_timer_check_point());

Comment on lines +79 to +101
async fn sync_topic_config(&self) {
error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
}

async fn sync_consumer_offset(&self) {
error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
}

async fn sync_delay_offset(&self) {
error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
}

async fn sync_subscription_group_config(&self) {
error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
}

async fn sync_message_request_mode(&self) {
error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
}

async fn sync_timer_metrics(&self) {
error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix copy/paste in log messages and lower severity from error to warn

All stubs log “syncTopicConfig” at error level, which is misleading and noisy. Use the correct function name and a warning level.

Apply this diff:

 async fn sync_topic_config(&self) {
-        error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
+        warn!("SlaveSynchronize::sync_topic_config is not implemented yet");
 }
 
 async fn sync_consumer_offset(&self) {
-        error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
+        warn!("SlaveSynchronize::sync_consumer_offset is not implemented yet");
 }
 
 async fn sync_delay_offset(&self) {
-        error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
+        warn!("SlaveSynchronize::sync_delay_offset is not implemented yet");
 }
 
 async fn sync_subscription_group_config(&self) {
-        error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
+        warn!("SlaveSynchronize::sync_subscription_group_config is not implemented yet");
 }
 
 async fn sync_message_request_mode(&self) {
-        error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
+        warn!("SlaveSynchronize::sync_message_request_mode is not implemented yet");
 }
 
 async fn sync_timer_metrics(&self) {
-        error!("SlaveSynchronize::syncTopicConfig is not implemented yet");
+        warn!("SlaveSynchronize::sync_timer_metrics is not implemented yet");
 }

Add this import (outside range) if not present:

use tracing::warn;
🤖 Prompt for AI Agents
In rocketmq-broker/src/slave/slave_synchronize.rs around lines 79 to 101, each
async stub currently logs the wrong message ("syncTopicConfig") at error level;
update each function to call warn! with the correct function-specific message
(e.g., "SlaveSynchronize::sync_topic_config is not implemented yet",
"SlaveSynchronize::sync_consumer_offset is not implemented yet", etc.), and add
the import use tracing::warn; near the other imports if it is not already
present.

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

Copy link
Copy Markdown
Collaborator

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 6de0891 into main Aug 28, 2025
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Aug 28, 2025
@mxsm
mxsm deleted the feature-3871 branch September 1, 2025 15:54
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🚀] Implement sync_all method in SlaveSynchronize for comprehensive synchronization

3 participants