diff options
author | michael-grunder <michael.grunder@gmail.com> | 2014-06-20 21:36:41 +0400 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2015-05-06 01:02:04 +0300 |
commit | 92606171950ff7bed4b8a5603880d68d5d6d59b6 (patch) | |
tree | 74a63367135cbb1090346f33cba6d504561af519 /cluster_library.c | |
parent | 381a6477efa0e2f7a38ea8eb0ac9dd62ef22cfe7 (diff) |
Don't NULL out the original slot on MOVED error
There is no reason to NULL out the originally requested slot
when we get a MOVED error, because all we really know is that
the data (at slot N) that we're requesting is somewhere else.
Instead, just update the node mapping for the destination MOVED
slot, if it has changed. The source mapping will change organically
as we send more requests.
Diffstat (limited to 'cluster_library.c')
-rw-r--r-- | cluster_library.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/cluster_library.c b/cluster_library.c index e745c159..8d0470ad 100644 --- a/cluster_library.c +++ b/cluster_library.c @@ -1059,12 +1059,9 @@ static int cluster_sock_write(redisCluster *c, unsigned short slot, /* Provided a redisCluster object, the slot where we thought data was and * the slot where data was moved, update our node mapping */ -static void cluster_update_slot(redisCluster *c, short orig_slot TSRMLS_CC) { +static void cluster_update_slot(redisCluster *c TSRMLS_CC) { redisClusterNode *node; - // Invalidate original slot - c->master[orig_slot] = NULL; - // Do we already have the new slot mapped if(c->master[c->redir_slot]) { // No need to do anything if it's the same node @@ -1210,8 +1207,8 @@ PHPAPI int cluster_send_slot(redisCluster *c, short slot, char *cmd, /* Send a command to given slot in our cluster. If we get a MOVED or ASK error * we attempt to send the command to the node as directed. */ -PHPAPI short cluster_send_command(redisCluster *c, short slot, - const char *cmd, int cmd_len TSRMLS_DC) +PHPAPI short cluster_send_command(redisCluster *c, short slot, const char *cmd, + int cmd_len TSRMLS_DC) { int resp, rslot = slot; @@ -1260,10 +1257,10 @@ PHPAPI short cluster_send_command(redisCluster *c, short slot, 0 TSRMLS_CC); return -1; } - + // In case of a MOVED redirection, update our node mapping if(c->redir_type == REDIR_MOVED) { - cluster_update_slot(c, rslot); + cluster_update_slot(c); } slot = c->redir_slot; } |