Skip to content

Conversation

clouder-zhai
Copy link

Close #1949

Command Desc:

  1. add support for the basic dump command, which supports an atomic operation of dump and restore
  2. the command only support the basic migrate command: MIGRATE host port key destination-db timeout

Redis doc: https://redis.io/docs/latest/commands/migrate/

@clouder-zhai clouder-zhai changed the title Add support of the command Migrate feat: Add support of the command Migrate Apr 1, 2025
@clouder-zhai clouder-zhai force-pushed the migrate-impl branch 2 times, most recently from 45680b6 to c862ea1 Compare April 1, 2025 07:43
Comment on lines 1267 to 1268
static Status DumpKey(engine::Context &ctx, Server *srv, Connection *conn, std::string &key,
std::string &dump_result) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static Status DumpKey(engine::Context &ctx, Server *srv, Connection *conn, std::string &key,
std::string &dump_result) {
static StatusOr<std::string> DumpKey(engine::Context &ctx, Server *srv, Connection *conn, std::string &key) {

Copy link
Author

Choose a reason for hiding this comment

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

when I run ./x.py format, it automatically becomes two lines

Copy link
Member

Choose a reason for hiding this comment

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

I mean we can use StatusOr here instead of Status.

MakeCmdAttr<CommandDump>("dump", 2, "read-only", 1, 1, 1),
MakeCmdAttr<CommandPollUpdates>("pollupdates", -2, "read-only admin", NO_KEY), )
MakeCmdAttr<CommandPollUpdates>("pollupdates", -2, "read-only admin", NO_KEY),
MakeCmdAttr<CommandMigrate>("migrate", -6, "write", 1, 1, 1))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
MakeCmdAttr<CommandMigrate>("migrate", -6, "write", 1, 1, 1))
MakeCmdAttr<CommandMigrate>("migrate", 6, "write", 1, 1, 1))

Copy link
Member

@PragmaTwice PragmaTwice Apr 1, 2025

Choose a reason for hiding this comment

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

Also the key position spec is wrong (1,1,1).

MakeCmdAttr<CommandDump>("dump", 2, "read-only", 1, 1, 1),
MakeCmdAttr<CommandPollUpdates>("pollupdates", -2, "read-only admin", NO_KEY), )
MakeCmdAttr<CommandPollUpdates>("pollupdates", -2, "read-only admin", NO_KEY),
MakeCmdAttr<CommandMigrate>("migrate", -6, "write", 1, -1, 1))
Copy link
Member

Choose a reason for hiding this comment

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

1, -1, 1 means that all arguments are keys, which is obviously not correct here.

You can refer to here for how to generate dynamic key ranges: https://github.com/apache/kvrocks/blob/unstable/src/commands/cmd_zset.cc#L1552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support of the command MIGRATE
4 participants