Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,31 @@ public CompletableFuture<Versioned<BookieServiceInfo>> getBookieServiceInfo(Book
if (info != null) {
return completedFuture(info);
} else {
return FutureUtils.exception(new BKException.BKBookieHandleNotAvailableException());
// In some scenarios, if the watch event of bookie changed fails to execute and leads to
// cache update failure. There is a phenomenon where the bookie is running normally and
// there is also bookie information on the metadata store, but the cache doesn't have it.
// So, we need to update cache manually.
// The purpose of use synchronized updating is to avoid multiple requests being sent to the metadata server.
synchronized (this) {
if ((info = writableBookieInfo.get(bookieId)) == null) {
log.warn("Bookie {} not found from all cache, now update writableBookieInfo cache "
+ "and then try to get from writableBookieInfo cache.", bookieId);
readBookieInfoAsWritableBookie(bookieId);
Copy link
Member

Choose a reason for hiding this comment

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

readBookieInfoAsWritableBookie returns a future so this doesn't seem to be the correct approach here. It would be necessary to use asynchronous callback chaining using CompletableFuture's .then* methods.

info = writableBookieInfo.get(bookieId);
if (info == null) {
log.warn("Bookie {} not found from writableBookieInfo cache, now update readOnlyBookieInfo "
+ "cache and then try to get from readOnlyBookieInfo cache.", bookieId);
readBookieInfoAsReadonlyBookie(bookieId);
info = readOnlyBookieInfo.get(bookieId);
}
}
}
if (info != null) {
return completedFuture(info);
} else {
log.error("Bookie {} not found from all cache, maybe it's not ready or shutdown.", bookieId);
return FutureUtils.exception(new BKException.BKBookieHandleNotAvailableException());
}
}
}

Expand Down
Loading