apache / apache/pulsar

[Bug] broker cannot connect the bookie when bookieId set hostname

Open
#18,899 5 comments 0 reactions 0 assignees View on GitHub
Stale type/bug
Dominant language
Java
Stars
15.3k
Forks
3.8k
Avg merge
1d 14h
Merged PRs (30d)
160

Description

### Search before asking

- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.

### Version

2.10.2

### Minimal reproduce step

With zookeeper deployed, bookieId is set to hostname, and the broker cannot connect to bookie

===============================================================
My preliminary analysis is that in the scenario of Zookeeper deployment, the broker should need to use zk to get the IP of Bookie

In the following function, DNS is directly applied to resolve IP, and there is no support for zk
```
public BookieSocketAddress(String addr) throws UnknownHostException {
String[] parts = addr.split(COLON);
if (parts.length < 2) {
throw new UnknownHostException(addr);
}
this.hostname = parts[0];

try {
this.port = Integer.parseInt(parts[1]);
} catch (NumberFormatException nfe) {
throw new UnknownHostException(addr);
}

if (InetAddresses.isInetAddress(hostname)) {
socketAddress = Optional.of(new InetSocketAddress(hostname, port));
} else {
socketAddress = Optional.empty();
}
}
```

### What did you expect to see?

broker should connect the bookie when bookieId set with hostname

### What did you see instead?

N/A

### Anything else?

N/A

### Are you willing to submit a PR?

- [X] I'm willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Start with the BookieSocketAddress constructor shown in the report and trace how the broker resolves a bookieId when it is a hostname. Review the ZooKeeper-based bookie metadata path and the broker-to-bookie connection flow. Done means a broker can connect when bookieId uses a hostname, with coverage for the reported 2.10.2 scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.