Repository navigation
Ingester client: release the gRPC connection when stream setup fails - #7969
arpitjain099 wants to merge 2 commits into
Conversation
a3072da to
e3bef13
Compare
SungJin1212
left a comment
There was a problem hiding this comment.
Code is LGTM, I left an one nit.
| * [BUGFIX] Querier: Increment `cortex_query_evictions_total` and deregister the victim before cancelling it in the query evictor, fixing double-counted evictions of still-unwinding queries. #7616 | ||
| * [BUGFIX] Ring: Ignore READONLY ingesters when assigning tokens so the active series remain balanced. #7946 | ||
| * [BUGFIX] Distributor: Fix a `panic: send on closed channel` crash during shutdown when `-distributor.num-push-workers` or `-distributor.num-query-workers` is greater than 0. #7964 | ||
| * [BUGFIX] Ingester Client: Fix a gRPC connection leak when `-distributor.use-stream-push` is enabled. A client whose push streams could not be opened was discarded without closing its connection or cancelling its stream context, and because the client pool only records a client once the factory has succeeded, nothing could close it afterwards. Each failure left a connection reconnecting to the ingester address for the lifetime of the process, and the failures cluster while an address is still in the ring but already unreachable. The error the stream workers report is also no longer written to a plain variable from all of them concurrently. #7969 |
There was a problem hiding this comment.
Could you rewrite a changelog? It's feel like an internal implementation, not the user-facing changes..
| * [BUGFIX] Ingester Client: Fix a gRPC connection leak when `-distributor.use-stream-push` is enabled. A client whose push streams could not be opened was discarded without closing its connection or cancelling its stream context, and because the client pool only records a client once the factory has succeeded, nothing could close it afterwards. Each failure left a connection reconnecting to the ingester address for the lifetime of the process, and the failures cluster while an address is still in the ring but already unreachable. The error the stream workers report is also no longer written to a plain variable from all of them concurrently. #7969 | |
| * [BUGFIX] Ingester Client: Fix a gRPC connection leak when `-distributor.use-stream-push` is enabled and the push streams to an ingester cannot be opened. #7969 |
There was a problem hiding this comment.
@SungJin1212 Taken verbatim, thank you. Yours is better scoped than mine, which described the mechanism rather than the user-facing effect.
There was a problem hiding this comment.
@SungJin1212 Fixed. It was stringsseq at client_test.go:416, now ranging over strings.SplitSeq. The package passes locally, 22 tests, and the lint job should confirm it.
sandy2008
left a comment
There was a problem hiding this comment.
Closing the connection on the Run error releases the started workers and the reconnect loop. The new test fails on master and passes here with -race. CHANGELOG.md needs a rebase. LGTM.
|
@arpitjain099 |
MakeIngesterClient returned the error from Run without closing the connection or cancelling the stream context, so a discarded client left a connection reconnecting to the ingester address for the lifetime of the process. Nothing could reach it, because ring/client.Pool only records a client once the factory has succeeded. Run also stored the workers' error in a plain variable written by all of them concurrently, which the race detector reports. Co-Authored-By: Claude <[email protected]> Signed-off-by: Arpit Jain <[email protected]>
Co-Authored-By: Claude <[email protected]> Signed-off-by: Arpit Jain <[email protected]>
f4b1509 to
18681d4
Compare
|
@SungJin1212 Rebased on master and resolved the CHANGELOG conflict, so the entry now sits after #7976 in the unreleased block. Re-ran the new test with |
What this PR does:
With
-distributor.use-stream-pushenabled,MakeIngesterClientopens the gRPC connection before it starts the push-stream workers. If starting them fails it returns the error without closing that connection or cancelling the stream context.ring/client.Poolonly records a client after the factory succeeds, so nothing is left holding the connection and nothing can ever close it, and its reconnect loop keeps dialing the ingester address until the process exits. The failures cluster while an ingester's address is still in the ring but already unreachable, so each rollout leaks a burst of them, and a querier reaches the same factory from the read path.The error path now cancels the stream context and closes the connection.
Runalso collected the workers' error in a plain variable written by all 100 of them, whichgo test -racereports, so it is now anatomic.Erroras inpkg/ring/batch.go.The new test drives
MakeIngesterClientagainst an address that refuses connections and fails on master.I used Claude Code while preparing this, and I have reviewed and tested the change myself.
Which issue(s) this PR fixes:
Fixes #7759
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags