fix(tokens,usage): in case of redis hiccup#8112
Open
rickbijkerk wants to merge 1 commit into
Open
Conversation
…k to Postgres After a Redis restart the ioredis client can report status "ready" on a connection that no longer responds. Without commandTimeout, redis.get never settles, so reads hang indefinitely instead of falling back to Postgres, and valid tokens are reported as not found until the service is manually restarted.
Contributor
There was a problem hiding this comment.
Code Review
This pull request configures a commandTimeout of 5,000ms for the Redis clients in the tokens and usage services to prevent commands from hanging indefinitely on half-open sockets. No issues were identified, and there is no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
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.
Background
If Redis becomes unavailable for a short moment for whatever reason, the
tokensservice can get stuck returning "token not found" for valid tokens until it is manually restarted.usagethen returns 401s and usage ingestion stops, and the service does not self-recover.Description
Adds
commandTimeoutto the ioredis client in two services:packages/services/tokenspackages/services/usageThis MR does not structurally fix the core issue that a redis connection can get into a broken state, it however does throw an error on no response, throwing an error, triggering the backup path of using postgres (in case of the tokens service). Which in turn should fix it functionally but does leave the redis connection broken.
These are the only two services whose Redis client is constructed without any timeout/retry options (others set
retryStrategy/reconnectOnErrorthroughcreateRedisClient). I didnt opt to rewrite usage/tokens to this mechanism as i couldnt fully oversee the consequences.Longer term it may be worth unifying tokens/usage onto the shared createRedisClient for consistency, though note that alone wouldn't fully resolve this, since it also doesn't set commandTimeout/keepAlive.
Checklist