feat(redis): name the cache and queue connections with the node - #233
Merged
Conversation
Redis connections arrived unnamed, so CLIENT LIST on the server could not tell which node or which component owned a connection — the first question asked when connections leak or maxclients fills up. Both clients now send CLIENT SETNAME as `console:<node>:<role>`, reusing the cluster identity from getThisNodeName() rather than deriving a second one. Behaviour is unchanged: ioredis sends SETNAME in the same awaited batch as the CLIENT SETINFO commands it already sends, and swallows a failure, so a server that rejects the command still connects.
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.
Why
Redis connections arrived unnamed, so
CLIENT LISTon the server could not say which node or which component owned a connection. That is the first question asked when connections leak ormaxclientsfills up — and it is a hard requirement from the bank we are onboarding.What
Both Redis clients now send
CLIENT SETNAME:src/lib/core/cache/redisCacheProvider.tsconsole:<node>:cachesrc/lib/core/queue/bullmqQueueProvider.tsconsole:<node>:queue,console:<node>:queue-subNo second identity scheme was introduced: the node name comes from the existing
getThisNodeName()(NODE_NAME, elsehostname-pid), which the queue provider already imported.Why this is safe on production
CLIENT SETNAMEin the same awaited batch as the twoCLIENT SETINFOcommands it already sends on every connect, and wraps it in.catch(noop). A server or proxy that rejects the command still connects.CACHE_PROVIDER=redis,QUEUE_PROVIDER=bullmq); memory and MongoDB paths are untouched.Verification
tsc --noEmit: no new errors (the three pre-existingagentService.tstrace-type errors are unrelated and untouched)src/__tests__/unit/cache-provider.test.tspassingredis-cli client list | grep -o 'name=[^ ]*' | sort | uniq -c