Search code examples
redisredis-cluster

Is there a way to pause/block Redis clients while Redis clustering


Redis during clustering requires all nodes to be empty, but if there're connected (apps)clients who write data continuously, it's not enough time to cluster, so I need to flushall->pause somehow->cluster->unpause.

Redis client kill is killing but clients quickly reconnect.

Redis client pause is pausing all clients, but for performing clustering operations I need at least one active redis-cli client. Is there a good way to deal with it? Or it requires stopping all clients and then reconnect after clustering?


Solution

  • Have found a solution, originally I was performing script with operations

    redis-cli -a $PASSWORD -c -h $HOST -p $PORT flushall
    redis-cli -a $PASSWORD -c -h $HOST -p $PORT cluster reset soft
    redis-cli -a $PASSWORD -c -h $HOST -p $PORT client pause 10000
    ....
    redis-cli -a $PASSWORD --cluster-yes --cluster create ...
    
    redis-cli -a $PASSWORD -c -h $HOST -p $PORT client unpause
    ....
    

    But problem was in latency on connections, so I've wrapped the first 3 commands and performed in batch

     cat reset.txt | redis-cli -a $PASSWORD -c -h $HOST -p $PORT --pipe
     ....
     redis-cli -a $PASSWORD --cluster-yes --cluster create ...
     
     redis-cli -a $PASSWORD -c -h $HOST -p $PORT client unpause
     ....
    

    Where reset.txt

     flushall
     cluster reset soft
     client pause 10000
    

    So batch flushes and resets quickly before clients write data.