Skip to content

Skip sync the RocksDB when no changes#3904

Merged
hangc0276 merged 2 commits intoapache:masterfrom
hangc0276:chenhang/skip_sync_rocksdb_when_no_changes
Jan 8, 2024
Merged

Skip sync the RocksDB when no changes#3904
hangc0276 merged 2 commits intoapache:masterfrom
hangc0276:chenhang/skip_sync_rocksdb_when_no_changes

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
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)
Ghatage pushed a commit to sijie/bookkeeper that referenced this pull request Jul 12, 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.
lhotari pushed a commit that referenced this pull request Apr 17, 2025
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.

6 participants

Comments