From 6f6d4ea873e222ca919a4e6a1966415a4a023c0c Mon Sep 17 00:00:00 2001 From: Janko Date: Wed, 29 Jul 2020 20:04:08 +0800 Subject: [PATCH 1/3] bugfix: fix limit-count plugin redis.ttl error. --- apisix/plugins/limit-count/limit-count-redis.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apisix/plugins/limit-count/limit-count-redis.lua b/apisix/plugins/limit-count/limit-count-redis.lua index b71cd852b0a0..a0cdfb574ce6 100644 --- a/apisix/plugins/limit-count/limit-count-redis.lua +++ b/apisix/plugins/limit-count/limit-count-redis.lua @@ -71,7 +71,8 @@ function _M.incoming(self, key) local remaining key = self.plugin_name .. tostring(key) - local ret = red:ttl(key) + -- todo: test case + local ret = red:ttl(key) or -2 core.log.info("ttl key: ", key, " ret: ", ret, " err: ", err) if ret < 0 then -- todo: test case From a953becb0617b599e039c10f909e1e6d40d16b37 Mon Sep 17 00:00:00 2001 From: Janko Date: Wed, 29 Jul 2020 21:42:42 +0800 Subject: [PATCH 2/3] change: fix code logic errors. --- apisix/plugins/limit-count/limit-count-redis.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apisix/plugins/limit-count/limit-count-redis.lua b/apisix/plugins/limit-count/limit-count-redis.lua index a0cdfb574ce6..6f9c787b04b5 100644 --- a/apisix/plugins/limit-count/limit-count-redis.lua +++ b/apisix/plugins/limit-count/limit-count-redis.lua @@ -72,7 +72,11 @@ function _M.incoming(self, key) key = self.plugin_name .. tostring(key) -- todo: test case - local ret = red:ttl(key) or -2 + local ret, err = red:ttl(key) + if not ret then + return false, "failed to get redis ttl: " .. err + end + core.log.info("ttl key: ", key, " ret: ", ret, " err: ", err) if ret < 0 then -- todo: test case From 53aaa20269b76b1dd2cb8f3ac75bbcd879e48212 Mon Sep 17 00:00:00 2001 From: Janko Date: Thu, 30 Jul 2020 10:39:55 +0800 Subject: [PATCH 3/3] change: add redis key to error return msg. --- apisix/plugins/limit-count/limit-count-redis.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apisix/plugins/limit-count/limit-count-redis.lua b/apisix/plugins/limit-count/limit-count-redis.lua index 6f9c787b04b5..a4dfba51b36e 100644 --- a/apisix/plugins/limit-count/limit-count-redis.lua +++ b/apisix/plugins/limit-count/limit-count-redis.lua @@ -74,7 +74,7 @@ function _M.incoming(self, key) -- todo: test case local ret, err = red:ttl(key) if not ret then - return false, "failed to get redis ttl: " .. err + return false, "failed to get redis `" .. key .."` ttl: " .. err end core.log.info("ttl key: ", key, " ret: ", ret, " err: ", err)