You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by hu...@apache.org on 2023/07/07 02:17:59 UTC
[kvrocks] branch unstable updated: Fix ZUNION hang in syntax error (#1559)
This is an automated email from the ASF dual-hosted git repository.
hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new d39e198f Fix ZUNION hang in syntax error (#1559)
d39e198f is described below
commit d39e198f8faff904905ea1ecf663858b83a41d7a
Author: Binbin <bi...@qq.com>
AuthorDate: Fri Jul 7 10:17:54 2023 +0800
Fix ZUNION hang in syntax error (#1559)
The bug was introduced in #1502, without this return, when syntax
the error happens, the code will be stuck in the while loop and
result in a hang.
---
src/commands/cmd_zset.cc | 2 ++
tests/gocase/unit/type/zset/zset_test.go | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/src/commands/cmd_zset.cc b/src/commands/cmd_zset.cc
index a226d870..18dbc22b 100644
--- a/src/commands/cmd_zset.cc
+++ b/src/commands/cmd_zset.cc
@@ -1187,6 +1187,8 @@ class CommandZUnion : public Commander {
}
} else if (parser.EatEqICase("withscores")) {
with_scores_ = true;
+ } else {
+ return parser.InvalidSyntax();
}
}
return Commander::Parse(args);
diff --git a/tests/gocase/unit/type/zset/zset_test.go b/tests/gocase/unit/type/zset/zset_test.go
index 1b5a2980..489d76f5 100644
--- a/tests/gocase/unit/type/zset/zset_test.go
+++ b/tests/gocase/unit/type/zset/zset_test.go
@@ -1072,6 +1072,12 @@ func basicTests(t *testing.T, rdb *redis.Client, ctx context.Context, encoding s
require.Equal(t, []redis.Z{{1, "a"}, {2, "b"}, {3, "c"}, {3, "d"}}, rdb.ZRangeWithScores(ctx, "zsetc", 0, -1).Val())
})
+ t.Run(fmt.Sprintf("ZUNION error - %s", encoding), func(t *testing.T) {
+ rdb.Del(ctx, "zseta")
+
+ util.ErrorRegexp(t, rdb.Do(ctx, "zunion", 1, "zseta", "wrong_arg").Err(), ".*syntax error.*")
+ })
+
t.Run(fmt.Sprintf("ZUNION basics - %s", encoding), func(t *testing.T) {
createZset(rdb, ctx, "zseta", []redis.Z{
{Score: 1, Member: "a"},