Add new flag in CLIENT LIST for import-source client (#1398)

- Add new flag "I" in `CLIENT LIST` for import-source client
- Add `DEBUG_CONFIG` for import-mode
- Allow import-source status to be turned off when import-mode is off

Fixes #1350 and
https://github.com/valkey-io/valkey/pull/1185#discussion_r1851049362.

---------

Signed-off-by: lvyanqi.lyq <lvyanqi.lyq@alibaba-inc.com>
Signed-off-by: Yanqi Lv <lvyanqi.lyq@alibaba-inc.com>
Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Co-authored-by: Binbin <binloveplay1314@qq.com>
This commit is contained in:
Yanqi Lv 2024-12-10 20:35:07 +08:00 committed by GitHub
parent 9cfe1b3d81
commit f951a1ca73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View File

@ -3209,7 +3209,7 @@ standardConfig static_configs[] = {
createBoolConfig("enable-debug-assert", NULL, IMMUTABLE_CONFIG | HIDDEN_CONFIG, server.enable_debug_assert, 0, NULL, NULL),
createBoolConfig("cluster-slot-stats-enabled", NULL, MODIFIABLE_CONFIG, server.cluster_slot_stats_enabled, 0, NULL, NULL),
createBoolConfig("hide-user-data-from-log", NULL, MODIFIABLE_CONFIG, server.hide_user_data_from_log, 1, NULL, NULL),
createBoolConfig("import-mode", NULL, MODIFIABLE_CONFIG, server.import_mode, 0, NULL, NULL),
createBoolConfig("import-mode", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, server.import_mode, 0, NULL, NULL),
/* String Configs */
createStringConfig("aclfile", NULL, IMMUTABLE_CONFIG, ALLOW_EMPTY_STRING, server.acl_filename, "", NULL, NULL),

View File

@ -3340,6 +3340,7 @@ sds catClientInfoString(sds s, client *client, int hide_user_data) {
if (client->flag.readonly) *p++ = 'r';
if (client->flag.no_evict) *p++ = 'e';
if (client->flag.no_touch) *p++ = 'T';
if (client->flag.import_source) *p++ = 'I';
if (p == flags) *p++ = 'N';
*p++ = '\0';
@ -4101,7 +4102,7 @@ void clientCommand(client *c) {
addReply(c, shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr, "import-source")) {
/* CLIENT IMPORT-SOURCE ON|OFF */
if (!server.import_mode) {
if (!server.import_mode && strcasecmp(c->argv[2]->ptr, "off")) {
addReplyError(c, "Server is not in import mode");
return;
}

View File

@ -833,6 +833,19 @@ start_server {tags {"expire"}} {
assert_equal [r debug set-active-expire 1] {OK}
} {} {needs:debug}
test {import-source can be closed when import-mode is off} {
r config set import-mode no
assert_error "ERR Server is not in import mode" {r client import-source on}
r config set import-mode yes
assert_equal [r client import-source on] {OK}
assert_match {*flags=I*} [r client list id [r client id]]
r config set import-mode no
assert_equal [r client import-source off] {OK}
assert_match {*flags=N*} [r client list id [r client id]]
}
test {Import mode should forbid active expiration} {
r flushall