Fix batch read data in cache does not take effect
Descriptions of the changes in this PR:
### Motivation
Fix batch read data in cache does not take effect
### Changes
(Describe: what changes you have made)
Master Issue: #2230
Fixes: #2230
Reviewers: Jia Zhai <zhaijia@apache.org>, Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <None>
This closes #2231 from liudezhi2098/issue-branch-xxx
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
index e975f16..a6ae8c5 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
@@ -466,7 +466,7 @@
long size = 0;
while (count < readAheadCacheBatchSize && currentEntryLogId == firstEntryLogId) {
- ByteBuf entry = entryLogger.internalReadEntry(orginalLedgerId, -1, currentEntryLocation,
+ ByteBuf entry = entryLogger.internalReadEntry(orginalLedgerId, firstEntryId, currentEntryLocation,
false /* validateEntry */);
try {
@@ -482,6 +482,7 @@
readCache.put(orginalLedgerId, currentEntryId, entry);
count++;
+ firstEntryId++;
size += entry.readableBytes();
currentEntryLocation += 4 + entry.readableBytes();