-
Notifications
You must be signed in to change notification settings - Fork 174
[ISSUE #4031]🚀Add reject_request method to handle slave broker read conditions in PullMessageProcessor #4032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…onditions in PullMessageProcessor
WalkthroughAdds a reject_request method to PullMessageProcessor to pre-check and reject pull requests when the broker is Slave and slave_read_enable is false, returning a SlaveNotAvailable response. Includes necessary imports and integrates the method into the RequestProcessor impl. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant P as PullMessageProcessor
participant B as Broker Config/Role
C->>P: PullMessage Request
rect rgba(220,240,255,0.5)
note right of P: New pre-check
P->>B: Check role and slave_read_enable
alt Broker is Slave AND slave_read_enable=false
P-->>C: RemotingResponse: SlaveNotAvailable (reject)
else Proceed
P->>P: Continue normal pull handling
P-->>C: Pull result/other response
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks (4 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Poem
✨ Finishing touches
🧪 Generate unit tests
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. Comment |
🔊@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💥. |
There was a problem hiding this 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 adds a reject_request
method to the PullMessageProcessor
to handle read conditions for slave brokers, specifically rejecting read requests when slave reading is disabled on a slave broker.
- Adds imports for
BrokerRole
andRejectRequestResponse
types - Implements
reject_request
method that returns a rejection response when slave read is disabled on slave brokers
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
true, | ||
Some(RemotingCommand::create_response_command_with_code_remark( | ||
ResponseCode::SlaveNotAvailable, | ||
"the slave broker not allow to read", |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar error in the error message. Should be 'the slave broker does not allow reading' or 'the slave broker is not allowed to read'.
"the slave broker not allow to read", | |
"the slave broker does not allow reading", |
Copilot uses AI. Check for mistakes.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4032 +/- ##
==========================================
- Coverage 26.52% 26.52% -0.01%
==========================================
Files 565 565
Lines 80766 80779 +13
==========================================
Hits 21426 21426
- Misses 59340 59353 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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
🧹 Nitpick comments (2)
rocketmq-broker/src/processor/pull_message_processor.rs (2)
115-128
: Early reject on slave read disabled is correct; refine the remark for clarity.Logic aligns with the PR objective. Improve the user-facing remark (grammar + context) and include broker identity for diagnostics.
Apply:
fn reject_request(&self, _code: i32) -> RejectRequestResponse { if !self.broker_runtime_inner.broker_config().slave_read_enable && self.broker_runtime_inner.message_store_config().broker_role == BrokerRole::Slave { return ( true, Some(RemotingCommand::create_response_command_with_code_remark( ResponseCode::SlaveNotAvailable, - "the slave broker not allow to read", + format!( + "The broker[{}] is in slave mode; reads are disabled (slaveReadEnable=false).", + self.broker_runtime_inner.broker_config().broker_ip1 + ), )), ); } (false, None) }I can also add a focused unit test to cover both branches (reject/allow). Want me to draft it?
103-111
: Nit: incorrect processor name in unsupported-code remark.Message says “ClientManageProcessor” in PullMessageProcessor. Update for accuracy.
- "ClientManageProcessor request code {} not supported", + "PullMessageProcessor request code {} not supported",
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
rocketmq-broker/src/processor/pull_message_processor.rs
(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
rocketmq-broker/src/processor/pull_message_processor.rs (4)
rocketmq-broker/src/processor/send_message_processor.rs (1)
reject_request
(133-167)rocketmq-broker/src/processor.rs (2)
reject_request
(142-160)reject_request
(235-251)rocketmq-remoting/src/runtime/processor.rs (1)
reject_request
(35-37)rocketmq-remoting/src/protocol/remoting_command.rs (1)
create_response_command_with_code_remark
(196-204)
⏰ 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 (macos-latest, nightly)
- GitHub Check: build (windows-latest, nightly)
- GitHub Check: build (ubuntu-latest, nightly)
- GitHub Check: build (macos-latest, stable)
- GitHub Check: build (windows-latest, stable)
- GitHub Check: build (ubuntu-latest, stable)
- GitHub Check: test
- GitHub Check: build
- GitHub Check: auto-approve
🔇 Additional comments (2)
rocketmq-broker/src/processor/pull_message_processor.rs (2)
21-21
: Import of BrokerRole is appropriate.Required for the role check in reject_request; no issues.
46-46
: Import of RejectRequestResponse is correct.Matches the trait’s expected return type; no issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Which Issue(s) This PR Fixes(Closes)
Fixes #4031
Brief Description
How Did You Test This Change?
Summary by CodeRabbit