{"record":{"id":"477184d0ecb60646","repo":"apache/pulsar","slug":"failed-to-init-bookieid-list","errorCode":null,"errorMessage":" failed to init BookieId list","messagePattern":" failed to init BookieId list","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMapping.java","lineNumber":121,"sourceCode":"                        MetadataStoreConfig.builder()\n                                .metadataStoreName(MetadataStoreConfig.METADATA_STORE)\n                                .sessionTimeoutMillis(zkTimeout)\n                                .build());\n            } catch (MetadataStoreException e) {\n                throw new MetadataException(Code.METADATA_SERVICE_ERROR, e);\n            }\n        }\n        return store;\n    }\n\n    @Override\n    public synchronized void setConf(Configuration conf) {\n        super.setConf(conf);\n        MetadataStore store;\n        try {\n            store = getMetadataStore(conf);\n        } catch (MetadataException e) {\n            throw new RuntimeException(METADATA_STORE_INSTANCE + \" failed to init BookieId list\");\n        }\n\n        bookieMappingCache = store.getMetadataCache(BookiesRackConfiguration.class);\n        store.registerListener(this::handleUpdates);\n\n        try {\n            var racksWithHost = bookieMappingCache.get(BOOKIE_INFO_ROOT_PATH)\n                    .thenApply(optRes -> optRes.orElseGet(BookiesRackConfiguration::new))\n                    .get();\n\n            for (var bookieMapping : racksWithHost.values()) {\n                for (String address : bookieMapping.keySet()) {\n                    bookieAddressListLastTime.add(BookieId.parse(address));\n                }\n                log.debug()\n                        .attr(\"bookieAddressListLastTime\", bookieAddressListLastTime)\n                        .log(\"BookieRackAffinityMapping init, bookieAddressListLastTime\");\n            }","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMapping.java#L103-L139","documentation":"BookieRackAffinityMapping.setConf calls getMetadataStore(conf); if that throws MetadataException (failed to create/connect the metadata store), setConf wraps it in a RuntimeException \"... failed to init BookieId list\". This makes the mapping fail fast at configuration time instead of silently serving empty rack data.","triggerScenarios":"setConf() invoked (by BookKeeper loading the RackawareEnsemblePlacementPolicy config) when the metadata service URI is unreachable, malformed, or the store client cannot be created.","commonSituations":"ZooKeeper down or wrong address in metadataServiceUri; invalid zkTimeout value; network/firewall blocking the metadata store port; bad scheme in metadataStoreUrl during migration to the metadata-store abstraction.","solutions":["Check broker logs for the underlying MetadataException and fix the metadata store URL/credentials/connectivity","Verify ZooKeeper or etcd is reachable from the broker (telnet the host:port)","Validate the metadataServiceUri scheme (metadata-store:zk:... ) and zkTimeout parseability, then restart"],"exampleFix":"// before\n// metadataServiceUri=metadata-store:zk:zk-bad-host:2181/ledgers\n// after\n// metadataServiceUri=metadata-store:zk:zk1:2181,zk2:2181,zk3:2181/ledgers","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    mapping.setConf(conf);\n} catch (RuntimeException e) {\n    log.error(\"failed to init bookie rack mapping\", e);\n    // check connectivity to the metadata store before retry/startup\n}","preventionTips":["Pre-flight check metadata store reachability at broker startup","Validate metadataServiceUri scheme and zkTimeout values","Monitor ZooKeeper/metadata backend health"],"tags":["metadata-store","initialization","zookeeper","connectivity"],"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"}