8000 Fix random connection timeouts with Redis Cluster · phpredis/phpredis@1af521a · GitHub
[go: up one dir, main page]

Skip to content

Commit 1af521a

Browse files
kjoemichael-grunder
authored andcommitted
Fix random connection timeouts with Redis Cluster
When a node timeout occurs, then phpredis will try to connect to another node, whose answer probably will be MOVED redirect. After this we need more time to accomplish the redirection, otherwise we get "Timed out attempting to find data in the correct node" error message. Fixes #795 #888 #1142 #1385 #1633 #1707 #1811 #2407
1 parent 98d64ba commit 1af521a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cluster_library.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ PHP_REDIS_API redisCluster *cluster_create(double timeout, double read_timeout,
833833
c->err = NULL;
834834

835835
/* Set up our waitms based on timeout */
836-
c->waitms = (long)(1000 * timeout);
836+
c->waitms = (long)(1000 * (timeout + read_timeout));
837837

838838
/* Allocate our seeds hash table */
839839
ALLOC_HASHTABLE(c->seeds);

redis_cluster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static void redis_cluster_init(redisCluster *c, HashTable *ht_seeds, double time
381381
c->flags->timeout = timeout;
382382
c->flags->read_timeout = read_timeout;
383383
c->flags->persistent = persistent;
384-
c->waitms = timeout * 1000L;
384+
c->waitms = (long)(1000 * (timeout + read_timeout));
385385

386386
/* Attempt to load slots from cache if caching is enabled */
387387
if (CLUSTER_CACHING_ENABLED()) {

0 commit comments

Comments
 (0)
0