Skip to content

[ISSUE #6597]🚀Add total message count and size methods to AssignedMessageQueue; implement async pull task and flow control checks in DefaultLitePullConsumerImpl#6598

Merged
rocketmq-rust-bot merged 1 commit intomainfrom
feat-6597
Mar 1, 2026

Conversation

@mxsm
Copy link
Owner

@mxsm mxsm commented Mar 1, 2026

Which Issue(s) This PR Fixes(Closes)

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

Release Notes

  • New Features
    • Added message cache monitoring capabilities to track total cached message count and size across queues
    • Implemented message pull task scheduling with multi-level flow control enforcement (global, per-queue, and span-based thresholds)

…sageQueue; implement async pull task and flow control checks in DefaultLitePullConsumerImpl
@rocketmq-rust-bot
Copy link
Collaborator

🔊@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💥.

@rocketmq-rust-bot rocketmq-rust-bot self-requested a review March 1, 2026 04:43
@rocketmq-rust-bot rocketmq-rust-bot added the waiting-review waiting review this PR label Mar 1, 2026
@rocketmq-rust-robot rocketmq-rust-robot added the feature🚀 Suggest an idea for this project. label Mar 1, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 1, 2026

Walkthrough

This PR adds message aggregation methods to AssignedMessageQueue and introduces an async pull task launcher with flow control enforcement to DefaultLitePullConsumerImpl, establishing infrastructure for message consumption and throttling management.

Changes

Cohort / File(s) Summary
Message Aggregation Methods
rocketmq-client/src/consumer/consumer_impl/assigned_message_queue.rs
Two new async methods added: total_msg_count() aggregates cached message counts across all queues, and total_msg_size_in_mib() aggregates cached message sizes in MiB.
Pull Task and Flow Control
rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs
Introduces async pull task spawning (start_pull_task), core pull stub (pull_inner), and flow control enforcement (check_flow_control) that validates global/per-queue message thresholds, message size limits, and offset span constraints; includes helper methods to aggregate queue cache metrics.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

Poem

🐰 Hops with joy through async streams,
Pull tasks dancing in their dreams,
Flow control reigns, thresholds align,
Message counts aggregate just fine—
RocketMQ's momentum takes flight! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes all major changes in the PR: new total message methods on AssignedMessageQueue, async pull task, and flow control checks in DefaultLitePullConsumerImpl.
Linked Issues check ✅ Passed The PR implements all three coding objectives from #6597: total message count/size API on AssignedMessageQueue, async pull task in DefaultLitePullConsumerImpl, and flow-control checks enforcement.
Out of Scope Changes check ✅ Passed All changes are directly aligned with #6597 objectives; no out-of-scope modifications detected beyond the specified features.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-6597

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@rocketmq-client/src/consumer/consumer_impl/assigned_message_queue.rs`:
- Around line 185-190: The method total_msg_size_in_mib currently divides each
queue's byte size by (1024*1024) before summing, losing sub‑MiB precision;
change the logic to sum all process_queue.msg_size() values from queue_map
(using the existing read lock and map.values() / process_queue.msg_size()) into
a 64‑bit accumulator, then perform a single division by (1024*1024) and cast to
i64 for the return value so truncation only occurs once after aggregation.

In
`@rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs`:
- Around line 575-577: cached_msg_size is computed in MiB by flooring
pq.msg_size() / (1024*1024) and thus can miss up to ~1 MiB; change the
comparison to use byte-level values instead: use pq.msg_size() as an i64 for
cached_msg_size (or simply compare pq.msg_size() as i64) against
(config.pull_threshold_size_for_queue as i64 * 1024 * 1024) so the flow-control
check in default_lite_pull_consumer_impl.rs (symbols: cached_msg_size,
pq.msg_size(), config.pull_threshold_size_for_queue, queue_flow_control_times)
triggers precisely when the queue exceeds the configured byte threshold.
- Around line 541-548: The pull_inner function currently uses unimplemented!()
which panics when a pull task runs; replace that panic with a proper async
implementation or at minimum a non-panicking placeholder that returns a
RocketMQResult<u64> so pull tasks continue running. Locate pull_inner(&self,
_mq: &MessageQueue, _process_queue: &Arc<...::ProcessQueue>) and either
implement the core pull logic (perform pull, compute retry/delay, and return
Ok(delay_ms)) or, as a safe interim fix, return an Ok(<reasonable_delay>) and
propagate errors via RocketMQResult instead of panicking; ensure any error paths
map to Err(...) rather than calling panic macros.
- Around line 501-538: The code inserts a new JoinHandle into self.task_handles
without cancelling any previous handle, which leaves the old background task
running; update the logic in start_pull_task (the code that writes to
self.task_handles and calls .insert(mq, handle)) to first check for an existing
handle for that MessageQueue, call abort() on it, and await/join it (e.g., let _
= old_handle.await; or handle.abort(); let _ = old_handle.await; to reap the
task) before inserting the new handle so the previous pull task is properly
cancelled and cleaned up.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74ab87d and be5b4aa.

📒 Files selected for processing (2)
  • rocketmq-client/src/consumer/consumer_impl/assigned_message_queue.rs
  • rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Comment on lines +185 to +190
/// Returns the total cached message size in MiB across all queues.
pub async fn total_msg_size_in_mib(&self) -> i64 {
let map = self.queue_map.read().await;
map.values()
.map(|aq| (aq.process_queue.msg_size() / (1024 * 1024)) as i64)
.sum()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid per-queue MiB truncation before summing total size.

Line [189] divides each queue size by MiB before aggregation, which drops sub‑MiB bytes per queue and underreports total cached size.

💡 Proposed fix
 pub async fn total_msg_size_in_mib(&self) -> i64 {
     let map = self.queue_map.read().await;
-    map.values()
-        .map(|aq| (aq.process_queue.msg_size() / (1024 * 1024)) as i64)
-        .sum()
+    let total_bytes: i64 = map
+        .values()
+        .map(|aq| aq.process_queue.msg_size() as i64)
+        .sum();
+    total_bytes / (1024 * 1024)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Returns the total cached message size in MiB across all queues.
pub async fn total_msg_size_in_mib(&self) -> i64 {
let map = self.queue_map.read().await;
map.values()
.map(|aq| (aq.process_queue.msg_size() / (1024 * 1024)) as i64)
.sum()
/// Returns the total cached message size in MiB across all queues.
pub async fn total_msg_size_in_mib(&self) -> i64 {
let map = self.queue_map.read().await;
let total_bytes: i64 = map
.values()
.map(|aq| aq.process_queue.msg_size() as i64)
.sum();
total_bytes / (1024 * 1024)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@rocketmq-client/src/consumer/consumer_impl/assigned_message_queue.rs` around
lines 185 - 190, The method total_msg_size_in_mib currently divides each queue's
byte size by (1024*1024) before summing, losing sub‑MiB precision; change the
logic to sum all process_queue.msg_size() values from queue_map (using the
existing read lock and map.values() / process_queue.msg_size()) into a 64‑bit
accumulator, then perform a single division by (1024*1024) and cast to i64 for
the return value so truncation only occurs once after aggregation.

Comment on lines +501 to +538
let handle = tokio::spawn(async move {
loop {
if shutdown_signal.load(Ordering::Acquire) {
break;
}

let pq = match assigned_mq.get_process_queue(&mq_clone).await {
Some(pq) if !pq.is_dropped() => pq,
_ => break,
};

if assigned_mq.is_paused(&mq_clone).await {
tokio::time::sleep(Duration::from_millis(
default_impl.consumer_config.pull_time_delay_millis_when_exception,
))
.await;
continue;
}

match default_impl.pull_inner(&mq_clone, &pq).await {
Ok(delay) => {
if delay > 0 {
tokio::time::sleep(Duration::from_millis(delay)).await;
}
}
Err(e) => {
tracing::error!("Pull error for {:?}: {}", mq_clone, e);
tokio::time::sleep(Duration::from_millis(
default_impl.consumer_config.pull_time_delay_millis_when_exception,
))
.await;
}
}
}
});

self.task_handles.write().await.insert(mq, handle);
Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "default_lite_pull_consumer_impl.rs" | head -5

Repository: mxsm/rocketmq-rust

Length of output: 141


🏁 Script executed:

wc -l rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 143


🏁 Script executed:

sed -n '501,538p' rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 1488


🌐 Web query:

Tokio 1.x JoinHandle drop behavior without abort await

💡 Result:

In Tokio 1.x, dropping a tokio::task::JoinHandle<T> does not abort/cancel the task.

  • Drop = detach: when the JoinHandle is dropped, the task keeps running in the background; you just lose the ability to await/“join” it and retrieve its result. [1]
  • What happens to the return value: once the task eventually finishes, if the JoinHandle is already gone, Tokio will drop the produced output automatically (there’s no longer any consumer). [2]
  • How to actually cancel: cancellation is done explicitly via JoinHandle::abort() (or an AbortHandle). A task is signaled to stop the next time it yields at an .await point. [3]
  • If you want “cancel on drop”: wrap the handle in tokio_util::task::AbortOnDropHandle, which does abort the task when dropped. [4]
  • Runtime shutdown: when the Tokio runtime shuts down (e.g., returning from #[tokio::main]), it cancels remaining tasks on that runtime. [3]

Sources: JoinHandle docs [1], Tokio runtime task internals re: dropping output when handle is gone [2], Tokio task cancellation docs [3], AbortOnDropHandle docs [4].


🏁 Script executed:

sed -n '1,100p' rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs | grep -A 5 "task_handles"

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

rg "task_handles" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs -A 3 -B 3

Repository: mxsm/rocketmq-rust

Length of output: 1346


🏁 Script executed:

sed -n '450,510p' rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 2345


🏁 Script executed:

rg "async fn.*start.*pull" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs -A 10

Repository: mxsm/rocketmq-rust

Length of output: 557


🏁 Script executed:

rg "start_pull_task" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs -B 5 -A 5

Repository: mxsm/rocketmq-rust

Length of output: 478


🏁 Script executed:

sed -n '1,50p' rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs | grep -E "struct|pub fn"

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

rg "start_pull_task" rocketmq-client/src/consumer/consumer_impl/ -B 3 -A 3

Repository: mxsm/rocketmq-rust

Length of output: 845


🏁 Script executed:

sed -n '300,400p' rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 4591


🏁 Script executed:

rg "start_pull_task" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 139


🏁 Script executed:

rg "assign" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs -B 2 -A 10 | head -100

Repository: mxsm/rocketmq-rust

Length of output: 4264


🏁 Script executed:

rg "start_pull_task" rocketmq-client/src/ -B 5 -A 5

Repository: mxsm/rocketmq-rust

Length of output: 1336


🏁 Script executed:

rg "assigned_message_queue" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs | grep -E "fn|pub|add|assign"

Repository: mxsm/rocketmq-rust

Length of output: 462


🏁 Script executed:

rg "on_assign" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs -A 30

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

cat rocketmq-client/src/consumer/consumer_impl/assigned_message_queue.rs

Repository: mxsm/rocketmq-rust

Length of output: 7110


🏁 Script executed:

rg "start_pull_task" rocketmq-client/src/ -B 10 -A 2

Repository: mxsm/rocketmq-rust

Length of output: 1488


🏁 Script executed:

rg "fn.*MQConsumerInner\|notify_consumer_queue_change" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs -A 30

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

rg "notify_consumer_queue_change\|on_assign\|reassign_queues" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs -A 20

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

rg "start_pull_task" rocketmq-client/src/consumer/ -B 3 -A 1

Repository: mxsm/rocketmq-rust

Length of output: 623


🏁 Script executed:

rg "start_pull_task" rocketmq-client/src/consumer/consumer_impl/re_balance/ -B 5 -A 5

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

sed -n '550,659p' rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 4098


🏁 Script executed:

rg "impl.*RebalanceLitePullImpl\|update_assigned_message_queue" rocketmq-client/src/consumer/ -A 20

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

rg "trait RebalanceLitePullImpl" rocketmq-client/src/consumer/ -A 5

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

rg "MQConsumerInner\|RebalanceLite" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs | head -20

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

sed -n '1,30p' rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 1314


🏁 Script executed:

rg "task_handles.*insert\|start_pull_task" rocketmq-client/src/ -B 3 -A 3

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

rg "start_pull_task\|task_handles" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

rg "assign\|queue_change" rocketmq-client/src/consumer/consumer_impl/re_balance/ -l

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

grep -r "start_pull_task" rocketmq-client/src/consumer/ 2>/dev/null | head -20

Repository: mxsm/rocketmq-rust

Length of output: 217


🏁 Script executed:

grep -r "task_handles.*insert" rocketmq-client/src/consumer/ 2>/dev/null

Repository: mxsm/rocketmq-rust

Length of output: 199


🏁 Script executed:

rg "struct DefaultLitePullConsumerImpl" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs -A 50 | head -70

Repository: mxsm/rocketmq-rust

Length of output: 2009


🏁 Script executed:

sed -n '200,300p' rocketmq-client/src/consumer/consumer_impl/re_balance/rebalance_lite_pull_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 4568


🏁 Script executed:

find rocketmq-client/src/consumer/consumer_impl/re_balance -name "*.rs" -exec grep -l "start_pull_task\|assign" {} \;

Repository: mxsm/rocketmq-rust

Length of output: 215


🏁 Script executed:

cat rocketmq-client/src/consumer/consumer_impl/re_balance/rebalance_lite_pull_impl.rs | head -200

Repository: mxsm/rocketmq-rust

Length of output: 9158


🏁 Script executed:

grep -n "start_pull_task" rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs

Repository: mxsm/rocketmq-rust

Length of output: 143


🏁 Script executed:

rg "update_assigned_message_queue\|put_process_queue" rocketmq-client/src/consumer/consumer_impl/ -A 10

Repository: mxsm/rocketmq-rust

Length of output: 44


Abort the previous pull task handle before overwriting.

Line 537 inserts a new task handle without aborting the previous one. In Tokio 1.x, dropping a JoinHandle does not cancel the task—it continues running in the background. If start_pull_task is called again for the same MessageQueue, both the old and new pull tasks will run concurrently, creating a race condition on message offsets.

Recommended fix
-        self.task_handles.write().await.insert(mq, handle);
+        let mut handles = self.task_handles.write().await;
+        if let Some(old_handle) = handles.insert(mq, handle) {
+            old_handle.abort();
+        }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs`
around lines 501 - 538, The code inserts a new JoinHandle into self.task_handles
without cancelling any previous handle, which leaves the old background task
running; update the logic in start_pull_task (the code that writes to
self.task_handles and calls .insert(mq, handle)) to first check for an existing
handle for that MessageQueue, call abort() on it, and await/join it (e.g., let _
= old_handle.await; or handle.abort(); let _ = old_handle.await; to reap the
task) before inserting the new handle so the previous pull task is properly
cancelled and cleaned up.

Comment on lines +541 to +548
/// Core pull logic (returns delay in milliseconds).
async fn pull_inner(
&self,
_mq: &MessageQueue,
_process_queue: &Arc<crate::consumer::consumer_impl::process_queue::ProcessQueue>,
) -> RocketMQResult<u64> {
unimplemented!("pull_inner")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

pull_inner panics at runtime and blocks pull-task execution.

Line [547] uses unimplemented!, so any started pull task will panic on first execution of pull logic.

💡 Proposed fix
 async fn pull_inner(
     &self,
     _mq: &MessageQueue,
     _process_queue: &Arc<crate::consumer::consumer_impl::process_queue::ProcessQueue>,
 ) -> RocketMQResult<u64> {
-    unimplemented!("pull_inner")
+    if let Some(delay) = self.check_flow_control(_mq, _process_queue).await? {
+        return Ok(delay);
+    }
+    Err(crate::mq_client_err!("pull_inner is not implemented yet"))
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs`
around lines 541 - 548, The pull_inner function currently uses unimplemented!()
which panics when a pull task runs; replace that panic with a proper async
implementation or at minimum a non-panicking placeholder that returns a
RocketMQResult<u64> so pull tasks continue running. Locate pull_inner(&self,
_mq: &MessageQueue, _process_queue: &Arc<...::ProcessQueue>) and either
implement the core pull logic (perform pull, compute retry/delay, and return
Ok(delay_ms)) or, as a safe interim fix, return an Ok(<reasonable_delay>) and
propagate errors via RocketMQResult instead of panicking; ensure any error paths
map to Err(...) rather than calling panic macros.

Comment on lines +575 to +577
let cached_msg_size = (pq.msg_size() / (1024 * 1024)) as i64;
if cached_msg_size > config.pull_threshold_size_for_queue as i64 {
self.queue_flow_control_times.fetch_add(1, Ordering::Relaxed);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use byte-level comparison for queue-size flow control.

Line [575] floors bytes to MiB before comparing at Line [576]. A queue can exceed the configured size threshold by up to almost 1 MiB without being throttled.

💡 Proposed fix
-        let cached_msg_size = (pq.msg_size() / (1024 * 1024)) as i64;
-        if cached_msg_size > config.pull_threshold_size_for_queue as i64 {
+        let cached_msg_size_bytes = pq.msg_size() as i64;
+        let threshold_size_bytes = (config.pull_threshold_size_for_queue as i64) * 1024 * 1024;
+        if cached_msg_size_bytes > threshold_size_bytes {
             self.queue_flow_control_times.fetch_add(1, Ordering::Relaxed);
             return Ok(Some(config.pull_time_delay_millis_when_cache_flow_control));
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let cached_msg_size = (pq.msg_size() / (1024 * 1024)) as i64;
if cached_msg_size > config.pull_threshold_size_for_queue as i64 {
self.queue_flow_control_times.fetch_add(1, Ordering::Relaxed);
let cached_msg_size_bytes = pq.msg_size() as i64;
let threshold_size_bytes = (config.pull_threshold_size_for_queue as i64) * 1024 * 1024;
if cached_msg_size_bytes > threshold_size_bytes {
self.queue_flow_control_times.fetch_add(1, Ordering::Relaxed);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@rocketmq-client/src/consumer/consumer_impl/default_lite_pull_consumer_impl.rs`
around lines 575 - 577, cached_msg_size is computed in MiB by flooring
pq.msg_size() / (1024*1024) and thus can miss up to ~1 MiB; change the
comparison to use byte-level values instead: use pq.msg_size() as an i64 for
cached_msg_size (or simply compare pq.msg_size() as i64) against
(config.pull_threshold_size_for_queue as i64 * 1024 * 1024) so the flow-control
check in default_lite_pull_consumer_impl.rs (symbols: cached_msg_size,
pq.msg_size(), config.pull_threshold_size_for_queue, queue_flow_control_times)
triggers precisely when the queue exceeds the configured byte threshold.

@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

❌ Patch coverage is 0% with 89 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.71%. Comparing base (74ab87d) to head (be5b4aa).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...r/consumer_impl/default_lite_pull_consumer_impl.rs 0.00% 79 Missing ⚠️
...c/consumer/consumer_impl/assigned_message_queue.rs 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6598      +/-   ##
==========================================
- Coverage   41.74%   41.71%   -0.04%     
==========================================
  Files         959      959              
  Lines      133927   134016      +89     
==========================================
- Hits        55910    55905       -5     
- Misses      78017    78111      +94     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - All CI checks passed ✅

@rocketmq-rust-bot rocketmq-rust-bot merged commit 9e91a89 into main Mar 1, 2026
18 of 20 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI review first Ai review pr first approved PR has approved auto merge feature🚀 Suggest an idea for this project.

Projects

None yet

3 participants