{"record":{"id":"9d7c830b591295a5","repo":"apache/pulsar","slug":"failed-initialized","errorCode":null,"errorMessage":" failed initialized","messagePattern":" failed initialized","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicy.java","lineNumber":99,"sourceCode":"     */\n    @Getter\n    @VisibleForTesting\n    private volatile CompletableFuture<Void> initialRackConfigurationLoadFuture =\n            CompletableFuture.completedFuture(null);\n\n    public IsolatedBookieEnsemblePlacementPolicy() {\n        super();\n    }\n\n    @Override\n    public RackawareEnsemblePlacementPolicyImpl initialize(ClientConfiguration conf,\n            Optional<DNSToSwitchMapping> optionalDnsResolver, HashedWheelTimer timer, FeatureProvider featureProvider,\n            StatsLogger statsLogger, BookieAddressResolver bookieAddressResolver) {\n        MetadataStore store;\n        try {\n            store = BookieRackAffinityMapping.getMetadataStore(conf);\n        } catch (MetadataException e) {\n            throw new RuntimeException(METADATA_STORE_INSTANCE + \" failed initialized\");\n        }\n        Set<String> primaryIsolationGroups = new HashSet<>();\n        Set<String> secondaryIsolationGroups = new HashSet<>();\n        if (conf.getProperty(ISOLATION_BOOKIE_GROUPS) != null) {\n            String isolationGroupsString = ConfigurationStringUtil\n                    .castToString(conf.getProperty(ISOLATION_BOOKIE_GROUPS));\n            if (!isolationGroupsString.isEmpty()) {\n                Collections.addAll(primaryIsolationGroups, isolationGroupsString.split(\",\"));\n            }\n            // Only add the bookieMappingCache if we have defined an isolation group\n            bookieMappingCache = store.getMetadataCache(BookiesRackConfiguration.class);\n            CompletableFuture<Void> rackConfigurationLoad = bookieMappingCache\n                    .get(BookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH).thenAccept(opt -> opt.ifPresent(\n                            bookiesRackConfiguration -> cachedRackConfiguration = bookiesRackConfiguration));\n            // Initialization continues when the load fails; isolation is simply not applied until a later refresh.\n            rackConfigurationLoad.exceptionally(e -> {\n                log.warn().exception(e)\n                        .log(\"Failed to load bookies rack configuration while initialize the PlacementPolicy.\");","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicy.java#L81-L117","documentation":"IsolatedBookieEnsemblePlacementPolicy.initialize obtains the metadata store via BookieRackAffinityMapping.getMetadataStore(conf); on MetadataException it throws RuntimeException \"... failed initialized\", aborting policy initialization because rack data cannot be loaded without the store.","triggerScenarios":"Ensemble placement policy initialization with a BookKeeper configuration whose metadata service is unreachable or misconfigured (same root cause as the mapping's init failure).","commonSituations":"Broker starting against an unavailable ZooKeeper; misconfigured metadataServiceUri when using bookkeeper rack awareness; CI/test environments without a metadata backend.","solutions":["Ensure the metadata store URI in the BK client config is valid and reachable before starting the broker","Inspect the underlying MetadataException stack trace for connection vs. parsing issues","In tests, inject a METADATA_STORE_INSTANCE (e.g. MockMetadataStore) instead of relying on a live service"],"exampleFix":"// before\nconf.setProperty(ISOLATION_BOOKIE_GROUPS, \"group-a\"); // no metadata source\n// after\nconf.setProperty(\"metadataServiceUri\", \"metadata-store:zk:zk1:2181/ledgers\");\nconf.setProperty(ISOLATION_BOOKIE_GROUPS, \"group-a\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    policy.initialize(conf, optionalDnsResolver, timer, featureProvider, statsLogger, bookieAddressResolver);\n} catch (RuntimeException e) {\n    log.error(\"isolation policy init failed: check metadata store\", e);\n}","preventionTips":["Ensure metadata store URI is configured and reachable before enabling rack awareness","Inject a METADATA_STORE_INSTANCE in unit tests","Keep isolation group config valid strings"],"tags":["placement-policy","metadata-store","initialization"],"backgroundTag":"metadata-store-init-failed","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}