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

Skip to content

Commit eb7f31e

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 8323ddf commit eb7f31e

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
@@ -139,7 +139,7 @@ static void redis_cluster_init(redisCluster *c, HashTable *ht_seeds, double time
139139
c->flags->timeout = timeout;
140140
c->flags->read_timeout = read_timeout;
141141
c->flags->persistent = persistent;
142-
c->waitms = timeout * 1000L;
142+
c->waitms = (long)(1000 * (timeout + read_timeout));
143143

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

0 commit comments

Comments
 (0)
0