You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "horizonzy (via GitHub)" <gi...@apache.org> on 2023/09/04 04:24:15 UTC
[GitHub] [pulsar] horizonzy commented on pull request #21096: [fix] [broker] Fix isolated group not work problem.
horizonzy commented on PR #21096:
URL: https://github.com/apache/pulsar/pull/21096#issuecomment-1704590008
> ```java
>
> ```
> I would like to provide another approach for handling the cached rack configuration update.
>
> 1. Make allGroupsBookieMapping as a `volatile` variable
> 2. Update the cached rack configuration async
>
> initialize
>
> ```java
> bookieMappingCache.get(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH).thenAccept(opt -> {
> opt.ifPresent(bookiesRackConfiguration -> cachedRackConfiguration = bookiesRackConfiguration);
> }).exceptionally(ex -> {
> log.warn("Failed to load bookies rack configuration while initialize the PlacementPolicy.");
> return null;
> });
> ```
>
> getExcludedBookiesWithIsolationGroups
>
> ```java
> CompletableFuture<Optional<BookiesRackConfiguration>> future =
> bookieMappingCache.get(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH);
>
> BookiesRackConfiguration allGroupsBookieMapping;
> future.thenAccept(opt ->
> opt.ifPresent(bookiesRackConfiguration -> cachedRackConfiguration = bookiesRackConfiguration)
> ).exceptionally(ex -> {
> log.warn("The newest bookie rack config is not available now.");
> return null;
> });
> allGroupsBookieMapping = cachedRackConfiguration;
> if (allGroupsBookieMapping == null) {
> return excludedBookies;
> }
> ```
>
> When the broker restarts, we might lose the rack configurations, but it can avoid any potential deadlocks.
>
> The initialize method is called when starting the broker before the broker service becomes available to the client. So we will not lose the bookie rack configuration in most cases.
It makes sense, we should print a debug log when the allGroupsBookieMapping is null.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org