Skip to content

[Bug] pulsar 4.0.4 Unable to start broker #24312

Closed

Description

@HGHNice

Search before reporting

  • 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

Image

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.

Additional information

null

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added
    type/bug
    on May 16, 2025
  2. HGHNice commented on May 16, 2025

    @HGHNice
    Author

    I've used bin-pulsar initialize-cluster-metadata normally for initialization

  3. Shawyeok commented on May 19, 2025

    @Shawyeok
    Contributor

    The brokerId is initialized after the BrokerService has started.

    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?

    @HGHNice

  4. HGHNice commented on May 19, 2025

    @HGHNice
    Author

    The brokerId is initialized after the BrokerService has started.

    pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java

    Lines 940 to 942 in eccc6b6

    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.

    pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java

    Lines 2535 to 2539 in eccc6b6

    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?

    @HGHNice

    Can be opened PR ~

  5. lhotari commented on May 27, 2025

    @lhotari
    Member

    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.

  6. lhotari commented on May 27, 2025

    @lhotari
    Member

    @Shawyeok @nodece A simple fix would be to replace if (!pulsar.isRunning()) { with if (pulsar.getState() != PulsarService.State.Started) { at

    .

  7. nodece commented on May 28, 2025

    @nodece
    Member

    @lhotari I overlooked that dynamic ports(0). #24352 has been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions