[
https://issues.apache.org/jira/browse/BOOKKEEPER-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13204339#comment-13204339
]
Sijie Guo commented on BOOKKEEPER-137:
--------------------------------------
hmm, I can't find the code to avoid readHeader twice.
{code}
909 LedgerDescriptor l = getHandle(ledgerId, false, masterKey);
910 if (!l.isMasterKeyPersisted()) {
{code}
suppose a ledger is existed before but not in cache. then readHeader still be
called twice as below:
getHandle => createHandle => lh#checkAccess(masterKey) => the initial masterKey
in lh is null, lh gets FileInfo#getMasterKey => no master key in FileInfo =>
FileInfo#checkOpen => FileInfo#readHeader (yes, it read header).
lh#isMasterKeyPersisted (the initial masterKeyPersisted is false) => it will
get FileInfo from LedgerCache => call FileInfo#readHeader (then, it read header
again)
> Do not create Ledger index files until absolutely necessary.
> ------------------------------------------------------------
>
> Key: BOOKKEEPER-137
> URL: https://issues.apache.org/jira/browse/BOOKKEEPER-137
> Project: Bookkeeper
> Issue Type: Bug
> Reporter: Ivan Kelly
> Assignee: Ivan Kelly
> Fix For: 4.1.0
>
> Attachments: BOOKKEEPER-137.diff, BOOKKEEPER-137.diff,
> BOOKKEEPER-137.diff, BOOKKEEPER-137.diff, BOOKKEEPER-137.diff
>
>
> This is an optimization to speed up the case where we have many ledgers and
> are writing to them at random (a benchmark case we currently have).
> Currently, we create the ledger index file and write the first 1k of it to
> disk immediately. With a lot of ledgers being randomly written to, this means
> a lot of random writes on the ledger disk. This fix postpones the creation of
> the index file and writing of the first 1k until the first flush of the
> ledger.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira