apache / apache/pulsar

[improve][broker]PIP-340 Optimization of Probe Implementation for Automatic Failover

Open
#22,134 0 comments 0 reactions 0 assignees View on GitHub
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.

### Motivation

he current Java client implementation has certain flaws in automatic fault switching.
```
org.apache.pulsar.client.impl.AutoClusterFailover.java
boolean probeAvailable(String url) {
try {
resolver.updateServiceUrl(url);
InetSocketAddress endpoint = resolver.resolveHost();
Socket socket = new Socket();
socket.connect(new InetSocketAddress(endpoint.getHostName(), endpoint.getPort()), TIMEOUT);
socket.close();

return true
} catch (Exception e) {
log.warn("Failed to probe available, url: {}", url, e);
return false;
}
}
```
The client only establishes a TCP connection with the exposed connection address of the cluster to determine whether the cluster is available, which cannot adapt to scenarios where the cluster is partially unavailable (half dead). In this scenario, we hope to make corresponding fault switching judgments by initiating cluster health status requests to the cluster. Then within the cluster, we provide an admin management command to update the cluster's health status. To avoid this scenario, all businesses that need to connect to this cluster need to manually switch cluster connection addresses and restart applications, resulting in inconsistent link data among multiple business team due to inconsistent operation steps.

### Solution

_No response_

### Alternatives

_No response_

### Anything else?

_No response_

### Are you willing to submit a PR?

- [X] I'm willing to submit a PR!
PR: https://github.com/apache/pulsar/pull/22133

Contributor guide

Open the contributing guide

Research direction

Start with org.apache.pulsar.client.impl.AutoClusterFailover.java and its probeAvailable(String url) method, then review PR 22133. Determine how cluster health requests and the proposed admin health-status update should support failover decisions beyond a TCP connection; done should be demonstrated by tests covering partially unavailable clusters.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.