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

[improve][broker] Cache LedgerHandle in BookkeeperBucketSnapshotStorage #20117

Merged
merged 8 commits into from
Apr 20, 2023

Conversation

coderzc
Copy link
Member

@coderzc coderzc commented Apr 17, 2023

PIP: #16763

Motivation

#20111 (review)

Modifications

Cache this ledger in BookkeeperBucketSnapshotStorage

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@coderzc coderzc requested a review from mattisonchao April 17, 2023 12:18
@coderzc coderzc self-assigned this Apr 17, 2023
@coderzc coderzc added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages area/broker labels Apr 17, 2023
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Apr 17, 2023
@coderzc coderzc changed the title [improve][broker] Cache this ledger in BookkeeperBucketSnapshotStorage [improve][broker] Cache LedgerHandle in BookkeeperBucketSnapshotStorage Apr 17, 2023
@coderzc coderzc force-pushed the improve_bucket_storage_cache branch from db05856 to f7c23e6 Compare April 17, 2023 12:24
@coderzc coderzc force-pushed the improve_bucket_storage_cache branch from f7c23e6 to 00f09a9 Compare April 17, 2023 12:38
@coderzc coderzc requested review from eolivelli and Technoboy- April 17, 2023 12:39
@coderzc coderzc added this to the 3.0.0 milestone Apr 17, 2023
}

@Override
public CompletableFuture<Void> deleteBucketSnapshot(long bucketId) {
ledgerHandleCache.remove(bucketId);
Copy link
Member

Choose a reason for hiding this comment

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

We should close this handle here.

future.complete(handle);
}
}, null, metadata);
return future;
}

private CompletableFuture<LedgerHandle> getLedgerHandle(Long ledgerId) {
LedgerHandle ledgerHandle = ledgerHandleCache.get(ledgerId);
Copy link
Member

Choose a reason for hiding this comment

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

There is a race condition, you should consider use compute here.

case: read - if -modify

Copy link
Member

@mattisonchao mattisonchao left a comment

Choose a reason for hiding this comment

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

Left some comments here.

@@ -186,6 +178,10 @@ private CompletableFuture<LedgerHandle> openLedger(Long ledgerId) {
LedgerPassword,
(rc, handle, ctx) -> {
if (rc != BKException.Code.OK) {
ledgerHandleFutureCache.remove(ledgerId, future);
Copy link
Member

Choose a reason for hiding this comment

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

If the future is complete like sync, may it cause a deadlock?

@coderzc coderzc force-pushed the improve_bucket_storage_cache branch from a90c93c to 4d0b405 Compare April 18, 2023 12:51
@coderzc coderzc force-pushed the improve_bucket_storage_cache branch from 4d0b405 to 2a65382 Compare April 18, 2023 12:51
@cbornet
Copy link
Contributor

cbornet commented Apr 18, 2023

@coderzc we're in code freeze for 3.0. Is this a blocker or fixing a regression from 2.11 ? Otherwise I suggest to move this to 3.1 milestone.

@cbornet cbornet modified the milestones: 3.0.0, 3.1.0 Apr 18, 2023
@coderzc
Copy link
Member Author

coderzc commented Apr 19, 2023

@coderzc we're in code freeze for 3.0. Is this a blocker or fixing a regression from 2.11 ? Otherwise I suggest to move this to 3.1 milestone.

OK, it can be moved to 3.1

@coderzc coderzc merged commit d3fa998 into apache:master Apr 20, 2023
coderzc added a commit that referenced this pull request Apr 20, 2023
cbornet added a commit that referenced this pull request Apr 24, 2023
poorbarcode pushed a commit that referenced this pull request May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker cherry-picked/branch-3.0 doc-not-needed Your PR changes do not impact docs ready-to-test release/3.0.1 type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants