Repository navigation
fix(sentinel): use the client-side cache with a type mapping - #3662
Merged
nkaradzhov merged 1 commit intoNov 23, 2026
Merged
nkaradzhov merged 1 commit into
nkaradzhov merged 1 commit into
Conversation
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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Description
With
clientSideCacheon, a sentinel with atypeMappingincommandOptionsnever uses the cache. Everygetgoes to the server and the cache stats stay at 0 hits, 0 misses.The sentinel's master and replica clients are built from
#nodeClientOptionsinsentinel/index.ts, which never getcacheTypeMapping, while the sentinel runs every command with its owncommandOptions. 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 aBLOB_STRING→Buffermapping. Before: the server ran all 50 GETs, 0 cache hits. After: 49 hits, 1 miss.This sets
cacheTypeMappingon 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:changedpass. The fullnpm testhas 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
npm testpass with this change (including linting)?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.typeMappingwas set: master/replica node clients never received a matchingcacheTypeMapping, so cache lookups compared against the wrong mapping and everyGEThit the server.The constructor now copies
commandOptions.typeMappingonto#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 secondgetis 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.