feat(grpc-gcp): penalize retryable channel errors - #14219
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces an error penalty mechanism for channels experiencing retryable errors (such as UNAVAILABLE or RESOURCE_EXHAUSTED). It adds configuration options for the penalty step and duration, tracks individual and aggregate penalty loads, and incorporates these penalties into the channel load calculations and scale-up signaling. Additionally, a comprehensive test suite has been added to verify the correctness of the error penalty logic under various scenarios. I have no feedback to provide.
| if (!useDifferentChannel && channelRef != null && !channelRef.getChannel().isShutdown()) { | ||
| return channelRef; | ||
| } |
There was a problem hiding this comment.
This does not take any error penalty into account. For read/write transactions, that is maybe (probably) the right choice. But for read-only transactions, where channel affinity is just a 'nice-to-have', it is probably not the right choice.
There was a problem hiding this comment.
yes but that means we need to send transaction type info here which will be beyond the scope of this PR, can be done in follow-up PR
| || errorPenaltyDuration.isZero() | ||
| || errorPenaltyDuration.isNegative() | ||
| || (status.getCode() != Code.UNAVAILABLE | ||
| && status.getCode() != Code.RESOURCE_EXHAUSTED)) { |
There was a problem hiding this comment.
Should we indiscriminately apply errors for all RESOURCE_EXHAUSTED errors? Or only the ones that include certain metadata? (e.g. a RetryInfo)
There was a problem hiding this comment.
In design review it was agreed that we will apply for all RESOURCE_EXHAUSTED errors so want to keep same here
4524b24 to
993773c
Compare
olavloite
left a comment
There was a problem hiding this comment.
LGTM, except for the configuration option setters.
(Also do a recheck whether the PR description is up to date with the implementation)
993773c to
f2e9cae
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces an error penalty mechanism to the GCP Managed Channel pool. When retryable errors (such as UNAVAILABLE or RESOURCE_EXHAUSTED) occur on a channel, a decaying load penalty is applied to that channel. This penalty is added to the active stream count to compute the "picker load", which is then used by the channel selection strategies to steer traffic away from degraded channels. The PR also adds configuration options for the penalty step and duration, updates the scale-up and scale-down logic to account for these penalties, and includes comprehensive unit tests. There are no review comments, so I have no feedback to provide.
With dynamic scaling enabled, a channel returning retryable errors (UNAVAILABLE / RESOURCE_EXHAUSTED) kept its low active-stream count and so kept attracting picks: the pool had no signal that a channel was unhealthy until its streams actually piled up, and scale-up never triggered for a pool that was failing rather than busy.
Change
errorPenaltyStep(new pool option) of synthetic load to that channel forerrorPenaltyDuration, capped atmaxRpcPerChannel. The picker sees the penalty throughgetPickerLoad(), steering new picks toward healthy channels; expiry is lazy and lock-free.