-
Notifications
You must be signed in to change notification settings - Fork 903
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
[bookie-shell] fix readLedger with parameter -bookie and -ledgerid can not read any entries in ledger #3874
base: master
Are you sure you want to change the base?
Conversation
|
||
try { | ||
future.get(); | ||
} catch (Exception e) { | ||
LOG.error("Error future.get while reading entries from ledger {}", flags.ledgerId, e); | ||
if (e.getCause() instanceof BKException.BKNoSuchEntryException && lastEntry == -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.
If the ledger only has 100 entries, but the input param lastEntry
is 10000, it will still read 100-10000 entries.
There are two ways to solve it.
- remove the
lastEntry == -1
judgment, once meet BKNoSuchEntryException, end the loop. - Add more limitations for the loop. (lastEntry == -1 || nextEntryId <= lastEntry && nextEntryId <= LAC), we can use bookieClient.readLac() to get the LAC.
@TakaHiR07 Are you still working on this? |
Sorry for forget this work. If needing, I can finish this in a few day. |
@TakaHiR07 Thanks for your contribution, I want to move this forward in the next release. |
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.
Can we add some tests?
8baa5f7
to
99aaf0d
Compare
@shoothzj @horizonzy Have done. Can you help review again. Thx |
Motivation
If we use bookieshell readLedger only with parameter -ledgerid, we can read all entries in this ledger, but if use with parameter -ledgerid and --bookie, we cant read any entries.
This is because it try to reverse entries from firstentry(default 0) to lastEntry(default -1). Therefore it would directly finish without read any entries, misleading us that ledgerId in our selected bookie has no entry.
Changes
when set -ledgerid and -bookie and not set -entry, continue to read next entry until get BKNoSuchEntryException