Repository navigation
fix(resp3): accept push frames; count nil _ as miss in arbitrary command tracking - #435
Conversation
…and tracking Two RESP3 correctness bugs surfaced by the 2.4 readiness review. #27: aggregate_type() lacked '>'. A server-pushed message (pubsub, keyspace notifications, client tracking invalidation) on a RESP3 connection hit the "unsupported response" path and dropped the connection. Now accepts and drains push frames inline. #25: SingleNullBulk and ArrayPerElementNulls miss sentinels only recognised RESP2 nil shapes ($-1/*-1/*0). RESP3 nil (_\r\n) was miscounted as a hit, silently understating miss rate and suppressing --miss-rate-threshold warnings. Refs: 2.4 review findings #25 + #27 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
… "_" Bugbot flagged that the ArrayPerElementNulls walker used a content heuristic (value_len==1 && value[0]=='_') that couldn't tell a RESP3 null parsed via single_type from a real bulk value of literal "_" parsed via blob_type. Both produce identical bulk_el. Added bulk_el::is_resp3_null flag, set only when single_type constructs the element for type byte '_'. Walker now reads the flag directly instead of inferring from content. Test added that stores "_" values and asserts they are NOT counted as misses. Refs: bugbot LOW on PR #435 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Bugbot LOW addressed in f7cf37f: bulk_el now carries an is_resp3_null flag set at construction by single_type, replacing the content heuristic. Added test that stores literal "_" values and asserts they count as hits, not misses. |
Reviewer caught that the prior commit accepted RESP3 push (>) into aggregate_type() but didn't suppress its effect on m_last_response. The push frame fully parsed AS a reply, response_ended() returned 1, and memtier dequeued the push as the reply to the next in-flight command -- corrupting latency attribution + hit/miss accounting. Adds an m_push drain-mode flag: - Set when a push aggregate is encountered at top level - Suppresses every mutation to m_last_response while true - Cleared in response_ended(), which returns false so the parser continues to read the actual reply - Reset on rs_initial transition Refs: 2.4 review of PR #435 (R1 CRITICAL).
|
Review R1 (CRITICAL) addressed in cc0cdd7: added m_push drain-mode flag so push frames are read+discarded without mutating m_last_response. response_ended() now returns false on push completion so the parser keeps reading the actual reply. |
Bugbot caught that response_ended()'s m_push drain returned false without resetting m_response_len. The accumulated push frame bytes stayed in the counter and contaminated set_total_len() for the actual reply, skewing bandwidth and per-op size statistics. Resetting m_response_len to 0 at the push-drain-complete site matches the behaviour at rs_initial (the only other site where m_response_len is reset). Refs: bugbot LOW on PR #435 (follow-up). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Bugbot LOW (push frame inflates reply size) addressed in d26f4dd: m_response_len is now reset to 0 when response_ended() clears m_push, so push bytes don't accumulate into the next reply's stats. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d26f4dd. Configure here.
…ded() Bugbot caught that if an attribute (|) appears nested inside a push frame (>), and both complete at the same response_ended() call, the m_attribute branch fired first and returned false, leaving m_push set. The parser then consumed the actual command reply as push-drain data, desynchronizing the connection. response_ended() now clears whichever flags are set in a single call and returns false if either was set. Refs: bugbot LOW on PR #435 (follow-up). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Bugbot LOW (attribute-in-push) addressed in 9183f52: response_ended() now clears both m_push and m_attribute together when both reach completion at the same time. |
Resolve conflicts after redis#432/redis#434/redis#435 landed on master. Conflict in memtier_benchmark.cpp: adopt master's "must be a positive integer" wording (standardized by redis#432) for the four negative-value guard fprintf() calls added by this branch; both sides trigger on the same code path and the test assertions only check the prefix, so either wording is functionally correct.
…862) test_arbitrary_get_resp3_nil_counted_as_miss and test_arbitrary_get_resp3_literal_underscore_not_counted_as_miss always skipped. Their local HELLO 3 probe ran on RLTest's protocol=2 client, where redis-py's RESP2 parser raises InvalidResponse on the RESP3 map reply, and a bare except turned that into a skip. RLTest counts skips as passes, so the RESP3 nil-as-miss handling from #435 never ran in CI. Use the shared server_supports_resp3(), which reads INFO server, and drop its catch-all so a probe that cannot decide fails the test instead of skipping it. Only servers older than Redis 6 skip. Both tests use GET, which never reaches the ArrayPerElementNulls / bulk_el::is_resp3_null path, so add an MGET resp3 test with a fixed key layout (a value, a literal "_", two missing keys) that asserts the exact hit/miss split and the per-position counts. Fixes #861 Co-Authored-By: Claude Opus 5.5 <[email protected]>

Summary
Two RESP3 correctness bugs surfaced by the 2.4 readiness review (findings #25 and #27). This PR is targeted at milestone 2.4.
Bug #27 — RESP3 push type
>silently dropped the connectionaggregate_type()inprotocol.cppaccepted%(map),~(set), and|(attribute) for RESP3, but not>(push). When a Redis 7+ server emitted a server-pushed message (pubsub, keyspace notifications, client-tracking invalidation) on a--protocol=resp3connection, the parser hit the "unsupported response" path and returned-1, dropping the connection.Fix: Added
>toaggregate_type(). Push frames are structurally identical to arrays (>N\r\n+ N elements) so they are parsed and drained inline. A TODO is left for future out-of-band routing.The existing fixture
tests/fixtures/resp_payloads/resp3_push_unsolicited.bin(>2\r\n+pubsub\r\n+msg\r\n+OK\r\n) and testtest_resp3_push_unsolicitedintests/test_resp_response_fuzzer.pyalready covered this case and will now pass.Bug #25 — RESP3 nil
_\r\nmiscounted as hit in arbitrary-command miss trackingTwo miss-tracking sentinels in
client.cpponly recognised RESP2 nil shapes:SingleNullBulkhandler (line ~801): checked$-1,*-1,*0— but not RESP3 nil_. The RESP3 nil is parsed viasingle_typeand stored verbatim as the status string"_", so it was classified as a hit.ArrayPerElementNullswalker (line ~856): checkedbel->value != NULLto detect a hit. RESP3 nil inside an mbulk is stored as abulk_elwithvalue=strdup("_")(non-NULL), so it was also classified as a hit.Both paths silently understated the miss rate and suppressed
--miss-rate-thresholdwarnings when running against RESP3 connections.Fix:
"_"to theSingleNullBulksentinel set.value_len==1 && value[0]=='_'check in theArrayPerElementNullswalker.New test:
test_arbitrary_get_resp3_nil_counted_as_missintests/test_arbitrary_command_misses.pyrunsGET __key__ --protocol=resp3against pre-populated keys and assertsTotal Misses > 0. Gated byHELLO 3capability detection so it skips cleanly on Redis < 6.Test plan
test_resp3_push_unsolicited(existing,tests/test_resp_response_fuzzer.py) — was a confirmed bug, now passes with theaggregate_type()fixtest_arbitrary_get_resp3_nil_counted_as_miss(new,tests/test_arbitrary_command_misses.py) — asserts misses > 0 under--protocol=resp3; skips on Redis < 6test_arbitrary_command_misses.pytests continue to pass (no regression in RESP2 nil handling)test_resp_response_fuzzer.pyfixtures continue to pass🤖 Generated with Claude Code
Note
Medium Risk
Changes core RESP3 parsing and per-key miss accounting on live benchmark connections; incorrect push or null handling could skew stats or affect long-running RESP3 workloads, though scope is limited and covered by new tests.
Overview
This PR hardens RESP3 handling in the Redis protocol parser and in arbitrary-command miss tracking when
--protocol=resp3is used.Push frames (
>): The parser now treats RESP3 push aggregates like other aggregates instead of failing as unsupported. While a push is active, it drains the frame (advancing the read buffer) without writing status, mbulk trees, values, or hit counts into the in-flight command reply—so pubsub/keyspace/tracking pushes no longer tear down the connection or masquerade as command replies. A TODO remains for routing pushes to an out-of-band listener.RESP3 null (
_) in miss stats:SingleNullBulkmiss detection now treats status"_"as a miss alongside$-1,*-1, and*0. For array walks,bulk_el::is_resp3_nullis set only when the null type is parsed viasingle_type, so a real bulk string whose payload is a single_is still counted as a hit.Tests: Integration tests run
GETunder RESP3 (skipped whenHELLO 3is unavailable) to assert nil misses are recorded and literal"_"values are not.Reviewed by Cursor Bugbot for commit 9183f52. Bugbot is set up for automated code reviews on this repo. Configure here.