rocketmq-rust icon indicating copy to clipboard operation
rocketmq-rust copied to clipboard

[Bug🐛] Static topic pulls can return the mapping start as the next offset

Open lipeh1 opened this issue 1 week ago • 0 comments

Prerequisites

  • [x] I have searched existing issues and discussions
  • [x] This is a bug, not a question (use Discussions for questions)

Environment

  • Windows 11 (x86-64)
  • main at 417d0f8a2
  • Rust 1.95.0

Bug Description

LogicQueueMappingItem::compute_static_queue_offset_strictly returns logic_offset for every physical offset above start_offset. The Broker uses this conversion for next_begin_offset when rewriting a static topic pull response. As a result, a successful read can point a consumer back to the start of the same mapping.

Steps to Reproduce

  1. Open the compute_static_queue_offset_strictly unit test in rocketmq-protocol/src/protocol/static_topic/logic_queue_mapping_item.rs. Its fixture has start_offset = 100 and logic_offset = 500.

  2. Set end_offset = 200 and replace the two existing assertions with the following check.

    let offsets = [50, 100, 150, 250].map(|p| item.compute_static_queue_offset_strictly(p));
    assert_eq!(offsets, [500, 500, 550, 650]);
    
  3. Run cargo test --locked -p rocketmq-protocol --lib compute_static_queue_offset_strictly.

Expected vs Actual

Physical offset 150 is 50 positions into the mapping and should translate to 550. It returns 500. Physical offset 50 precedes the mapping and should clamp to 500. It returns 450.

Logs/Screenshots

assertion `left == right` failed
  left: [450, 500, 500, 500]
 right: [500, 500, 550, 650]

Additional Context

The Apache RocketMQ 5.5.0 implementation clamps only offsets below the physical start. The Rust Broker pull response uses the strict conversion after it applies its own end-offset limit.

I will submit a fix with protocol and Broker pull-response regression coverage.

lipeh1 avatar Nov 27 '26 03:11 lipeh1