Skip to content

Conversation

@MeirShpilraien
Copy link

@MeirShpilraien MeirShpilraien commented Dec 13, 2021

Follow the conclusions here: #9899
This PR handles point 1,2 on the action items list: #9899 (comment)

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.

todo:

  • Set write command instead of maybe_replicate on: FUNCTION RESTORE
  • Update commands description on commands json files.

Added 2 new FUNCTION sub-commands:
1. FUNCTION DUMP - dump a binary blob representation of all the functions.
2. FUNCTION RESTORE - give the binary blob extracted using FUNCTION DUMP,
   restore all the functions on the given blob. Drop existing functions if
   exists.

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.
@oranagra oranagra added release-notes indication that this issue needs to be mentioned in the release notes state:major-decision Requires core team consensus labels Dec 14, 2021
meir added 5 commits December 19, 2021 12:01
* Added restore policy argument to FUNCTION RESTORE commands (either FLUSH, APPEND or REPLACE).
* Small consmetic and bug fixes.
meir added 2 commits December 19, 2021 19:00
* Do not count on 'err' out parameter.
* Change 'err' out parameter on 'rdbFunctionLoad' to be optional.
* Replace line comment on redis-cli.
Changed restore policy to be the last argument on 'FUNCTION RESTORE'.
meir and others added 2 commits December 19, 2021 21:48
* Change default restore policy to APPEND.
* Added restore policy argument to function-restore.json
* documentation fixes.
@oranagra oranagra added the approval-needed Waiting for core team approval to be merged label Dec 19, 2021
@oranagra
Copy link
Member

@redis/core-team please approve

Co-authored-by: sundb <sundbcn@gmail.com>
Copy link
Member

@itamarhaber itamarhaber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API is ok imo

meir added 4 commits December 21, 2021 22:10
* Changed FUNCTION RESTORE to be WRITE command instead of MAY_REPLICATE
* Added command description to FUNCTION DUMP and RESTORE on command json
* Added documentation to describe FUNCTION DUMP serialization format
* Changed RESTORE_POLICY_* to enum
* Change blob terminology to payload
* Added test to verify 'redis-cli --cluster add-node' uploads
  existing functions to the new node.
Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM..
@madolson PTAL

meir and others added 3 commits December 22, 2021 16:23
Copy link
Contributor

@madolson madolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new cluster test LGTM, also approving the two new API designs. Left some other minor comments.

1. redis-cli will verify there is no functions on the new node
   before adding it to the cluster (on redis-cli --cluster add-node)
2. Drop unneeded variables on the new test
3. Use redis_client instead of redis_deferring_client (on new test)
4. Better naming new test
Copy link
Contributor

@soloestoy soloestoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FUNCTION RESTORE [FLUSH|APPEND|REPLACE]

APPEND: appends the restored functions to the existing functions. On collision, abort.

just one question, does it satisfy atomicity? the abort means rollback or just abort?

@oranagra
Copy link
Member

FUNCTION RESTORE [FLUSH|APPEND|REPLACE]

APPEND: appends the restored functions to the existing functions. On collision, abort.

just one question, does it satisfy atomicity? the abort means rollback or just abort?

if any conflicts are detected, the operation is aborted without any modification to the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval-needed Waiting for core team approval to be merged release-notes indication that this issue needs to be mentioned in the release notes state:major-decision Requires core team consensus

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants