Skip to content

Preserve reader limits across redisReconnect - #1392

Open
RaphaelFakhri wants to merge 1 commit into
redis:masterfrom
RaphaelFakhri:fix-reconnect-reader-limits
Open

RaphaelFakhri wants to merge 1 commit into
redis:masterfrom
RaphaelFakhri:fix-reconnect-reader-limits

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Oct 24, 2026 •

Copy link
Copy Markdown

Summary

redisReconnect() replaces c->reader with a freshly created reader, which resets maxbuf, maxelements and maxdepth to their defaults. The README documents setting these fields on context->reader, so a reconnect silently undoes that configuration. Depending on the direction of the change, the client either starts rejecting replies it accepted before the reconnect, or loses a limit it set to bound memory use.

This change copies the three limits from the old reader to the new one. If there is no old reader (for example after an earlier allocation failure), the defaults apply as before.

Fixes #1391

Testing

  • Added Reconnect preserves the reader limits to test_blocking_connection_timeouts in test.c. It sets non-default limits, calls redisReconnect(), and checks the values on the new reader.
  • Without the fix, the new test fails for both TCP and Unix socket connections (*** 2 TESTS FAILED ***). With the fix, ./test.sh reports ALL TESTS PASSED (0 skipped).
  • make builds clean with the default -Wall -Wextra -Werror -pedantic flags.

Note

Low Risk
Localized change to reconnect reader setup with a matching test; no auth or protocol behavior changes beyond keeping user-configured parse limits.

Overview
redisReconnect() used to allocate a fresh redisReader, which reset maxbuf, maxelements, and maxdepth to library defaults and dropped any limits the app set on context->reader (as documented in the README).

The reconnect path now snapshots those three fields from the existing reader before redisReaderFree, then restores them on the new reader after redisReaderCreate(). If there is no prior reader, behavior is unchanged (defaults apply).

A regression test Reconnect preserves the reader limits sets non-default values, calls reconnect, and asserts they survive on the new reader.

Reviewed by Cursor Bugbot for commit 51c7946. Bugbot is set up for automated code reviews on this repo. Configure here.

redisReconnect() frees the context reader and creates a new one with
the default settings, so any maxbuf, maxelements or maxdepth value set
on c->reader (as the README describes) is silently reset after a
reconnect. Copy these limits to the new reader.
@github-actions github-actions Bot added the bug label Oct 24, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T16:47:32.355587Z 51c7946 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

redisReconnect resets reader limits set on context->reader

1 participant