-
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 #2073]💫Implement PopReviveService#reviveRetry🚀 #2074
Conversation
WalkthroughThe pull request introduces significant enhancements to 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💥. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2074 +/- ##
==========================================
- Coverage 28.43% 28.39% -0.05%
==========================================
Files 489 489
Lines 69326 69431 +105
==========================================
Hits 19713 19713
- Misses 49613 49718 +105 ☔ 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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
rocketmq-broker/src/processor/processor_service/pop_revive_service.rs (2)
43-54
: Add documentation for newly introduced fields.
Thebroker_config
,topic_config_manager
,consumer_offset_manager
, andescape_bridge
fields significantly impact how thePopReviveService
interacts with broker-level configurations and offset management. Consider adding doc comments to clarify their purpose.
83-145
: Avoid overwriting or duplicating tags/properties.
Insiderevive_retry
, lines 107–110 set the tags from the original message if present; otherwise, they set an empty property map. Then line 118 callsMessageAccessor::set_properties
again, cloning the entire property set from the originalmessage_ext
. This sequence may override the earlier assignment if the message had no tags or if other properties conflict.--- a/pop_revive_service.rs +++ b/pop_revive_service.rs @@ -107,9 +107,6 @@ if let Some(tags) = message_ext.get_tags() { msg_inner.set_tags(tags); } else { - MessageAccessor::set_properties(&mut msg_inner, HashMap::new()); } // ... MessageAccessor::set_properties(&mut msg_inner, message_ext.properties().clone());
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
rocketmq-broker/src/processor/processor_service/pop_revive_service.rs
(2 hunks)
🔇 Additional comments (3)
rocketmq-broker/src/processor/processor_service/pop_revive_service.rs (3)
147-164
: Ensure new topics are consistently visible across the system.
When callingadd_retry_topic_if_not_exist
, a new topic configuration is inserted. Please verify that other broker components (e.g., routing and metadata) pick up newly added topics so messages aren't dropped.✅ Verification successful
Let me gather more information about how topic configurations are handled in the broker runtime.
Topic registration is properly handled through the broker runtime system
The verification shows that topic configurations are properly propagated across the system:
- When a new topic is created via
update_topic_config
, theTopicConfigManager
automatically callsregister_broker_data
for new topics- The registration process:
- Spawns an async task to handle the registration
- Uses
register_single_topic_all
to propagate the topic to all name servers whenenable_single_topic_register
is enabled- Updates permissions and broker metadata as needed
The code follows a robust pattern for topic registration and visibility across the broker system, ensuring new topics are properly tracked and accessible.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if add_retry_topic_if_not_exist is followed by any step or method that notifies the broker's topic routing or metadata systems. rg -A 5 'update_topic_config' rocketmq-brokerLength of output: 4172
Script:
#!/bin/bash # Check broker runtime handling of topic configurations ast-grep --pattern 'fn broker_runtime_inner' # Check if there are any topic registration or notification mechanisms rg -B 2 -A 5 'register.*topic|notify.*topic' rocketmq-brokerLength of output: 11800
22-42
: Consider grouping and re-checking imports for potential duplication or unnecessary modules.
While the introduced imports (for exampleBrokerConfig
,TopicConfig
, and more) seem necessary for the new functionality, please verify that every imported item is used to avoid cluttering the namespace.✅ Verification successful
Let me verify the usage of these imports in the actual code.
All imports are actively used in the code
Based on the search results, every imported module and type is being used within the file:
BrokerConfig
is used in struct fields and parametersTopicConfig
is used for creating and configuring topicsKeyBuilder
is used for building pop retry topicsmessage_decoder
is used for converting message properties to stringsMessageExt
andMessageExtBrokerInner
are used for message handlingMessageConst
is used for property constantsMessageTrait
is imported as a trait requirementmix_all
is used for prefix checkingPopAckConstants
is used for queue configurationTopicFilterType
is used for topic filter configurationMessageAccessor
is used for property manipulation🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search the file to confirm usage of each import within lines 22 to 42. rg -A 5 'use rocketmq_common::common::(broker|config|key_builder|message|mix_all|pop_ack_constants|TopicFilterType|MessageAccessor)' rocketmq-broker/src/processor/processor_service/pop_revive_service.rsLength of output: 1098
Script:
#!/bin/bash # Search for usage of each imported type/module in the file echo "=== Searching for BrokerConfig usage ===" rg "BrokerConfig" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for TopicConfig usage ===" rg "TopicConfig" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for KeyBuilder usage ===" rg "KeyBuilder" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for message_decoder usage ===" rg "message_decoder" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for MessageExt usage ===" rg "MessageExt" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for MessageExtBrokerInner usage ===" rg "MessageExtBrokerInner" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for MessageConst usage ===" rg "MessageConst" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for MessageTrait usage ===" rg "MessageTrait" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for mix_all usage ===" rg "mix_all" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for PopAckConstants usage ===" rg "PopAckConstants" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for TopicFilterType usage ===" rg "TopicFilterType" rocketmq-broker/src/processor/processor_service/pop_revive_service.rs echo -e "\n=== Searching for MessageAccessor usage ===" rg "MessageAccessor" rocketmq-broker/src/processor/processor_service/pop_revive_service.rsLength of output: 4256
Line range hint
57-81
: Initialization logic is consistent, but consider verifying concurrency assumptions.
The constructor properly initializes the new fields, but if multiple threads instantiate or mutatePopReviveService
, ensure concurrency assumptions hold. In particular, confirm that theTopicConfigManager
andConsumerOffsetManager
usage remains thread-safe or is only used within a single-thread context.✅ Verification successful
Thread-safety is properly implemented through synchronized data structures
The code inspection reveals that
PopReviveService
is designed with thread-safety in mind:
- The
inflight_revive_request_map
is wrapped in bothArc
andparking_lot::Mutex
, providing thread-safe access to the shared state- Thread-safe components are used for shared resources:
Arc<ConsumerOffsetManager>
for consumer offset managementArc<BrokerConfig>
for broker configurationArcMut<EscapeBridge>
for escape bridge accessThe concurrency concerns in the review comment are already addressed through proper use of synchronization primitives. The implementation correctly handles concurrent access through atomic reference counting and mutex protection where needed.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Inspect references to PopReviveService::new usage across the codebase for concurrency or multi-thread usage patterns rg -A 5 'PopReviveService::new'Length of output: 31
Script:
#!/bin/bash # Let's try a broader search to understand the usage patterns and thread safety rg -l "PopReviveService" # Also search for potential concurrent access patterns ast-grep --pattern 'struct PopReviveService'Length of output: 141
Script:
#!/bin/bash # Look for any async or thread-related code around PopReviveService rg -B 3 -A 7 "PopReviveService"Length of output: 2478
Script:
#!/bin/bash # Search for any mutex or synchronization mechanisms rg "Arc::new|Mutex::new|RwLock::new" rocketmq-broker/src/processor/processor_service/pop_revive_service.rsLength of output: 179
Script:
#!/bin/bash # Let's check for any async methods or concurrent operations in the implementation ast-grep --pattern 'impl$$$PopReviveService$$$async fn' # Look for any methods that might modify the shared state rg -B 2 -A 5 "inflight_revive_request_map" rocketmq-broker/src/processor/processor_service/pop_revive_service.rsLength of output: 953
Script:
#!/bin/bash # Check if this service is used in any async/concurrent context rg -B 3 -A 7 "async.*PopReviveService"Length of output: 40
fn init_pop_retry_offset(&mut self, topic: &CheetahString, consumer_group: &CheetahString) { | ||
let offset = self | ||
.consumer_offset_manager | ||
.query_offset(consumer_group, topic, 0); | ||
if offset < 0 { | ||
self.consumer_offset_manager.commit_offset( | ||
"initPopRetryOffset".into(), | ||
consumer_group, | ||
topic, | ||
0, | ||
0, | ||
); |
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
Initialization with offset 0 might need a more detailed rationale.
If the offset is missing (“< 0”), you commit offset = 0. Consider whether resuming at offset 0 for existing topics might accidentally reprocess older messages or skip messages. A comment or doc note explaining this initialization decision would help maintainers.
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 #2073
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
New Features
Refactor
PopReviveService
struct with more comprehensive configuration management