• Meir Shpilraien (Spielrein)'s avatar
    Add FUNCTION DUMP and RESTORE. (#9938) · 365cbf46
    Meir Shpilraien (Spielrein) authored
    Follow the conclusions to support Functions in redis cluster (#9899)
    
    Added 2 new FUNCTION sub-commands:
    1. `FUNCTION DUMP` - dump a binary payload representation of all the functions.
    2. `FUNCTION RESTORE <PAYLOAD> [FLUSH|APPEND|REPLACE]` - give the binary payload extracted
       using `FUNCTION DUMP`, restore all the functions on the given payload. Restore policy can be given to
       control how to handle existing functions (default is APPEND):
       * FLUSH: delete all existing functions.
       * APPEND: appends the restored functions to the existing functions. On collision, abort.
       * REPLACE: appends the restored functions to the existing functions. On collision,
         replace the old function with the new function.
    
    Modify `redis-cli --cluster add-node` to use `FUNCTION DUMP` to get existing functions from
    one of the nodes in the cluster, and `FUNCTION RESTORE` to load the same set of functions
    to the new node. `redis-cli` will execute this step before sending the `CLUSTER MEET` command
    to the new node. If `FUNCTION DUMP` returns an error, assume the current Redis version do not
    support functions and skip `FUNCTION RESTORE`. If `FUNCTION RESTORE` fails, abort and do not send
    the `CLUSTER MEET` command. If the new node already contains functions (before the `FUNCTION RESTORE`
    is sent), abort and do not add the node to the cluster. Test was added to verify
    `redis-cli --cluster add-node` works as expected. 
    365cbf46
functions.c 24.8 KB