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

SortedLedgerStorage supports multiple dirs #3493

Closed

Conversation

StevenLuMT
Copy link
Member

@StevenLuMT StevenLuMT commented Sep 16, 2022

Descriptions of the changes in this PR:

Motivation

planning for multiple dirs: mail talking
stage 1 :

  1. SortedLedgerStorage supports multiple dirs

the condition that the bug triggers:
1) conf.getLedgerDirs are multiple dirs
2) ledgerStorageClass=org.apache.bookkeeper.bookie.SortedLedgerStorage

Changes

  1. SortedLedgerStorage supports multiple dirs

@StevenLuMT StevenLuMT force-pushed the master_SortedLedgerStorageMultiDirs branch from d736bf8 to d201d74 Compare September 17, 2022 01:21
@StevenLuMT StevenLuMT force-pushed the master_SortedLedgerStorageMultiDirs branch from 0848afb to ecd4eb2 Compare September 17, 2022 01:24
interleavedLedgerStorage.checkpointer.startCheckpoint(cp);
for (InterleavedLedgerStorage s : interleavedLedgerStorageList) {
try {
LOG.info("Started flushing mem table.");
Copy link
Contributor

Choose a reason for hiding this comment

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

This line will be logged multiple times. Can we log something about 's'?

Copy link
Member Author

Choose a reason for hiding this comment

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

finished:
print log's dir

s.checkpointer.startCheckpoint(cp);
}
} catch (Exception e) {
s.getStateManager().transitionToReadOnlyMode();
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here

Copy link
Member Author

Choose a reason for hiding this comment

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

finished:
print log's dir


public DefaultEntryLogger getEntryLogger() {
return interleavedLedgerStorage.getEntryLogger();
public List<DefaultEntryLogger> getEntryLogger() {
Copy link
Contributor

Choose a reason for hiding this comment

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

getDefaultEntryLoggers

Copy link
Member Author

Choose a reason for hiding this comment

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

finished

}

@Override
public void forceGC() {
interleavedLedgerStorage.forceGC();
interleavedLedgerStorageList.forEach(s -> s.forceGC());
Copy link
Contributor

Choose a reason for hiding this comment

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

If one of the instances throws an error we won't process the others.
I suggest to wrap the error and continue processing.
Then, if one error occurred we throw it in the end.
The same here and in other similar methods

Copy link
Member Author

Choose a reason for hiding this comment

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

finished:
exception handling optimization

}

@Override
public LedgerStorage getUnderlyingLedgerStorage() {
return interleavedLedgerStorage;
return interleavedLedgerStorageList.get(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure that this is correct.
Is this method only for tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

finished:
this is mistake,I have updated

}

@VisibleForTesting
protected SortedLedgerStorage(InterleavedLedgerStorage ils) {
interleavedLedgerStorage = ils;
protected SortedLedgerStorage(String interleavedLedgerStorageClazz) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we pass a class name here?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is for InterleavedLedgerStorage's child class: SlowInterleavedLedgerStorage

we can init SortedLedgerStorage with overide the diff child InterleavedLedgerStorage

image

@dlg99
Copy link
Contributor

dlg99 commented Sep 20, 2022

the condition that the bug triggers:

please provide more details - what's the bug / how it affects BK.

Copy link
Contributor

@dlg99 dlg99 left a comment

Choose a reason for hiding this comment

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

See comments

LOG.info("ledgerStorage({}) started flushing mem table.",
getEntryLogDirPath(s.getEntryLogger()));
s.getEntryLogger().prepareEntryMemTableFlush();
memTable.flush(SortedLedgerStorage.this);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is no need to do memetable.flush for each interleaved storage, Sorted storage should fan flush out.

s.getEntryLogger().prepareEntryMemTableFlush();
memTable.flush(SortedLedgerStorage.this);

if (s.getEntryLogger().commitEntryMemTableFlush()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it is possible that only some interleaved storages / entry loggers actually got data (e.g. memetaable had data for one ledger only). What's the side-effect of the prepare/commit flush without any actual data? Do we have tests for this?

s.checkpointer.startCheckpoint(cp);
}
} catch (Exception e) {
s.getStateManager().transitionToReadOnlyMode();
Copy link
Contributor

Choose a reason for hiding this comment

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

Now we create interleaved storages (ILS) per directory (ledgerDirsManager.getAllLedgerDirs().size())
Entry log manager (EntryLogManagerBase, getCurrentLogForLedgerForAddEntry/createNewLog/selectDirForNextEntryLog) still rotates entry logs across all available directories (the only reason why transition to read only on one ILS failing write is acceptable.) Also there is entry log per ledger.

It looks like it implicitly introduces parallelism (N ILSs for N dirs -> will write to N entry loggers, possibly at the same dir) which might not be ok for rotational disks

i do not have clear picture of what specifically you are trying to achieve so this per my best understanding.

@StevenLuMT
Copy link
Member Author

@dlg99 thank you for your comments, I will sort it out and reply to you later

@StevenLuMT
Copy link
Member Author

Temporarily close first, and reopen after improvement

@StevenLuMT StevenLuMT closed this Feb 14, 2025
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