-
Notifications
You must be signed in to change notification settings - Fork 111
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
[ISSUE #1281]⚡️Optimize name server DefaultRequestProcessor#delete_topic_in_name_srv #1282
Conversation
…pic_in_name_srv
WalkthroughThe pull request modifies the Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning Rate limit exceeded@mxsm has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 18 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
🔊@mxsm 🚀Thanks for your contribution 🎉. CodeRabbit(AI) will review your code first 🔥 |
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
🧹 Outside diff range and nitpick comments (2)
rocketmq-namesrv/src/processor/default_request_processor.rs (1)
352-353
: LGTM! The optimization simplifies parameter passing.The change improves code clarity by directly passing the topic and cluster name from the request header to the route info manager.
Consider adding error handling and validation:
fn delete_topic_in_name_srv(&mut self, request: RemotingCommand) -> RemotingCommand { let request_header = request .decode_command_custom_header::<DeleteTopicFromNamesrvRequestHeader>() .expect("decode DeleteTopicFromNamesrvRequestHeader failed"); + // Validate input parameters + if request_header.topic.is_empty() { + return RemotingCommand::create_response_command_with_code(RemotingSysResponseCode::SystemError) + .set_remark(CheetahString::from_static_str("topic cannot be empty")); + } + + // Delete topic and handle the result + match self.route_info_manager.delete_topic(request_header.topic, request_header.cluster_name) { + Ok(_) => RemotingCommand::create_response_command(), + Err(e) => RemotingCommand::create_response_command_with_code(RemotingSysResponseCode::SystemError) + .set_remark(format!("Failed to delete topic: {}", e)), + } - self.route_info_manager - .delete_topic(request_header.topic, request_header.cluster_name); - RemotingCommand::create_response_command() }rocketmq-namesrv/src/route/route_info_manager.rs (1)
760-762
: Consider adding error handling for topic removalThe topic removal operation could benefit from returning a Result to indicate success/failure of the operation.
- self.topic_queue_table.mut_from_ref().remove(&topic); + let removed = self.topic_queue_table.mut_from_ref().remove(&topic); + if removed.is_none() { + debug!("Topic {} not found for removal", topic); + }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
rocketmq-namesrv/src/processor/default_request_processor.rs
(1 hunks)rocketmq-namesrv/src/route/route_info_manager.rs
(1 hunks)
🔇 Additional comments (2)
rocketmq-namesrv/src/route/route_info_manager.rs (2)
739-740
: LGTM: Type safety improvement with CheetahString
The change from impl Into<String>
to CheetahString
improves type safety and reduces runtime conversions.
742-749
: LGTM: Improved concurrency and null safety
Good improvements:
- Proper write lock acquisition for thread safety
- Using
is_some_and
for more idiomatic null checking - Safe mutable access to the topic queue table
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1282 +/- ##
=======================================
Coverage 18.98% 18.98%
=======================================
Files 428 428
Lines 53854 53853 -1
=======================================
Hits 10224 10224
+ Misses 43630 43629 -1 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Which Issue(s) This PR Fixes(Closes)
Fixes #1281
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
RouteInfoManager
.