-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix BenchReadThroughputLatency batch read can't stop problems. #4220
Fix BenchReadThroughputLatency batch read can't stop problems. #4220
Conversation
@@ -89,7 +89,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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the read is batched, the lastRead may be greater than lastConfirmed.
@@ -102,14 +102,14 @@ private static void readLedger(ClientConfiguration conf, long ledgerId, byte[] p | |||
} | |||
long starttime = System.nanoTime(); | |||
|
|||
while (entriesRead <= lastConfirmed) { | |||
while (entriesRead < lastConfirmed) { | |||
long nextLimit = lastRead + 100000; | |||
Enumeration<LedgerEntry> entries; | |||
if (batchEntries <= 0) { | |||
long readTo = Math.min(nextLimit, lastConfirmed); | |||
entries = lh.readEntries(lastRead + 1, readTo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the read is single read, we should make sure that entriesRead is less than lastConfirmed. Or the lastRead + 1
will be greater than readTo
.
long nextLimit = lastRead + 100000; | ||
Enumeration<LedgerEntry> 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lastRead
entry already be read, so we should read next entry at the next read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need init the lastRead
to -1
instead of 0
, otherwise the entry 0
can't be read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch.
while (entriesRead <= lastConfirmed) { | ||
long nextLimit = lastRead + 100000; | ||
while (entriesRead < lastConfirmed) { | ||
long nextLimit = lastRead + 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change it to 10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, that's a test at my local, I will revert it.
@@ -89,7 +89,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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we from the entry 0 to start read, so here we should make lastRead + 1
to compare with lastConfirmed.
…e#4220) Fix BenchReadThroughputLatency batch read can't stop problems.
Fix BenchReadThroughputLatency batch read can't stop problems.