CLUSTER FORGET node-id

    Time complexity: O(1)

    The command is used in order to remove a node, specified via its node ID, from the set of known nodes of the Redis Cluster node receiving the command. In other words the specified node is removed from the nodes table of the node receiving the command.

    However the command cannot simply drop the node from the internal node table of the node receiving the command, it also implements a ban-list, not allowing the same node to be added again as a side effect of processing the gossip section of the heartbeat packets received from other nodes.

    In the following example we'll show why the command must not just remove a given node from the nodes table, but also prevent it for being re-inserted again for some time.

    • Reshard all the hash slots from D to nodes A, B, C.
    • We contact A, and send .
    • B sends node A a heartbeat packet, where node D is listed.
    • A does no longer known node D (see step 3), so it starts an handshake with D.
    • D ends re-added in the nodes table of A.As you can see in this way removing a node is fragile, we need to send commands to all the nodes ASAP hoping there are no gossip sections processing in the meantime. Because of this problem the command implements a ban-list with an expire time for each entry.

    So what the command really does is:

    • The node ID of the removed node gets added to the ban-list, for 1 minute.
    • The node will skip all the node IDs listed in the ban-list when processing gossip sections received in heartbeat packets from other nodes.This way we have a 60 second window to inform all the nodes in the cluster that we want to remove a node.

    The command does not succeed and returns an error in the following cases:

    • The specified node ID is not found in the nodes table.
    • The node receiving the command is a replica, and the specified node ID identifies its current master.