[Bug🐛] Static topic pulls can return the mapping start as the next offset
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)
mainat417d0f8a2- 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
-
Open the
compute_static_queue_offset_strictlyunit test inrocketmq-protocol/src/protocol/static_topic/logic_queue_mapping_item.rs. Its fixture hasstart_offset = 100andlogic_offset = 500. -
Set
end_offset = 200and 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]); -
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.