apache / apache/pulsar-client-cpp

[Feature] Port SameAuthParamsLookupAutoClusterFailover from Java client to C++

Đang mở
#571 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
71
Fork
90
Merge trung bình
2 giờ 33 phút
Pull request đã merge (30 ngày)
3

Mô tả

## Motivation

The Java client introduced `SameAuthParamsLookupAutoClusterFailover` in apache/pulsar#23129 (merged August 2024, released in Pulsar 4.0.0 and backported to 3.0.7 / 3.3.2). This `ServiceUrlProvider` implementation addresses a well-known reliability gap in `AutoClusterFailover` that is particularly relevant to geo-replication deployments sitting behind a Pulsar Proxy.

**The problem with `AutoClusterFailover`**: its health probe is a raw TCP connection. In a typical deployment where a Pulsar Proxy fronts the brokers, the TCP probe succeeds as soon as the proxy accepts the connection — even if all brokers behind the proxy have crashed. This means `AutoClusterFailover` cannot detect broker-layer failure and may reconnect clients to a cluster that is not actually serving requests.

**What `SameAuthParamsLookupAutoClusterFailover` does differently**:
- Probes cluster health via a **topic lookup** (`getBroker()` on a configurable test topic) rather than a raw TCP connection. A broker that can respond to a lookup is demonstrably processing requests — the proxy cannot mask broker failure here.
- Introduces a **hysteresis state machine** with separate `failoverThreshold` and `recoverThreshold` counters (default 5 each), requiring consecutive failures before cutting over and consecutive successes before switching back. This prevents flapping without requiring a coarse `switchBackDelay` timer.
- Targets geo-replication topologies where all clusters share the same authentication credentials, which is the common case.

## Request

Port `SameAuthParamsLookupAutoClusterFailover` to the C++ client.

The `ServiceInfoProvider` interface is already part of the C++ public API (`include/pulsar/ServiceInfoProvider.h`), and `AutoClusterFailover` is already implemented against it — so the interface contract is defined and the pattern is established. The Java implementation ([`SameAuthParamsLookupAutoClusterFailover.java`](https://github.com/apache/pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/SameAuthParamsLookupAutoClusterFailover.java)) serves as a direct reference.

## Impact

The C++ client is the foundation for the Node.js client binding. Once `SameAuthParamsLookupAutoClusterFailover` is available in C++, it can be surfaced to Node.js consumers as well — a client language that currently has no automatic failover support at all.

This would bring C++ and Node.js deployments to parity with Java on the most important `AutoClusterFailover` reliability fix for proxy-fronted geo-replication clusters.

## References

- apache/pulsar#23129 — original Java implementation and motivation
- `include/pulsar/ServiceInfoProvider.h` — existing C++ interface
- `lib/AutoClusterFailover.cc` — existing C++ `AutoClusterFailover` implementation (reference for structure)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với lib/AutoClusterFailover.cc và include/pulsar/ServiceInfoProvider.h để hiểu cấu trúc C++ hiện có và hợp đồng giao diện, sau đó so sánh chúng với SameAuthParamsLookupAutoClusterFailover.java. Hoàn tất khi client C++ cung cấp cơ chế kiểm tra health được yêu cầu cho topic-lookup, các ngưỡng riêng biệt cho failover và recovery, cùng hành vi dùng chung cho các tham số xác thực.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
cpp, java
Lĩnh vực
distributed-systems
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
58/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.