-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[ISSUE #2457]💫Optimize AckMessageProcessor handle ack message🥅 #2458
Conversation
WalkthroughThe pull request focuses on optimizing the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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🔥! 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.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
rocketmq-broker/src/processor/ack_message_processor.rs
(7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: build (windows-latest, nightly)
- GitHub Check: build (windows-latest, stable)
- GitHub Check: build (macos-latest, nightly)
- GitHub Check: build (macos-latest, stable)
- GitHub Check: build (ubuntu-latest, nightly)
- GitHub Check: test
- GitHub Check: build (ubuntu-latest, stable)
- GitHub Check: build
- GitHub Check: auto-approve
🔇 Additional comments (3)
rocketmq-broker/src/processor/ack_message_processor.rs (3)
49-49
: LGTM! Improved logging with appropriate severity levels.The addition of structured logging with appropriate severity levels (error for critical issues, warn for recoverable issues) enhances observability and debugging capabilities.
Also applies to: 151-156, 179-180, 199-200
456-456
: LGTM! Consistent host assignment.Correctly assigns the store host to both born_host and store_host fields.
471-481
: LGTM! Improved status checking with better error logging.The changes improve the code by:
- Using the more concise
matches!
macro- Handling additional status codes as success cases
- Adding error logging for failure cases
if let Ok(bytes) = batch_ack.encode() { | ||
inner.set_body(Bytes::from(bytes)); | ||
} else { | ||
warn!("encode batch ack msg error"); | ||
} |
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.
🛠️ Refactor suggestion
Consider propagating encoding errors.
While the code now handles encoding errors with warning logs, it continues execution which could lead to undefined behavior since the message body won't be set correctly.
Consider propagating the errors:
- if let Ok(bytes) = batch_ack.encode() {
- inner.set_body(Bytes::from(bytes));
- } else {
- warn!("encode batch ack msg error");
- }
+ let bytes = batch_ack.encode().map_err(|e| {
+ warn!("encode batch ack msg error: {}", e);
+ BrokerCommonError("Failed to encode batch ack message".into())
+ })?;
+ inner.set_body(Bytes::from(bytes));
Similar change should be applied to the single ack message encoding block.
Also applies to: 439-443
let message_store_inner = self.broker_runtime_inner.message_store().as_ref().unwrap(); | ||
let min_offset = message_store_inner | ||
.get_min_offset_in_queue(&request_header.topic, request_header.queue_id); | ||
let max_offset = self | ||
.broker_runtime_inner | ||
.message_store() | ||
.as_ref() | ||
.unwrap() | ||
let max_offset = message_store_inner |
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.
🛠️ Refactor suggestion
Consider handling potential None case for message store.
While storing the message store reference reduces redundant unwraps, using unwrap()
could still cause a panic if the message store is None.
Consider using proper error handling:
- let message_store_inner = self.broker_runtime_inner.message_store().as_ref().unwrap();
- let min_offset = message_store_inner
+ let message_store_inner = self.broker_runtime_inner.message_store().as_ref()
+ .ok_or_else(|| BrokerCommonError("Message store not initialized".into()))?;
+ let min_offset = message_store_inner
.get_min_offset_in_queue(&request_header.topic, request_header.queue_id);
- let max_offset = message_store_inner
+ let max_offset = message_store_inner
.get_max_offset_in_queue(&request_header.topic, request_header.queue_id);
Committable suggestion skipped: line range outside the PR's diff.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2458 +/- ##
==========================================
- Coverage 28.63% 28.62% -0.01%
==========================================
Files 510 510
Lines 73501 73518 +17
==========================================
Hits 21044 21044
- Misses 52457 52474 +17 ☔ View full report in Codecov by Sentry. |
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 #2457
Brief Description
How Did You Test This Change?
Summary by CodeRabbit