StevenLuMT commented on code in PR #3522:
URL: https://github.com/apache/bookkeeper/pull/3522#discussion_r992084824
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieImpl.java:
##########
@@ -935,9 +936,10 @@ private void addEntryInternal(LedgerDescriptor handle,
ByteBuf entry,
// journal `addEntry` should happen after the entry is added to ledger
storage.
// otherwise the journal entry can potentially be rolled before the
ledger is created in ledger storage.
- if (masterKeyCache.get(ledgerId) == null) {
+ if (masterKeyCache.getIfPresent(ledgerId) == null) {
// Force the load into masterKey cache
- byte[] oldValue = masterKeyCache.putIfAbsent(ledgerId, masterKey);
+ byte[] oldValue = masterKeyCache.getIfPresent(ledgerId);
+ masterKeyCache.put(ledgerId, masterKey);
if (oldValue == null) {
Review Comment:
> Good point. I have a question. Is there any problem if the
`masterKeyCahce` cache is evicted during `readJournal`? I don't see the role of
`masterKeyCache` in this process.
@wenbingshen
The main role of masterKeyCache:
1. When addEntry, synchronize a piece of METAENTRY_ID_LEDGER_KEY data, you
need masterKeyCache to write only one piece of this data for each ledgerID
2. When the bookie is restarted and the journal is doing data replay, for
METAENTRY_ID_LEDGER_KEY, the following operations are done: restore
masterKeyCache, restore HandleFactory
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]