RongtongJin commented on a change in pull request #1955:
URL: https://github.com/apache/rocketmq/pull/1955#discussion_r414501880
##########
File path:
store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
##########
@@ -663,9 +663,27 @@ public long getMaxOffsetInQueue(String topic, int queueId)
{
}
public long getMinOffsetInQueue(String topic, int queueId) {
+ return getMinOffsetInQueue(topic, queueId,false);
+ }
+
+ public long getMinOffsetInQueue(String topic, int queueId, boolean
realOffset) {
ConsumeQueue logic = this.findConsumeQueue(topic, queueId);
if (logic != null) {
- return logic.getMinOffsetInQueue();
+ long consumeQueueOffset = logic.getMinOffsetInQueue();
+ MessageExt msgExt = null;
+ long commitLogOffset = 0L;
+ if (realOffset) {
+ for (;consumeQueueOffset <=
getMaxOffsetInQueue(topic,queueId);consumeQueueOffset++) {
+ commitLogOffset = getCommitLogOffsetInQueue(topic,
queueId, consumeQueueOffset);
+ msgExt = lookMessageByOffset(commitLogOffset);
+ if (null != msgExt) {
+ return consumeQueueOffset;
+ }
+ }
+ return consumeQueueOffset;
Review comment:
IMO, this is a very CPU intensive operation. It is possible to get a
lot of cold data and decode it, which will affect the stability of the broker.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]