-
Notifications
You must be signed in to change notification settings - Fork 893
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] Fix sorted ledger storage rotating entry log files too frequent #1807
Conversation
*Motivation* A strong behavior was observed when using sorted ledger storage with single entry log manager on production: "the entry log files are rotated very frequently and small entry log files are produced". The problem was introduced due to apache#1410. At current entry logger, when a new entry log file is created, EntryLogger will notify its listeners that a new entry log file is rotated via [`onRotateEntryLog`](https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogManagerBase.java#L152). Before the change in apache#1410, `SortedLedgerStorage` inherits from `InterleavedLedgerStorage`. So when a new entry log file is rotated, `SortedLedgerStorage` is notified. However after the change in apache#1410, `SortedLedgerStorage` doesn't inherits `InterleavedLedgerStorage` anymore. Instead, the relationship is changed to composition. `SortedLedgerStorage` is composed using an interleaved ledger storage. So the entrylog listener contract was broken. `SortedLedgerStorage` will not receive any `onRotateEntryLog` notification any more. *Changes* When `SortedLedgerStorage` initializes, it passes its own entry log listener down to the interleaved ledger storage. So entry logger can notify the right person for entry log rotations. *Tests* Existing tests should cover most of the case. Looking for how to add new test cases.
(not sure if that's the best fix or not. any suggestions are welcome) |
statsLogger); | ||
} | ||
|
||
void initializeWithEntryLogListener(ServerConfiguration conf, |
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.
instead of adding a new initialize method, you should consider changing the signature of the existing initialize method, which takes EntryLogListener argument. In ILS initialize method it will check if it receives the listener, if it is not null use it otherwise use ‘this’.
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.
Actually I think currently entry log listener is only visible to interleaved and sorte ledger storages. but it is not visible to db ledger storage. so I think it is probably better to use my approach here, since the behavior is only applied to interleaved and sorted ledger storage.
we can improve it later if this listener is going to be applied to all ledger storage implementation.
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.
@reddycharan I am not sure your proposal is clearer. Because it will add an implicit default.
To me we can go with this change, but I have no strong feeling
@sijie in this change can you add log files in the stackTrace of createNewLog call hierarchy. As we observed in the log file, it was not evident what triggered the creation of new entrylog files. Since createNewLog is infrequent thing, it should be ok to add logs as much as we want. |
@reddycharan I added a logging message with a reason field. let me know if this approach works for you. |
createNewLog(ledgerId); | ||
createNewLog(ledgerId, | ||
": diskFull = " + diskFull + ", allDisksFull = " + allDisksFull | ||
+ ", reachEntryLogLimit = " + reachEntryLogLimit); |
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.
we can get to this block even if logChannel is null. so add that aswell to the reason string.
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.
add logChannel in the reason string.
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.
LGTM other than that minor log statement issue - https://github.com/apache/bookkeeper/pull/1807/files#r233123238
run integration tests |
IGNORE IT CI |
Descriptions of the changes in this PR: *Motivation* A strong behavior was observed when using sorted ledger storage with single entry log manager on production: "the entry log files are rotated very frequently and small entry log files are produced". The problem was introduced due to #1410. At current entry logger, when a new entry log file is created, EntryLogger will notify its listeners that a new entry log file is rotated via [`onRotateEntryLog`](https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogManagerBase.java#L152). Before the change in #1410, `SortedLedgerStorage` inherits from `InterleavedLedgerStorage`. So when a new entry log file is rotated, `SortedLedgerStorage` is notified. However after the change in #1410, `SortedLedgerStorage` doesn't inherits `InterleavedLedgerStorage` anymore. Instead, the relationship is changed to composition. `SortedLedgerStorage` is composed using an interleaved ledger storage. So the entrylog listener contract was broken. `SortedLedgerStorage` will not receive any `onRotateEntryLog` notification any more. *Changes* When `SortedLedgerStorage` initializes, it passes its own entry log listener down to the interleaved ledger storage. So entry logger can notify the right person for entry log rotations. *Tests* Existing tests should cover most of the case. Looking for how to add new test cases. Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Charan Reddy Guttapalem <reddycharan18@gmail.com>, Andrey Yegorov <None> This closes #1807 from sijie/fix_rotation_behavior (cherry picked from commit deebe6d) Signed-off-by: Sijie Guo <sijie@apache.org>
Descriptions of the changes in this PR:
Motivation
A strong behavior was observed when using sorted ledger storage with single entry log manager on production:
"the entry log files are rotated very frequently and small entry log files are produced".
The problem was introduced due to #1410.
At current entry logger, when a new entry log file is created, EntryLogger will notify its listeners
that a new entry log file is rotated via
onRotateEntryLog
.Before the change in #1410,
SortedLedgerStorage
inherits fromInterleavedLedgerStorage
.So when a new entry log file is rotated,
SortedLedgerStorage
is notified.However after the change in #1410,
SortedLedgerStorage
doesn't inheritsInterleavedLedgerStorage
anymore.Instead, the relationship is changed to composition.
SortedLedgerStorage
is composed using an interleaved ledgerstorage. So the entrylog listener contract was broken.
SortedLedgerStorage
will not receive anyonRotateEntryLog
notification any more.
Changes
When
SortedLedgerStorage
initializes, it passes its own entry log listener down to the interleaved ledger storage.So entry logger can notify the right person for entry log rotations.
Tests
Existing tests should cover most of the case. Looking for how to add new test cases.