From ad06dfb2c0658d15a46e1837a669cc05702e5350 Mon Sep 17 00:00:00 2001 From: Yan Zhao Date: Mon, 18 Mar 2024 11:03:42 +0800 Subject: [PATCH] Fix BenchReadThroughputLatency batch read can't stop problems. (#4220) Fix BenchReadThroughputLatency batch read can't stop problems. --- .../bookkeeper/benchmark/BenchReadThroughputLatency.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java index 5cd029b3c1e..bfff2ed53d1 100644 --- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java +++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java @@ -79,7 +79,7 @@ private static void readLedger(ClientConfiguration conf, long ledgerId, byte[] p BookKeeper bk = null; long time = 0; long entriesRead = 0; - long lastRead = 0; + long lastRead = -1; int nochange = 0; long absoluteLimit = 5000000; @@ -90,7 +90,7 @@ private static void readLedger(ClientConfiguration conf, long ledgerId, byte[] p lh = bk.openLedgerNoRecovery(ledgerId, BookKeeper.DigestType.CRC32, passwd); long lastConfirmed = Math.min(lh.getLastAddConfirmed(), absoluteLimit); - if (lastConfirmed == lastRead) { + if (lastConfirmed <= lastRead + 1) { nochange++; if (nochange == 10) { break; @@ -103,14 +103,14 @@ private static void readLedger(ClientConfiguration conf, long ledgerId, byte[] p } long starttime = System.nanoTime(); - while (entriesRead <= lastConfirmed) { + while (lastRead < lastConfirmed) { long nextLimit = lastRead + 100000; Enumeration entries; if (batchEntries <= 0) { long readTo = Math.min(nextLimit, lastConfirmed); entries = lh.readEntries(lastRead + 1, readTo); } else { - entries = lh.batchReadEntries(lastRead, batchEntries, -1); + entries = lh.batchReadEntries(lastRead + 1, batchEntries, -1); } while (entries.hasMoreElements()) { LedgerEntry e = entries.nextElement();