From f3c9ef572018e849c7c615fede6d6657789ad006 Mon Sep 17 00:00:00 2001 From: samugi Date: Thu, 12 Oct 2023 09:39:57 +0200 Subject: [PATCH] fix(rate-limiting): revert request-aware-table usage * the request-aware-table was incorrectly used in this plugin, these tables are expected to be shared across requests and should not be limited to a single request. --- kong/plugins/rate-limiting/policies/init.lua | 41 +++++++++----------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/kong/plugins/rate-limiting/policies/init.lua b/kong/plugins/rate-limiting/policies/init.lua index 80731cb0648b..12f9f32983e8 100644 --- a/kong/plugins/rate-limiting/policies/init.lua +++ b/kong/plugins/rate-limiting/policies/init.lua @@ -2,7 +2,7 @@ local policy_cluster = require "kong.plugins.rate-limiting.policies.cluster" local timestamp = require "kong.tools.timestamp" local reports = require "kong.reports" local redis = require "resty.redis" -local request_aware_table = require "kong.tools.request_aware_table" +local table_clear = require "table.clear" local kong = kong local pairs = pairs @@ -18,26 +18,23 @@ local EMPTY_UUID = "00000000-0000-0000-0000-000000000000" -- for `conf.sync_rate > 0` local auto_sync_timer -local cur_usage = request_aware_table.new() --- { --- [[ --- [cache_key] = --- ]] --- } +local cur_usage = { + --[[ + [cache_key] = + --]] +} -local cur_usage_expire_at = request_aware_table.new() --- { --- [[ --- [cache_key] = --- ]] --- } +local cur_usage_expire_at = { + --[[ + [cache_key] = + --]] +} -local cur_delta = request_aware_table.new() --- { --- [[ --- [cache_key] = --- ]] --- } +local cur_delta = { + --[[ + [cache_key] = + --]] +} local function is_present(str) @@ -141,9 +138,9 @@ local function get_redis_connection(conf) end local function clear_local_counter() - cur_usage:clear() - cur_usage_expire_at:clear() - cur_delta:clear() + table_clear(cur_usage) + table_clear(cur_usage_expire_at) + table_clear(cur_delta) end local function sync_to_redis(premature, conf)