You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched in the issues and found nothing similar.
Read release policy
I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.
User environment
pulsar 4.0.4
Issue Description
Error messages
unable get broker id
Reproducing the issue
The apache-pulsar-4.0.4-bin.tar.gz used, and it was found that the deployment was completed. The last step was to start the broker and it could not start normally.
The reproduction step is: execute it once according to the document. Start broker and report an error in the last step.
// Ignore metadata changes when broker is not running
log.info("Ignoring metadata change since broker is not running (id={}, state={}) {}", pulsar.getBrokerId(),
pulsar.getState(), n);
return;
To avoid this race condition, we could initialize the brokerId earlier in the startup process, Would you be interested in opening a PR to address this?
this.brokerId =
String.format("%s:%s", advertisedAddress, config.getWebServicePort()
.or(config::getWebServicePortTls).orElseThrow());
So there's a chance the broker could receive a metadata change event before brokerId is initialized.
if (!pulsar.isRunning()) {
// Ignore metadata changes when broker is not running
log.info("Ignoring metadata change since broker is not running (id={}, state={}) {}", pulsar.getBrokerId(),
pulsar.getState(), n);
return;
To avoid this race condition, we could initialize the brokerId earlier in the startup process, Would you be interested in opening a PR to address this?
To avoid this race condition, we could initialize the brokerId earlier in the startup process, Would you be interested in opening a PR to address this?
This is intentionally done late since when using dynamic ports (0), the port number isn't available before the server has started. An alternative fix would be to pause metadata change handling until the broker has started. There's already a solution to not serve incoming requests until server has started, but the metadata changes weren't covered.
Activity
HGHNice commentedon May 16, 2025
I've used bin-pulsar initialize-cluster-metadata normally for initialization
Shawyeok commentedon May 19, 2025
The
brokerIdis initialized after the BrokerService has started.pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
Lines 940 to 942 in eccc6b6
So there's a chance the broker could receive a metadata change event before
brokerIdis initialized.pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Lines 2535 to 2539 in eccc6b6
To avoid this race condition, we could initialize the
brokerIdearlier in the startup process, Would you be interested in opening a PR to address this?@HGHNice
HGHNice commentedon May 19, 2025
Can be opened PR ~
lhotari commentedon May 27, 2025
This is intentionally done late since when using dynamic ports (
0), the port number isn't available before the server has started. An alternative fix would be to pause metadata change handling until the broker has started. There's already a solution to not serve incoming requests until server has started, but the metadata changes weren't covered.lhotari commentedon May 27, 2025
@Shawyeok @nodece A simple fix would be to replace
if (!pulsar.isRunning()) {withif (pulsar.getState() != PulsarService.State.Started) {atpulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
Line 2535 in 397b021
nodece commentedon May 28, 2025
@lhotari I overlooked that dynamic ports(0). #24352 has been updated.