From 12662275e1474cc90fb3a71bdc174793a8f6d95c Mon Sep 17 00:00:00 2001 From: Twice Date: Thu, 3 Oct 2024 14:25:03 +0800 Subject: [PATCH 1/3] ci: disable kvrocks2redis test for archlinux (#2575) --- .github/workflows/kvrocks.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/kvrocks.yaml b/.github/workflows/kvrocks.yaml index d855109a78a..4814ca5429a 100644 --- a/.github/workflows/kvrocks.yaml +++ b/.github/workflows/kvrocks.yaml @@ -540,6 +540,8 @@ jobs: run: apt install -y python3-redis - name: Run kvrocks2redis Test + # FIXME: https://github.com/apache/kvrocks/issues/2574 + if: ${{ !startsWith(matrix.image, 'archlinux') }} shell: bash run: | $HOME/local/bin/redis-server --daemonize yes From e3211c156f400788a9f1934736be0cddcd51bb12 Mon Sep 17 00:00:00 2001 From: Twice Date: Thu, 3 Oct 2024 16:02:34 +0800 Subject: [PATCH 2/3] feat(command): add slow flag to more commands (#2570) --- src/commands/cmd_hash.cc | 2 +- src/commands/cmd_key.cc | 4 ++-- src/commands/cmd_search.cc | 3 ++- src/commands/cmd_server.cc | 2 +- src/commands/cmd_set.cc | 2 +- src/commands/cmd_txn.cc | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/commands/cmd_hash.cc b/src/commands/cmd_hash.cc index a3aee46a3db..a319ec23c3d 100644 --- a/src/commands/cmd_hash.cc +++ b/src/commands/cmd_hash.cc @@ -461,6 +461,6 @@ REDIS_REGISTER_COMMANDS(Hash, MakeCmdAttr("hget", 3, "read-only", 1 MakeCmdAttr("hgetall", 2, "read-only slow", 1, 1, 1), MakeCmdAttr("hscan", -3, "read-only", 1, 1, 1), MakeCmdAttr("hrangebylex", -4, "read-only", 1, 1, 1), - MakeCmdAttr("hrandfield", -2, "read-only", 1, 1, 1), ) + MakeCmdAttr("hrandfield", -2, "read-only slow", 1, 1, 1), ) } // namespace redis diff --git a/src/commands/cmd_key.cc b/src/commands/cmd_key.cc index fecf4d55475..634437539eb 100644 --- a/src/commands/cmd_key.cc +++ b/src/commands/cmd_key.cc @@ -572,7 +572,7 @@ REDIS_REGISTER_COMMANDS(Key, MakeCmdAttr("ttl", 2, "read-only", 1, 1 MakeCmdAttr("rename", 3, "write", 1, 2, 1), MakeCmdAttr("renamenx", 3, "write", 1, 2, 1), MakeCmdAttr("copy", -3, "write", 1, 2, 1), - MakeCmdAttr>("sort", -2, "write", 1, 1, 1), - MakeCmdAttr>("sort_ro", -2, "read-only", 1, 1, 1)) + MakeCmdAttr>("sort", -2, "write slow", 1, 1, 1), + MakeCmdAttr>("sort_ro", -2, "read-only slow", 1, 1, 1)) } // namespace redis diff --git a/src/commands/cmd_search.cc b/src/commands/cmd_search.cc index 7dbaa4af02b..88858558e62 100644 --- a/src/commands/cmd_search.cc +++ b/src/commands/cmd_search.cc @@ -481,7 +481,8 @@ class CommandFTDrop : public Commander { }; REDIS_REGISTER_COMMANDS(Search, - MakeCmdAttr("ft.create", -2, "write exclusive no-multi no-script", 0, 0, 0), + MakeCmdAttr("ft.create", -2, "write exclusive no-multi no-script slow", 0, 0, + 0), MakeCmdAttr("ft.searchsql", -2, "read-only", 0, 0, 0), MakeCmdAttr("ft.search", -3, "read-only", 0, 0, 0), MakeCmdAttr("ft.explainsql", -2, "read-only", 0, 0, 0), diff --git a/src/commands/cmd_server.cc b/src/commands/cmd_server.cc index 445f20d4601..ded447ef9e7 100644 --- a/src/commands/cmd_server.cc +++ b/src/commands/cmd_server.cc @@ -1331,7 +1331,7 @@ REDIS_REGISTER_COMMANDS(Server, MakeCmdAttr("auth", 2, "read-only o MakeCmdAttr("role", 1, "read-only ok-loading", 0, 0, 0), MakeCmdAttr("config", -2, "read-only", 0, 0, 0, GenerateConfigFlag), MakeCmdAttr("namespace", -3, "read-only", 0, 0, 0), - MakeCmdAttr("keys", 2, "read-only", 0, 0, 0), + MakeCmdAttr("keys", 2, "read-only slow", 0, 0, 0), MakeCmdAttr("flushdb", 1, "write no-dbsize-check", 0, 0, 0), MakeCmdAttr("flushall", 1, "write no-dbsize-check", 0, 0, 0), MakeCmdAttr("dbsize", -1, "read-only", 0, 0, 0), diff --git a/src/commands/cmd_set.cc b/src/commands/cmd_set.cc index cc66c968fff..b2ed58e6657 100644 --- a/src/commands/cmd_set.cc +++ b/src/commands/cmd_set.cc @@ -461,7 +461,7 @@ REDIS_REGISTER_COMMANDS(Set, MakeCmdAttr("sadd", -3, "write", 1, 1, MakeCmdAttr("sismember", 3, "read-only", 1, 1, 1), MakeCmdAttr("smismember", -3, "read-only", 1, 1, 1), MakeCmdAttr("spop", -2, "write", 1, 1, 1), - MakeCmdAttr("srandmember", -2, "read-only", 1, 1, 1), + MakeCmdAttr("srandmember", -2, "read-only slow", 1, 1, 1), MakeCmdAttr("smove", 4, "write", 1, 2, 1), MakeCmdAttr("sdiff", -2, "read-only slow", 1, -1, 1), MakeCmdAttr("sunion", -2, "read-only slow", 1, -1, 1), diff --git a/src/commands/cmd_txn.cc b/src/commands/cmd_txn.cc index fcd74e8fd73..41bc823f056 100644 --- a/src/commands/cmd_txn.cc +++ b/src/commands/cmd_txn.cc @@ -120,7 +120,7 @@ class CommandUnwatch : public Commander { REDIS_REGISTER_COMMANDS(Txn, MakeCmdAttr("multi", 1, "multi", 0, 0, 0), MakeCmdAttr("discard", 1, "multi", 0, 0, 0), - MakeCmdAttr("exec", 1, "exclusive multi", 0, 0, 0), + MakeCmdAttr("exec", 1, "exclusive multi slow", 0, 0, 0), MakeCmdAttr("watch", -2, "multi", 1, -1, 1), MakeCmdAttr("unwatch", 1, "multi", 0, 0, 0), ) From b6b4cbe8f624cb1232acdaa1e1c65382414fcfd5 Mon Sep 17 00:00:00 2001 From: Twice Date: Thu, 3 Oct 2024 18:02:52 +0800 Subject: [PATCH 3/3] feat(json): change default max_nesting_depth to 1024 (#2572) --- src/types/json.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/types/json.h b/src/types/json.h index 4a1ab791718..04e98fa5cde 100644 --- a/src/types/json.h +++ b/src/types/json.h @@ -51,10 +51,12 @@ struct JsonValue { Mul = 2, }; + static const size_t default_max_nesting_depth = 1024; + JsonValue() = default; explicit JsonValue(jsoncons::basic_json value) : value(std::move(value)) {} - static StatusOr FromString(std::string_view str, int max_nesting_depth = std::numeric_limits::max()) { + static StatusOr FromString(std::string_view str, int max_nesting_depth = default_max_nesting_depth) { jsoncons::json val; jsoncons::json_options options; @@ -69,7 +71,7 @@ struct JsonValue { return JsonValue(std::move(val)); } - static StatusOr FromCBOR(std::string_view str, int max_nesting_depth = std::numeric_limits::max()) { + static StatusOr FromCBOR(std::string_view str, int max_nesting_depth = default_max_nesting_depth) { jsoncons::json val; jsoncons::cbor::cbor_options options; @@ -84,13 +86,13 @@ struct JsonValue { return JsonValue(std::move(val)); } - StatusOr Dump(int max_nesting_depth = std::numeric_limits::max()) const { + StatusOr Dump(int max_nesting_depth = default_max_nesting_depth) const { std::string res; GET_OR_RET(Dump(&res, max_nesting_depth)); return res; } - Status Dump(std::string *buffer, int max_nesting_depth = std::numeric_limits::max()) const { + Status Dump(std::string *buffer, int max_nesting_depth = default_max_nesting_depth) const { jsoncons::json_options options; options.max_nesting_depth(max_nesting_depth); @@ -104,13 +106,13 @@ struct JsonValue { return Status::OK(); } - StatusOr DumpCBOR(int max_nesting_depth = std::numeric_limits::max()) const { + StatusOr DumpCBOR(int max_nesting_depth = default_max_nesting_depth) const { std::string res; GET_OR_RET(DumpCBOR(&res, max_nesting_depth)); return res; } - Status DumpCBOR(std::string *buffer, int max_nesting_depth = std::numeric_limits::max()) const { + Status DumpCBOR(std::string *buffer, int max_nesting_depth = default_max_nesting_depth) const { jsoncons::cbor::cbor_options options; options.max_nesting_depth(max_nesting_depth); @@ -221,7 +223,7 @@ struct JsonValue { } StatusOr> GetBytes(std::string_view path, JsonStorageFormat format, - int max_nesting_depth = std::numeric_limits::max()) const { + int max_nesting_depth = default_max_nesting_depth) const { std::vector results; Status s; try {