Skip to content

fix(sentinel): use the client-side cache with a type mapping - #3662

Merged
nkaradzhov merged 1 commit into
redis:masterfrom
maxymlyskov:fix/use-client-cache-with-a-type-mapping
Nov 23, 2026
Merged

nkaradzhov merged 1 commit into
redis:masterfrom
maxymlyskov:fix/use-client-cache-with-a-type-mapping

Conversation

@maxymlyskov

@maxymlyskov maxymlyskov commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

With clientSideCache on, a sentinel with a typeMapping in commandOptions never uses the cache. Every get goes to the server and the cache stats stay at 0 hits, 0 misses.

The sentinel's master and replica clients are built from #nodeClientOptions in sentinel/index.ts, which never get cacheTypeMapping, while the sentinel runs every command with its own commandOptions. So the cache check sees a different mapping from the sentinel's and skips the cache.

Repro against a real master + sentinel, 50 gets of one key with a BLOB_STRING → Buffer mapping. Before: the server ran all 50 GETs, 0 cache hits. After: 49 hits, 1 miss.

This sets cacheTypeMapping on the node client options when the sentinel has a type mapping, as the cluster does since #3556.

Added a test in sentinel/index.spec.ts; it fails on master (Cache Misses 0 !== 1).

Sentinel specs, the build and lint:changed pass. The full npm test has the same client failures on master (a VerbatimString timeout, sentinel "no valid master node"), plus a sentinel setup timeout that passes when run alone.


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Low Risk
Targeted wiring of existing cache/type-mapping options on Sentinel node clients; behavior change only when both client-side cache and top-level type mapping are enabled.

Overview
Sentinel client-side cache was skipped whenever commandOptions.typeMapping was set: master/replica node clients never received a matching cacheTypeMapping, so cache lookups compared against the wrong mapping and every GET hit the server.

The constructor now copies commandOptions.typeMapping onto #nodeClientOptions.cacheTypeMapping, matching the cluster client behavior from #3556.

A new integration test asserts that with RESP3, client-side cache, and BLOB_STRING → Buffer, the second get is a cache hit (1 miss, 1 hit).

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

A sentinel runs each command with its own commandOptions, typeMapping
included, on master and replica clients built from nodeClientOptions,
which carry no commandOptions and got no cacheTypeMapping. With a
clientSideCache and a typeMapping, every read compared the node's
undefined mapping with the sentinel's, so the cache was skipped and
every GET went to the server.

Set cacheTypeMapping from the sentinel's typeMapping when it has one,
as the cluster does for its node clients since redis#3556.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T06:05:16.852040Z f55b625 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.

@nkaradzhov nkaradzhov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

@nkaradzhov
nkaradzhov merged commit db8fd5b into redis:master Nov 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants