Skip to content
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

Merged
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,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;
Expand All @@ -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) {
Copy link
Member Author

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.

nochange++;
if (nochange == 10) {
break;
Expand All @@ -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);
Copy link
Member Author

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.

} else {
entries = lh.batchReadEntries(lastRead, batchEntries, -1);
entries = lh.batchReadEntries(lastRead + 1, batchEntries, -1);
Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch.

}
while (entries.hasMoreElements()) {
LedgerEntry e = entries.nextElement();
Expand Down
Loading