You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/03/31 01:45:17 UTC

[GitHub] [rocketmq] lizhiboo commented on a change in pull request #4071: bugfix : Returning min queue offset when timestamp is larger than queue-unit max timestamp

lizhiboo commented on a change in pull request #4071:
URL: https://github.com/apache/rocketmq/pull/4071#discussion_r839101346



##########
File path: store/src/main/java/org/apache/rocketmq/store/queue/BatchConsumeQueue.java
##########
@@ -710,6 +710,10 @@ public long getOffsetInQueueByTime(final long timestamp) {
         try {
             ByteBuffer byteBuffer = sbr.getByteBuffer();
             int left = targetMinOffset.getIndexPos(), right = targetMaxOffset.getIndexPos();
+            long maxQueueTimestamp = byteBuffer.getLong(right + MSG_STORE_TIME_OFFSET_INDEX);
+            if (timestamp >= maxQueueTimestamp) {
+                return byteBuffer.getLong(right + MSG_BASE_OFFSET_INDEX);
+            }
             int mid = binarySearchRight(byteBuffer, left, right, CQ_STORE_UNIT_SIZE, MSG_STORE_TIME_OFFSET_INDEX, timestamp);
             if (mid != -1) {

Review comment:
       if mid == -1, just the case timestamp > maxQueueTimestamp.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org