feat: add REDIS_OP_TIMEOUT for per-operation Redis timeout#1188
Open
hoangcn95 wants to merge 3 commits into
Open
feat: add REDIS_OP_TIMEOUT for per-operation Redis timeout#1188hoangcn95 wants to merge 3 commits into
hoangcn95 wants to merge 3 commits into
Conversation
added 3 commits
July 13, 2026 16:24
Signed-off-by: Peter Nguyen <petnguyen@axon.com>
Clarify that a timed-out op fails the request (counted in redis_error, returned as a gRPC error) rather than silently degrading, so operators know what to expect on dashboards after enabling this timeout.
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
REDIS_TIMEOUTonly bounds the dial. Once connected, radix v4 has no read/write timeout — a command is bounded only by the caller's context, and the hot rate-limit path passes the inbound gRPC context, which usually carries no deadline. When Redis stalls, calls park indefinitely, goroutines pile up, and the pod OOMs.This PR adds two new settings,
REDIS_OP_TIMEOUTandREDIS_PERSECOND_OP_TIMEOUT, both disabled by default. When enabled, each Redis command or pipeline gets its context wrapped with a deadline, bounding per-operation latency independent of the caller's context.REDIS_OP_TIMEOUT0REDIS_PERSECOND_OP_TIMEOUT0Architecture
flowchart LR A[gRPC request] --> B[DoLimit] B --> C[PipeDo / DoCmd] C --> D{opTimeout > 0?} D -->|yes| E[context.WithTimeout deadline] D -->|no| F[caller ctx, no deadline] E --> G[radix client] F --> G G --> H[(Redis)] style E fill:#2a9d5c,color:#fff style C fill:#2563eb,color:#fffLegend: 🟢 new — 🔵 rewired
Test Result
Added unit tests in
src/redis/driver_impl_test.gousing the existingrecordingRedisClient/testActionfakes (whitebox tests already in that package):TestPipeDoReturnsWithinOpTimeoutWhenRedisHangs/TestDoCmdReturnsWithinOpTimeoutWhenRedisHangs: simulate a Redis that never responds (blockDelay: time.Hour) and assert that withopTimeout = 30ms, bothPipeDoandDoCmdreturn acontext.DeadlineExceedederror in well under 500ms instead of blocking indefinitely.TestPipeDoAppliesOpTimeoutDeadlineToContext/TestDoCmdAppliesOpTimeoutDeadlineToContext: assert the context handed to the underlying radix client carries a deadline whenopTimeout > 0.TestPipeDoWithoutOpTimeoutLeavesContextUnbounded/TestDoCmdWithoutOpTimeoutLeavesContextUnbounded: assert no deadline is added whenopTimeout == 0, preserving current behavior exactly.Settings parsing is covered in
src/settings/settings_test.go(TestRedisOpTimeout_Default,TestRedisOpTimeout_Configured), mirroring the style of the settings tests added in #1018.All of the above pass under
go test -race, along with the full existing suite (./...).Load test