Skip to content

Commit 6819b4d

Browse files
[ISSUE #9233] Fix query time boundary calculation in tiered storage (#9374)
1 parent 8c623df commit 6819b4d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tieredstore/src/main/java/org/apache/rocketmq/tieredstore/index/IndexStoreService.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,15 @@ public AppendResult putKey(
226226
public CompletableFuture<List<IndexItem>> queryAsync(
227227
String topic, String key, int maxCount, long beginTime, long endTime) {
228228

229+
if (beginTime > endTime) {
230+
return CompletableFuture.completedFuture(new ArrayList<>());
231+
}
232+
229233
CompletableFuture<List<IndexItem>> future = new CompletableFuture<>();
230234
try {
231235
readWriteLock.readLock().lock();
232-
long firstFileTimeStamp = this.timeStoreTable.lowerKey(beginTime) == null ?
233-
this.timeStoreTable.firstKey() : this.timeStoreTable.lowerKey(beginTime);
234236
ConcurrentNavigableMap<Long, IndexFile> pendingMap =
235-
this.timeStoreTable.subMap(firstFileTimeStamp, true, endTime, true);
237+
this.timeStoreTable.subMap(beginTime, true, endTime, true);
236238
List<CompletableFuture<Void>> futureList = new ArrayList<>(pendingMap.size());
237239
ConcurrentHashMap<String /* queueId-offset */, IndexItem> result = new ConcurrentHashMap<>();
238240

@@ -260,6 +262,8 @@ public CompletableFuture<List<IndexItem>> queryAsync(
260262
}
261263
});
262264
} catch (Exception e) {
265+
log.error("IndexStoreService#queryAsync, topicId={}, key={}, maxCount={}, timestamp={}-{}",
266+
topic, key, maxCount, beginTime, endTime, e);
263267
future.completeExceptionally(e);
264268
} finally {
265269
readWriteLock.readLock().unlock();

0 commit comments

Comments
 (0)