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

Skip sync the RocksDB when no changes #3904

Merged

Conversation

hangc0276
Copy link
Contributor

Motivation

For the LedgerMetadataIndex#removeDeletedLedgers and LedgerMetadataIndex#flush, it will call ledgersDB sync whether the ledgersDB has changed or not. We can skip the sync call when nothing changed in the ledgersDB.

Changes

  • Check whether pendingLedgersUpdates is empty in flush() and pendingDeletedLedgers is empty in removeDeletedLedgers
  • Move the key.recycle() in finally to cover keys leak when the ledgersDB operations throw an exception.

Copy link
Member

@horizonzy horizonzy left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@wenbingshen wenbingshen left a comment

Choose a reason for hiding this comment

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

LGTM

@zymap
Copy link
Member

zymap commented Dec 4, 2023

@hangc0276 Do you want to update this PR to merge?

@hangc0276 hangc0276 merged commit 24464ba into apache:master Jan 8, 2024
16 checks passed
hangc0276 added a commit to hangc0276/bookkeeper that referenced this pull request Jan 18, 2024
Co-authored-by: Matteo Merli <mmerli@apache.org>
### Motivation
For the `LedgerMetadataIndex#removeDeletedLedgers` and `LedgerMetadataIndex#flush`, it will call ledgersDB sync whether the ledgersDB has changed or not. We can skip the sync call when nothing changed in the ledgersDB.

### Changes
- Check whether pendingLedgersUpdates is empty in `flush()` and `pendingDeletedLedgers` is empty in removeDeletedLedgers
- Move the `key.recycle()` in finally to cover keys leak when the ledgersDB operations throw an exception.

(cherry picked from commit 24464ba)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants