-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
This reverts commit 4e54007.
db05856
to
f7c23e6
Compare
f7c23e6
to
00f09a9
Compare
} | ||
|
||
@Override | ||
public CompletableFuture<Void> deleteBucketSnapshot(long bucketId) { | ||
ledgerHandleCache.remove(bucketId); |
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 should close this handle here.
...r/src/main/java/org/apache/pulsar/broker/delayed/bucket/BookkeeperBucketSnapshotStorage.java
Outdated
Show resolved
Hide resolved
future.complete(handle); | ||
} | ||
}, null, metadata); | ||
return future; | ||
} | ||
|
||
private CompletableFuture<LedgerHandle> getLedgerHandle(Long ledgerId) { | ||
LedgerHandle ledgerHandle = ledgerHandleCache.get(ledgerId); |
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.
There is a race condition, you should consider use compute
here.
case: read - if -modify
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.
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); |
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.
If the future is complete like sync, may it cause a deadlock?
a90c93c
to
4d0b405
Compare
4d0b405
to
2a65382
Compare
@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 |
PIP: #16763
Motivation
#20111 (review)
Modifications
Cache this ledger in BookkeeperBucketSnapshotStorage
Verifying this change
(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:)
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: