Repository navigation
feat: regard ProducerBlockedQuotaExceededException as retryable exception to continue to reconnect - #1457
Conversation
4de6a9f to
2c6d942
Compare
2c6d942 to
c5c3ffd
Compare
There was a problem hiding this comment.
Pull request overview
This pull request modifies the producer's reconnection behavior when encountering a ProducerBlockedQuotaExceededException. The change aligns the Go client with the Java client by treating this exception as retryable, allowing the producer to continue reconnecting after failing pending messages rather than closing the producer entirely.
Changes:
- Modified
producer_partition.goto remove early return whenProducerBlockedQuotaExceededExceptionis encountered, allowing reconnection to continue - Added test
TestProducerReconnectWhenBacklogQuotaExceedto verify the reconnection behavior - Updated golangci-lint version from v1.61.0 to v1.64.2
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| pulsar/producer_partition.go | Removed early return for ProducerBlockedQuotaExceededException to allow reconnection retry |
| pulsar/producer_test.go | Added test and custom backoff policy implementation to verify quota exceeded reconnection behavior |
| Makefile | Updated golangci-lint version to v1.64.2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
RobertIndie
left a comment
There was a problem hiding this comment.
PTAL comments from copilot. Thanks.
de206e1 to
70d6b0b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tion to continue to reconnect
70d6b0b to
1c5c317
Compare
…49933) ## Summary Bumps `pulsar-client-go` v0.17.0 → v0.19.0 to pick up [apache/pulsar-client-go#1457](apache/pulsar-client-go#1457): the client used to give up reconnecting after a topic hit the `producer_exception` backlog quota, leaving the producer permanently dead and writes timing out forever. v0.19.0 treats the quota exception as retryable, so producers recover once backlog clears. The bump can't ship alone: it's blocked at the module graph by Milvus's pinned `xiaofan-luan/pulsarctl v0.5.1` fork, which imports `pulsar-client-go/oauth2/store` — a package v0.19.0 has removed. MVS then pulls the legacy standalone `pulsar-client-go/oauth2` module back in, which collides with the main module's `oauth2/clock` (ambiguous import). To unblock cleanly, this PR also replaces the only ~50 lines of pulsarctl admin usage in Milvus with `pulsar-client-go`'s own `pulsaradmin` package (shipped in the same module). The legacy `99designs/{keyring,go-keychain}` and `danieljoos/wincred` transitive deps fall out as a side effect. ## Changes **Source (2 files, ~20 lines net)** - `pkg/mq/msgstream/mqwrapper/pulsar/pulsar_client.go` — `NewAdminClient` now returns `admin.Client` from `pulsaradmin/pkg/admin`, built from `config.Config` instead of `common.Config`. - `pkg/mq/msgstream/mq_factory.go` — `Subscriptions().Delete(*topic, sub, true)` → `ForceDelete(*topic, sub)` (pulsaradmin splits force-delete into its own method); error type assertion `cli.Error` → `rest.Error` (same `Reason` field). **Module hygiene (`pkg/go.mod`, `go.mod`)** - bump `apache/pulsar-client-go` v0.17.0 → v0.19.0 - drop `require github.com/streamnative/pulsarctl` - drop `replace streamnative/pulsarctl => xiaofan-luan/pulsarctl v0.5.1` - drop `exclude pulsar-client-go/oauth2 v0.0.0-20211108044248-...` (no longer needed; the standalone oauth2 module is no longer in the graph at all — `go list -m .../oauth2` ⇒ *not a known dependency*) ## Behavior notes v0.19.0 still calls `failPendingMessages` each time the producer reconnect hits the quota, so in-flight sends continue to fail with `ErrProducerBlockedQuotaExceeded` — upper-layer (msgstream / WAL) error surface is **unchanged**. What changes is that the producer no longer permanently dies and recovers automatically once backlog clears. API surface diff verified against Milvus's pulsar usage: no removed or renamed symbols; option structs only additively changed (`ConsumerOptions.NackPrecisionBit` added). v0.19.0 requires `go 1.24`; Milvus is on `go 1.25.8` — no Go version gate. issue: #49932 ## Test plan - [x] `go build ./...` in `pkg/` clean (with rocksdb pkg-config) - [x] `go vet -tags dynamic,test` clean on msgstream + walimpls/impls/pulsar - [x] pulsar test code compiles under `-tags dynamic,test -gcflags="all=-N -l"` - [x] Non-broker unit tests pass: `TestPulsarID_Serialize`, `TestPulsarID_Equal` - [x] `go list -m .../pulsar-client-go/oauth2` ⇒ `not a known dependency` (ambiguous-import root cause structurally resolved) - [ ] CI green - [ ] Broker-dependent unit tests pass against Pulsar 3.0.2 (matches milvus-helm `pulsarv3` subchart) - [ ] Pre-merge: induce `producer_exception` backlog quota in a staging cluster; verify producer recovers after backlog clears (independent reproduction already done out-of-tree) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: zhenshan.cao <[email protected]> Co-authored-by: Claude Opus 4.7 <[email protected]>
Fixes #1134
Master Issue: #1128
Motivation
Currently, the Go client handles connections in two ways:
grabCnx()method will not trigger retry logic. If an error occurs, it will be directly returned to the caller.runEventsLoop()method will detect the disconnection and call thereconnectToBroker()method to re-establish the connection. During reconnection, the method identifies whether the current exception is a retryable error. If it is a retryable error, theinternal.Retry()inside thereconnectToBroker()method will retry indefinitely based on the backoff strategy. If it is a non-retryable error, such as the currenterrMsgProducerBlockedQuotaExceededException, the partition producer will be closed, causing any following messages sent to that partition to result in aSendTimeoutError.Since the
backlogQuotaExceedExceptioncan be resolved by modifying the TTL or increasing consumption speed, it is likely to recover after some retry attempts. I believe the exception handling forerrMsgProducerBlockedQuotaExceededExceptionin thereconnectToBroker()method should align as closely as possible with the Java implementation. Java’s current retry logic for connections is as follows:handleSendError()is triggered to close the connection.connectionClosedmethod is called, which in turn invokes thegrabCnx()method, and subsequentlygrabCnx()calls theconnectionOpened()method to reconnect:connectionOpened()method, the client will execute different logic based on the current exception. For theProducerBlockedQuotaExceededExceptionexception, the Java client does not treat it as anisUnrecoverableError. Instead, it first cleans up the pending messages and then attempts to reconnect.Modifications
errMsgProducerBlockedQuotaExceededExceptionis encountered inreconnectToBroker(), onlyfailPendingMessages()should be executed, but the connection should not be closed. Specifically, the code should be modified as follows:Verifying this change
This change added tests and can be verified as follows:
TestProducerReconnectWhenBacklogQuotaExceedDoes this pull request potentially affect one of the following parts:
Documentation