diff --git a/src/config.c b/src/config.c index 5a07c2c0f0..dcb5a99ce3 100644 --- a/src/config.c +++ b/src/config.c @@ -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), diff --git a/src/networking.c b/src/networking.c index debd94ddfc..4d386d6dc4 100644 --- a/src/networking.c +++ b/src/networking.c @@ -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; } diff --git a/tests/unit/expire.tcl b/tests/unit/expire.tcl index 941acfad38..c5c11191c0 100644 --- a/tests/unit/expire.tcl +++ b/tests/unit/expire.tcl @@ -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