Repository navigation
Conversation
ClientImpl::onRespValue() used to only ASSERT that a request was outstanding and then call pending_requests_.front(). When an upstream sent a reply while the pending request list was empty, a surplus or unsolicited reply, a release build read the std::list sentinel as a PendingRequest and crashed (fault address 0x3ff in our case). Stock v1.39.3 reproduces it with an upstream that answers one command with two replies. The RESP3 change (envoyproxy#44936) added a guard that drops such a frame, but its comment and its only test cover a HELLO 3 init callback that closes the connection. Nothing tests the surplus or unsolicited reply on an established connection, and the crash fix has no release note. Broaden the comment, add a bug fix release note, and add three RedisClientImplTest cases (unsolicited reply, surplus reply in the same buffer, reply after a user callback closed the client) and two RedisProxyIntegrationTest cases that send a surplus reply in the same write and an unsolicited reply through the real decoder. They check that the reply is dropped, that the upstream connection stays open without a protocol error, and that the next command on it gets its own reply. Signed-off-by: William Dauchy <[email protected]> Signed-off-by: Henry Wang <[email protected]>
Contributor
Author
|
/retest |
wdauchy
marked this pull request as ready for review
October 11, 2026 13:54
botengyao
approved these changes
Oct 12, 2026
botengyao
left a comment
Member
There was a problem hiding this comment.
thanks for the test improvement!
gavin-jeong
added a commit
to sendbird/envoy
that referenced
this pull request
Oct 15, 2026
Upstream already fixed this. The guard landed on main in envoyproxy#44936 and envoyproxy#48205 added tests for it three days ago; that PR reproduces the crash exactly as we did, with "a fake upstream that answers one command with two replies". So this is a backport, not an original fix, and it should look like the thing it is backporting. Three changes from the first version: - The comment no longer claims upstream cannot reach this path. That was wrong, and measurably so: stock istio/proxyv2:1.31.1, with no Sendbird patches and no pub/sub, restarted twice in four rounds against a double-replying server while the patched build stayed at zero. The claim came from checking only one way in (subscribe is absent from upstream's command lists) and concluding there were none. - No stat is incremented. Upstream only logs. A counter here would be a permanent fork delta on a hunk that should dissolve the next time envoy moves -- which is the entire reason to match the text. - The tests are upstream's UnsolicitedReplyIsDropped, which asserts more than mine did: the connection stays Open, no protocol error is counted, and a subsequent request still completes, so a dropped frame cannot have shifted pending_requests_. The command-stats variant stays because this pin takes a different path there (command_ is a non-owning StatName that aborts in SymbolTable::fromSymbol once popped), and disabling command stats was measured not to be a workaround. Upstream also drops RESP3 Push frames ahead of this check. That cannot be ported: this pin's RespType has no Push member. release/v1.36 through release/v1.39 are still affected upstream and no backport PR is open yet. ae1505b (v1.39.2-dev) is in that range.
Merged
1 task done
gavin-jeong
added a commit
to sendbird/envoy
that referenced
this pull request
Oct 15, 2026
Upstream already fixed this. The guard landed on main in envoyproxy#44936 and envoyproxy#48205 added tests for it three days ago; that PR reproduces the crash exactly as we did, with "a fake upstream that answers one command with two replies". So this is a backport, not an original fix, and it should look like the thing it is backporting. Three changes from the first version: - The comment no longer claims upstream cannot reach this path. That was wrong, and measurably so: stock istio/proxyv2:1.31.1, with no Sendbird patches and no pub/sub, restarted twice in four rounds against a double-replying server while the patched build stayed at zero. The claim came from checking only one way in (subscribe is absent from upstream's command lists) and concluding there were none. - No stat is incremented. Upstream only logs. A counter here would be a permanent fork delta on a hunk that should dissolve the next time envoy moves -- which is the entire reason to match the text. - The tests are upstream's UnsolicitedReplyIsDropped, which asserts more than mine did: the connection stays Open, no protocol error is counted, and a subsequent request still completes, so a dropped frame cannot have shifted pending_requests_. The command-stats variant stays because this pin takes a different path there (command_ is a non-owning StatName that aborts in SymbolTable::fromSymbol once popped), and disabling command stats was measured not to be a workaround. Upstream also drops RESP3 Push frames ahead of this check. That cannot be ported: this pin's RespType has no Push member. release/v1.36 through release/v1.39 are still affected upstream and no backport PR is open yet. ae1505b (v1.39.2-dev) is in that range.
gavin-jeong
added a commit
to sendbird/envoy
that referenced
this pull request
Oct 15, 2026
Upstream already fixed this. The guard landed on main in envoyproxy#44936 and envoyproxy#48205 added tests for it three days ago; that PR reproduces the crash exactly as we did, with "a fake upstream that answers one command with two replies". So this is a backport, not an original fix, and it should look like the thing it is backporting. Three changes from the first version: - The comment no longer claims upstream cannot reach this path. That was wrong, and measurably so: stock istio/proxyv2:1.31.1, with no Sendbird patches and no pub/sub, restarted twice in four rounds against a double-replying server while the patched build stayed at zero. The claim came from checking only one way in (subscribe is absent from upstream's command lists) and concluding there were none. - No stat is incremented. Upstream only logs. A counter here would be a permanent fork delta on a hunk that should dissolve the next time envoy moves -- which is the entire reason to match the text. - The tests are upstream's UnsolicitedReplyIsDropped, which asserts more than mine did: the connection stays Open, no protocol error is counted, and a subsequent request still completes, so a dropped frame cannot have shifted pending_requests_. The command-stats variant stays because this pin takes a different path there (command_ is a non-owning StatName that aborts in SymbolTable::fromSymbol once popped), and disabling command stats was measured not to be a workaround. Upstream also drops RESP3 Push frames ahead of this check. That cannot be ported: this pin's RespType has no Push member. release/v1.36 through release/v1.39 are still affected upstream and no backport PR is open yet. ae1505b (v1.39.2-dev) is in that range.
gavin-jeong
pushed a commit
to sendbird/envoy
that referenced
this pull request
Nov 25, 2026
… the pending request ClientImpl pairs each upstream reply with the oldest pending request. RESP has no request id, so one lost or surplus reply shifts every later reply onto the wrong request, and the op timeout never fires while replies keep arriving. Upstream documents this limit in envoyproxy#48205. Record the RESP2 reply type that each fixed-type command always gets (EXISTS integer, GET bulk string or null, HGETALL array, ...). When a non-error reply has another type, treat it like a decoder protocol error: count upstream_cx_protocol_error and rq_error, report an outlier failure and close the connection, which fails every pending request. Transaction clients are not checked because the server answers +QUEUED inside MULTI. JIRA: https://sendbird.atlassian.net/browse/CPLAT-13577 (cherry picked from commit 98c39cf)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit Message: redis: test dropping an upstream reply with no pending request
ClientImpl::onRespValue()used to onlyASSERTthat a request was outstanding and then callpending_requests_.front(). When an upstream sent a reply while the pending request list was empty (a surplus or unsolicited reply), a release build read thestd::listsentinel as aPendingRequestand crashed. The RESP3 change (#44936) added a guard that drops such a frame, but its comment and its only test cover a HELLO 3 init callback that closes the connection. This adds tests for a surplus or unsolicited reply on an established connection, broadens the comment, and adds a bug fix release note.Additional Description:
We hit this in production on v1.39.x: an upstream Redis sent a reply while Envoy had no request pending on that connection, and the proxy crashed (fault address
0x3ff, stackDecoderImpl::parseSlice<-ClientImpl::onData). Stockenvoyproxy/envoy:v1.39.3reproduces it with a fake upstream that answers one command with two replies, or sends one unsolicited reply later.On main, the guard added by #44936 already drops the frame and keeps the connection open, which is the behavior these tests pin. The new tests:
RedisClientImplTest.UnsolicitedReplyIsDropped,SurplusReplyInSameBufferIsDroppedandReplyAfterCloseInSameBufferIsDropped: the reply is dropped, the connection stays open withoutupstream_cx_protocol_error, and the next request gets its own reply. The last one covers a user callback that closes the client while the decoder still holds a later reply from the same buffer.RedisProxyIntegrationTest.SurplusUpstreamReplyIsDroppedandUnsolicitedUpstreamReplyIsDropped: through the real decoder, the client gets only the first reply, and the next command goes over the same upstream connection (upstream_cx_total= 1,upstream_cx_protocol_error= 0). They wait for the drop log line before sending the next command, so the surplus reply cannot be paired with it on a loaded machine.A surplus reply that arrives while another request is pending is still paired with that request; RESP gives no way to detect it.
release/v1.36torelease/v1.39are still affected. #44936 is not a candidate for backport, so the fix there would be the guard alone plus these tests. We carry exactly that on v1.39.3. Happy to open the backport PRs if maintainers agree.Risk Level: Low (tests, a comment and a release note; no behavior change on main)
Testing: The five new tests abort on the
!pending_requests_.empty()ASSERT without the guard (checked on v1.39.3), and pass on main.Docs Changes: N/A
Release Notes: Added a bug fix note for the crash.
AI assistance: the investigation, the tests and this change were prepared with AI assistance (Claude Code and Cursor agent). We reviewed and understand all of it.