From 1e0bf88bf33dab71f326dc9912783c5de2e699d2 Mon Sep 17 00:00:00 2001 From: yeqown Date: Tue, 1 Aug 2023 18:37:35 +0800 Subject: [PATCH] fix: listLeaseExpiredCmd doesn't ignore possibly empty value of task in lua script --- internal/rdb/rdb.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/rdb/rdb.go b/internal/rdb/rdb.go index d200517..7bb10c8 100644 --- a/internal/rdb/rdb.go +++ b/internal/rdb/rdb.go @@ -1284,7 +1284,10 @@ local res = {} local ids = redis.call("ZRANGEBYSCORE", KEYS[1], "-inf", ARGV[1]) for _, id in ipairs(ids) do local key = ARGV[2] .. id - table.insert(res, redis.call("HGET", key, "msg")) + local v = redis.call("HGET", key, "msg") + if v then + table.insert(res, v) + end end return res `) @@ -1305,9 +1308,6 @@ func (r *RDB) ListLeaseExpired(cutoff time.Time, qnames ...string) ([]*base.Task return nil, errors.E(op, errors.Internal, fmt.Sprintf("cast error: Lua script returned unexpected value: %v", res)) } for _, s := range data { - if len(s) == 0 { - continue - } msg, err := base.DecodeMessage([]byte(s)) if err != nil { return nil, errors.E(op, errors.Internal, fmt.Sprintf("cannot decode message: %v", err))