-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nodeNext strange behaviour after master failover. #175
Comments
I tried to understand the behavior and added logs dumping :
Stared with and rebooted the master so 10.254.69.109 became new master before reboot logs shows only 10.254.2.71 after failover the redisClusterNode *table; / redisClusterNode lookup table */ was updatd and started to show new IP but struct dict *nodes; was still showing slave IP And nodeNext now was showing 3 master + 1 slave IP What is the purpose of both nodes and table in redisClusterContext and is this ok that nodes contains still slave IP ? |
Thanks for the report! I don't know why we have both a list and a table. Maybe it is not needed actually. Hopefully we can investigate this in the next week. |
Thanks If you will have any other suggestions what to check if hiredsi-cluster is not sending AUTH to new master after CLUSTER NODES response it would be very useful. |
It's good that you are able to reproduce the problem. Some ideas:
|
Also note that connection to a new master doesn't happen directly when CLUSTER NODES is handled. Connection happens only when there there is a command for that node (lazy connect). |
I'm encounter the same issue. In addition I have noticed that after master frailer new TCP connection is open to its slave (new master of a shard) but that is the only communication between them. No DB requests are being send. |
Yes I noticed that connection to newly selected master is only during command. We keep calling redisClusterAsyncFormattedCommand with keys that should go to this new master but the tcpdump does not show any attempt to really send them and there is no callback called so the process memory keeps growing. Im thinking of workaroung to count how many request we sent without response and when it starts growing call redisClusterReset |
We suspect the problem could be in actx_get_by_node We added test sleep 10ms between redisAsyncConnectWithOptions and redisAsyncCommand(AUTH) and it seams more clients was able to reconnect but still not all. |
Looks like the problem was in libae that was used by hiredis asynchronous functions. https://github.com/redis/hiredis/blob/master/adapters/ae.h The AE must be initialized with specific size aeCreateEventLoop(1024); and each redis asynchronous function opens temporary fd to send command. When application starts number of fd is low and they dont exceed AE max size. int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask, In https://github.com/redis/hiredis/blob/master/adapters/ae.h return code from aeCreateFileEvent is ignored and then command is silently dropped. |
We use nodeNext to monotor all the master in redis cluster . Every several seconds execute code
nodeIterator ni;
redisClusterNode *node;
initNodeIterator(&ni, this->_redisClusterAsyncContext->cc);
while ((node = nodeNext(&ni)) != NULL )
{
redisClusterAsyncCommandToNode(this->_redisClusterAsyncContext, node, onClusterHeartBeat, &pingCallbackRespTab[i], "PING");
}
normally it work fine and sends PING to master in each shard and when there is master failover it starts sending PING to new master.
But on larger cluster with 7 shards and large number of updates. We see that nodeNext does not return all nodes or returns slave nodes instead of master.
I would expect this to happen once or twice when routing table is updated is but after master fail over this strange behavior of nodeNext continue until we will not refresh _redisClusterAsyncContext. We call initNodeIterator before each try so its should have correct number of nodes but somehow data returned by nodeNext does not match the list of node returned by CLUSTER NODES command in redis-cli
The text was updated successfully, but these errors were encountered: