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

[bookie-shell] fix readLedger with parameter -bookie and -ledgerid can not read any entries in ledger #3874

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TakaHiR07
Copy link
Contributor

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


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) {
Copy link
Member

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.

  1. remove the lastEntry == -1 judgment, once meet BKNoSuchEntryException, end the loop.
  2. Add more limitations for the loop. (lastEntry == -1 || nextEntryId <= lastEntry && nextEntryId <= LAC), we can use bookieClient.readLac() to get the LAC.

@shoothzj
Copy link
Member

@TakaHiR07 Are you still working on this?

@TakaHiR07
Copy link
Contributor Author

@TakaHiR07 Are you still working on this?

Sorry for forget this work. If needing, I can finish this in a few day.

@shoothzj
Copy link
Member

@TakaHiR07 Thanks for your contribution, I want to move this forward in the next release.

Copy link
Member

@shoothzj shoothzj left a 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?

@TakaHiR07 TakaHiR07 force-pushed the improve_bookie_shell_readledger branch from 8baa5f7 to 99aaf0d Compare May 14, 2024 02:56
@TakaHiR07
Copy link
Contributor Author

Can we add some tests?

@shoothzj @horizonzy Have done. Can you help review again. Thx

@TakaHiR07 TakaHiR07 requested a review from horizonzy May 22, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants