-
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 #1671]⚡️Optimize MQClientInstance#find_broker_address_in_subscribe method signature🔥 #1673
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -845,7 +845,7 @@ | |
let client = self.client_instance.as_mut().unwrap(); | ||
let broker_name = client.get_broker_name_from_message_queue(mq).await; | ||
let find_broker_result = client | ||
.find_broker_address_in_subscribe(broker_name.as_str(), mix_all::MASTER_ID, true) | ||
.find_broker_address_in_subscribe(&broker_name, mix_all::MASTER_ID, true) | ||
.await; | ||
if let Some(find_broker_result) = find_broker_result { | ||
let mut request_body = LockBatchRequestBody { | ||
|
@@ -900,11 +900,7 @@ | |
} | ||
let client = client_instance.as_mut().unwrap(); | ||
let find_broker_result = client | ||
.find_broker_address_in_subscribe( | ||
broker_name.as_str(), | ||
mix_all::MASTER_ID, | ||
true, | ||
) | ||
.find_broker_address_in_subscribe(&broker_name, mix_all::MASTER_ID, true) | ||
.await; | ||
if let Some(find_broker_result) = find_broker_result { | ||
let request_body = LockBatchRequestBody { | ||
|
@@ -1018,7 +1014,7 @@ | |
} | ||
let client = self.client_instance.as_mut().unwrap(); | ||
let find_broker_result = client | ||
.find_broker_address_in_subscribe(broker_name.as_str(), mix_all::MASTER_ID, true) | ||
.find_broker_address_in_subscribe(&broker_name, mix_all::MASTER_ID, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Add test coverage for broker unlocking mechanism The verification confirms that there is no test coverage for the unlock mechanism in both
Add test cases covering:
🔗 Analysis chainAdd test coverage for broker unlocking mechanism. The broker unlocking logic lacks test coverage. Ensure proper testing of unlock scenarios, especially error cases and potential deadlock situations. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check existing test coverage for broker unlocking
rg -l "unlock_all.*test"
Length of output: 26 Script: #!/bin/bash
# Search for test files and unlock patterns more broadly
rg -l "test" rocketmq-client/src/consumer/consumer_impl/re_balance/
rg "unlock" rocketmq-client/src/consumer/consumer_impl/re_balance/ -C 2
Length of output: 9476 Script: #!/bin/bash
# Look for test modules and unlock_all usage
ast-grep --pattern 'mod test { $$$ }' rocketmq-client/src/consumer/consumer_impl/re_balance/rebalance_impl.rs
ast-grep --pattern 'fn unlock_all($$$) { $$$ }' rocketmq-client/src/consumer/consumer_impl/re_balance/rebalance_impl.rs
Length of output: 233 🧰 Tools🪛 GitHub Check: codecov/patch[warning] 1017-1017: rocketmq-client/src/consumer/consumer_impl/re_balance/rebalance_impl.rs#L1017 |
||
.await; | ||
if let Some(find_broker_result) = find_broker_result { | ||
let request_body = UnlockBatchRequestBody { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -441,7 +441,7 @@ | |
}; | ||
let broker_name = client.get_broker_name_from_message_queue(mq).await; | ||
let find_broker_result = client | ||
.find_broker_address_in_subscribe(broker_name.as_str(), mix_all::MASTER_ID, true) | ||
.find_broker_address_in_subscribe(&broker_name, mix_all::MASTER_ID, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Critical unlock functionality lacks test coverage in consumer implementation The unlock functionality in
Action items:
🔗 Analysis chainMethod signature optimization is consistent but critical path needs tests. The change aligns with the optimization pattern of passing broker names as references. However, this is in the unlock method which is critical for message queue management. Let's verify the test coverage for the unlock functionality: Let me gather more information about the unlock functionality and its test coverage. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check test coverage for unlock functionality
# Look for existing tests
rg -l "unlock.*test"
# Check test patterns
ast-grep --pattern 'fn test_$$$unlock$$$'
Length of output: 129 Script: #!/bin/bash
# Check the implementation and usage of unlock in rebalance_push_impl.rs
rg -A 5 "fn.*unlock" rocketmq-client/src/consumer/consumer_impl/re_balance/rebalance_push_impl.rs
# Check test modules in rebalance_push_impl.rs
rg -A 5 "mod test" rocketmq-client/src/consumer/consumer_impl/re_balance/rebalance_push_impl.rs
# Look for any test files related to rebalance push
fd "rebalance.*test" rocketmq-client/src/consumer/
# Check if unlock is tested in the broker's test file we found earlier
rg -A 5 "unlock.*test" rocketmq-broker/src/client/rebalance/rebalance_lock_manager.rs
Length of output: 1226 🧰 Tools🪛 GitHub Check: codecov/patch[warning] 444-444: rocketmq-client/src/consumer/consumer_impl/re_balance/rebalance_push_impl.rs#L444 |
||
.await; | ||
if let Some(find_broker_result) = find_broker_result { | ||
let mut request_body = UnlockBatchRequestBody { | ||
|
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.
💡 Codebase verification
Add unit tests for broker locking in RebalanceImpl
The broker locking mechanism in
RebalanceImpl
lacks test coverage. While there are tests for the broker-side locking manager (RebalanceLockManager
), the consumer-side implementation inrebalance_impl.rs
needs test coverage for:find_broker_address_in_subscribe
🔗 Analysis chain
Add test coverage for broker locking mechanism.
This broker locking logic is critical for message queue operations but lacks test coverage. Additionally, verify that the locking mechanism properly handles concurrent access scenarios.
Let me check the actual test coverage by examining the test implementations.
Let me check one more thing to verify if there are any integration tests or related test files for the consumer implementation.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 87
Script:
Length of output: 1487
Script:
Length of output: 199
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 903-903: rocketmq-client/src/consumer/consumer_impl/re_balance/rebalance_impl.rs#L903
Added line #L903 was not covered by tests