Skip to content

[ISSUES #6352, #6349 and #6325]#6353

Merged
mxsm merged 1 commit intomxsm:mainfrom
oopscompiled:enhancement/remove-redundant-code
Feb 17, 2026
Merged

[ISSUES #6352, #6349 and #6325]#6353
mxsm merged 1 commit intomxsm:mainfrom
oopscompiled:enhancement/remove-redundant-code

Conversation

@oopscompiled
Copy link
Contributor

@oopscompiled oopscompiled commented Feb 16, 2026

Which Issue(s) This PR Fixes(Closes)

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

Release Notes

Refactor

  • Enhanced error handling for timer message store operations
  • Streamlined query message processor initialization by removing redundant dependencies
  • Consolidated service task trait interface with unified context handling and simplified method contracts

Copilot AI review requested due to automatic review settings February 16, 2026 17:51
@rocketmq-rust-bot rocketmq-rust-bot self-requested a review February 16, 2026 17:51
@rocketmq-rust-bot
Copy link
Collaborator

🔊@oopscompiled 🚀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 Feb 16, 2026

Walkthrough

This PR consolidates and simplifies three components: error handling in broker runtime changes from unsafe unwrap to explicit panic, query message processor constructor is simplified by removing unused parameters, and the service task trait hierarchy is consolidated by merging ServiceTaskInner into ServiceTask with updated method signatures.

Changes

Cohort / File(s) Summary
Broker Runtime Error Handling
rocketmq-broker/src/broker_runtime.rs
Changed timer_message_store_unchecked method to return unimplemented!() instead of unsafe unwrap, altering error handling from potentially undefined behavior to explicit panic.
Query Message Processor Simplification
rocketmq-broker/src/processor/query_message_processor.rs
Removed message_store_config and message_store parameters from constructor; now accepts only broker_runtime_inner.
Service Task Trait Consolidation
rocketmq/src/task/service_task.rs
Removed ServiceTaskInner trait and merged methods into unified ServiceTask trait; updated run method signature from async fn(&ServiceTaskContext) to fn(&ServiceContext) -> impl Future; added Sync + Send bounds and default on_wait_end method.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A hop, skip, and refactor done,
Unsafe paths replaced—no more,
Traits consolidated, simpler run,
ServiceTask now just one door,
Code cleaned up, the work complete! 🌟

🚥 Pre-merge checks | ✅ 1 | ❌ 5

❌ Failed checks (2 warnings, 3 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (23 files):

⚔️ CHANGELOG.md (content)
⚔️ rocketmq-broker/src/broker_runtime.rs (content)
⚔️ rocketmq-broker/src/out_api/broker_outer_api.rs (content)
⚔️ rocketmq-broker/src/processor/admin_broker_processor.rs (content)
⚔️ rocketmq-broker/src/processor/admin_broker_processor/offset_request_handler.rs (content)
⚔️ rocketmq-broker/src/processor/end_transaction_processor.rs (content)
⚔️ rocketmq-broker/src/processor/query_message_processor.rs (content)
⚔️ rocketmq-client/src/admin/default_mq_admin_ext_impl.rs (content)
⚔️ rocketmq-client/src/implementation/mq_client_api_impl.rs (content)
⚔️ rocketmq-client/src/producer/producer_impl/default_mq_producer_impl.rs (content)
⚔️ rocketmq-example/Cargo.toml (content)
⚔️ rocketmq-remoting/src/clients.rs (content)
⚔️ rocketmq-remoting/src/clients/rocketmq_tokio_client.rs (content)
⚔️ rocketmq-store/src/queue.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/admin/default_mq_admin_ext.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/auth_commands.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/broker_commands.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/consumer_commands.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/controller_commands.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/namesrv_commands.rs (content)
⚔️ rocketmq-tools/rocketmq-admin/rocketmq-admin-core/src/commands/topic_commands.rs (content)
⚔️ rocketmq/src/task/service_task.rs (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
Title check ❓ Inconclusive The pull request title only lists issue numbers without describing the actual changes made, making it vague and uninformative about the specific work performed. Replace the title with a descriptive summary of the main changes, such as 'Simplify ServiceTask trait and query processor initialization' to clearly communicate the primary modifications.
Linked Issues check ❓ Inconclusive The PR addresses only issue #6352 with removal of redundant parameters from query_message_processor constructor, but issue details are incomplete and issues #6349 and #6325 have no linked context to validate against. Provide complete issue descriptions or documentation for all three linked issues (#6352, #6349, #6325) to validate that all coding requirements have been met.
Out of Scope Changes check ❓ Inconclusive Changes include refactoring ServiceTask trait (#6349/#6325 likely) and broker_runtime.rs modifications beyond the stated #6352 scope of removing query_message_processor redundant code. Clarify scope boundaries by ensuring all three linked issues explicitly cover ServiceTask trait refactoring, broker_runtime changes, and query_message_processor modifications.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch enhancement/remove-redundant-code
  • Post resolved changes as copyable diffs in a comment

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 pull request addresses three enhancement issues aimed at code cleanup: removing commented-out dead code from service_task.rs and query_message_processor.rs, and replacing an unsafe unwrap_unchecked() call with unimplemented!() in broker_runtime.rs.

Changes:

  • Removed commented-out ServiceTaskInner trait definition from service_task.rs
  • Cleaned up commented parameters and fields in QueryMessageProcessor constructor
  • Replaced unsafe unwrap_unchecked() with unimplemented!() for timer_message_store_unchecked method

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
rocketmq/src/task/service_task.rs Removes unused commented-out trait definition
rocketmq-broker/src/processor/query_message_processor.rs Cleans up commented parameters in constructor
rocketmq-broker/src/broker_runtime.rs Replaces unsafe unwrap with unimplemented macro

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

#[inline]
pub fn timer_message_store_unchecked(&self) -> &TimerMessageStore {
unsafe { self.timer_message_store.as_ref().unwrap_unchecked() }
unimplemented!("timer_message_store_unchecked is not implemented yet")
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

This change will cause a runtime panic when timer messages are processed. The method timer_message_store_unchecked() is actively called in rocketmq-broker/src/util/hook_utils.rs:157 within the handle_schedule_message function, which is used by ScheduleMessageHook for processing messages with timer properties. When a timer message is handled (and timer_wheel_enable is true), this will panic instead of returning the timer message store. The original unsafe unwrap_unchecked() should be replaced with a safe alternative like unwrap() or proper error handling, not unimplemented!().

Suggested change
unimplemented!("timer_message_store_unchecked is not implemented yet")
self.timer_message_store.as_ref().unwrap()

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@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: 1

🤖 Fix all issues with AI agents
In `@rocketmq-broker/src/broker_runtime.rs`:
- Around line 1757-1759: timer_message_store_unchecked currently calls
unimplemented!() which will panic when handle_schedule_message invokes it (when
timer_wheel_enable is true); replace the panic with a real implementation or a
safe API: either return a reference to the existing TimerMessageStore instance
(implement the body of timer_message_store_unchecked to retrieve and return the
stored TimerMessageStore), or change the public API to return
Result<&TimerMessageStore, Error> and propagate errors up from
handle_schedule_message, or gate the method behind a feature flag so callers
cannot call it when timer wheel is disabled; locate
timer_message_store_unchecked and the TimerMessageStore storage/field in the
broker_runtime impl and implement safe retrieval or alter its signature and
update handle_schedule_message accordingly.

Comment on lines 1757 to 1759
pub fn timer_message_store_unchecked(&self) -> &TimerMessageStore {
unsafe { self.timer_message_store.as_ref().unwrap_unchecked() }
unimplemented!("timer_message_store_unchecked is not implemented yet")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for any callers of timer_message_store_unchecked across all Rust files
rg -n 'timer_message_store_unchecked' --type rust

Repository: mxsm/rocketmq-rust

Length of output: 415


🏁 Script executed:

#!/bin/bash
# Get context around the caller at hook_utils.rs:157
sed -n '145,170p' rocketmq-broker/src/util/hook_utils.rs | cat -n

Repository: mxsm/rocketmq-rust

Length of output: 1568


Do not use unimplemented!() — this method has a caller that will panic at runtime.

timer_message_store_unchecked() is called from rocketmq-broker/src/util/hook_utils.rs:157 in the handle_schedule_message() function, which is the core message scheduling handler. When timer_wheel_enable is true, any incoming timer message will trigger the unimplemented!() panic.

Either implement the method properly or remove the public API. If the feature is not ready, consider returning an error or wrapping the method with a feature flag.

🤖 Prompt for AI Agents
In `@rocketmq-broker/src/broker_runtime.rs` around lines 1757 - 1759,
timer_message_store_unchecked currently calls unimplemented!() which will panic
when handle_schedule_message invokes it (when timer_wheel_enable is true);
replace the panic with a real implementation or a safe API: either return a
reference to the existing TimerMessageStore instance (implement the body of
timer_message_store_unchecked to retrieve and return the stored
TimerMessageStore), or change the public API to return
Result<&TimerMessageStore, Error> and propagate errors up from
handle_schedule_message, or gate the method behind a feature flag so callers
cannot call it when timer wheel is disabled; locate
timer_message_store_unchecked and the TimerMessageStore storage/field in the
broker_runtime impl and implement safe retrieval or alter its signature and
update handle_schedule_message accordingly.

@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.46%. Comparing base (8b35652) to head (c7596b2).
⚠️ Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
...mq-broker/src/processor/query_message_processor.rs 0.00% 2 Missing ⚠️
rocketmq-broker/src/broker_runtime.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6353      +/-   ##
==========================================
- Coverage   42.62%   42.46%   -0.17%     
==========================================
  Files         912      919       +7     
  Lines      128056   129254    +1198     
==========================================
+ Hits        54590    54893     +303     
- Misses      73466    74361     +895     

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

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 - All CI checks passed ✅

@mxsm mxsm merged commit c7c695b into mxsm:main Feb 17, 2026
15 of 27 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 Feb 17, 2026
@oopscompiled oopscompiled deleted the enhancement/remove-redundant-code branch February 17, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement✨] Remove useless code from query_message_processor.rs

5 participants