Commit e9ce92c
authored
upgrade radix from v3 to v4 for improved pipeline handling (#1041)
* feat: upgrade radix from v3 to v4
Upgrade radix Redis client from v3.8.1 to v4.1.4.
Main changes:
- Import paths: radix/v3 -> radix/v4
- Pool/Cluster/Sentinel use Config.New() instead of New()
- All client operations require context.Context parameter
- Dialer setup changed from functional options to struct config
- Pipelining uses radix.NewPipeline() and Append()
- Write buffering via Dialer.WriteFlushInterval
Breaking from v3:
- Pool on-empty behavior (WAIT/CREATE/ERROR) not available
- REDIS_PIPELINE_LIMIT setting deprecated (no effect in v4)
Tested with existing test suite - all tests passing.
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* docs: update pipeline settings for radix v4
Update documentation to reflect radix v4's pipeline behavior:
- REDIS_PIPELINE_WINDOW now sets WriteFlushInterval (auto-flush timing)
- REDIS_PIPELINE_LIMIT deprecated - no effect in v4
- Add REDIS_USE_EXPLICIT_PIPELINE for manual pipeline control
- Required for Redis Cluster: PIPELINE_WINDOW must be non-zero
Update terminology from "implicit pipelining" to "write buffering"
to better match radix v4's actual behavior.
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* test: update tests for radix v4
- Add useExplicitPipeline parameter to test client creation
- Update error assertions for v4's error message format
(v4 prefixes with "response returned from Conn:")
- Handle different connection errors (EOF, connection reset, broken pipe)
- Update radix.FlatCmd usage for v4 API
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* chore: add deprecation warning for REDIS_PIPELINE_LIMIT
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* test: fix Redis cluster test config for radix v4
Replace deprecated RedisPipelineLimit with RedisPipelineWindow in
configRedisCluster function. Radix v4 requires WriteFlushInterval
(RedisPipelineWindow) for cluster mode buffering instead of the
deprecated pipeline limit setting.
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* style: fix gofmt struct field alignment in settings.go
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* fix: fail fast on unsupported REDIS_POOL_ON_EMPTY_BEHAVIOR settings
Radix v4 does not support CREATE or ERROR behaviors for
REDIS_POOL_ON_EMPTY_BEHAVIOR. Previously, these settings were logged
as errors but the application would continue with blocking behavior,
which could cause unexpected issues in production.
Changes:
- Panic at startup when CREATE or ERROR is detected
- Prevent silent behavior changes that could cause blocking
- Update tests to verify panic behavior
- Improve migration documentation in comments
This ensures users are immediately notified of incompatible
configuration rather than experiencing unexpected blocking in production.
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* fix: change REDIS_POOL_ON_EMPTY_BEHAVIOR default to WAIT
The default value 'CREATE' is not supported in radix v4 and causes
integration tests to panic at startup. Changed default to 'WAIT' which
matches radix v4's actual pool behavior (always blocks when empty).
This fixes integration test failures where tests without explicit
REDIS_POOL_ON_EMPTY_BEHAVIOR settings would panic during initialization
with: "REDIS_POOL_ON_EMPTY_BEHAVIOR=CREATE is not supported in radix v4"
Also updated documentation to clarify that CREATE/ERROR are not supported
and marked RedisPoolOnEmptyWaitDuration as deprecated.
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* test: fix cluster connection timeout and context bug
- Fix WaitForTcpPort to use timeoutCtx instead of ctx
This ensures the timeout parameter is actually respected when
dialing TCP connections.
- Increase gRPC server startup timeout from 1s to 10s
Radix v4 cluster connection initialization takes longer,
especially when establishing connections to multiple cluster nodes.
This prevents "connection refused" errors in integration tests.
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* refactor: extract dialer creation logic to reduce duplication
Consolidates Redis and Sentinel dialer setup into a reusable createDialer
helper function, eliminating ~30 lines of duplicated code. Improves logging
by including connection target details (e.g., "sentinel(master,host1,host2)")
instead of generic "sentinel" string.
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* refactor: remove deprecated REDIS_POOL_ON_EMPTY_WAIT_DURATION settings
Remove the deprecated poolOnEmptyWaitDuration parameter and related
configuration settings as they have no effect in radix v4. The pool
always blocks until a connection is available when using WAIT behavior.
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* refactor: auto-select pipeline mode based on Redis type
Remove REDIS_USE_EXPLICIT_PIPELINE configuration option and
automatically determine pipeline mode based on Redis deployment type:
- Cluster mode: uses grouped pipeline (groups same-key commands)
- INCRBY + EXPIRE for same key are pipelined together (same slot)
- Reduces round-trips from 2 to 1 per key in cluster mode
- Single/Sentinel mode: uses explicit pipeline (batches all commands)
- All commands in one pipeline for minimal latency
- Optimal for non-cluster deployments
This simplifies configuration by removing user-facing options while
automatically choosing the optimal pipeline strategy for each Redis type.
Breaking changes:
- Remove REDIS_USE_EXPLICIT_PIPELINE env var
- Remove REDIS_PERSECOND_USE_EXPLICIT_PIPELINE env var
- Remove UseExplicitPipeline() interface method
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* docs: remove non-existent REDIS_USE_EXPLICIT_PIPELINE from README
The REDIS_USE_EXPLICIT_PIPELINE and REDIS_PERSECOND_USE_EXPLICIT_PIPELINE
settings were documented in README but do not exist in settings.go.
Removed the documentation to match the actual implementation.
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
* style: fix gofmt formatting in settings.go
Signed-off-by: seonghyun <seonghyunoh@gmail.com>
---------
Signed-off-by: seonghyun <seonghyunoh@gmail.com>1 parent 167d0f8 commit e9ce92c
14 files changed
Lines changed: 290 additions & 260 deletions
File tree
- src
- redis
- settings
- test
- common
- integration
- mocks/redis
- redis
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1308 | 1308 | | |
1309 | 1309 | | |
1310 | 1310 | | |
1311 | | - | |
| 1311 | + | |
1312 | 1312 | | |
1313 | | - | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
| 1313 | + | |
| 1314 | + | |
1317 | 1315 | | |
1318 | | - | |
| 1316 | + | |
1319 | 1317 | | |
1320 | 1318 | | |
1321 | 1319 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
| 105 | + | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
| |||
241 | 243 | | |
242 | 244 | | |
243 | 245 | | |
244 | | - | |
245 | | - | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | | - | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | | - | |
| 53 | + | |
0 commit comments