From e64c085c0d515ab7a5024c08f11f59fb49e1a8ba Mon Sep 17 00:00:00 2001 From: Datong Sun Date: Tue, 4 Jun 2024 10:00:30 -0700 Subject: [PATCH] fix pagination bug --- kong/clustering/services/sync/hooks.lua | 6 +++--- kong/db/strategies/connector.lua | 4 ++-- kong/db/strategies/off/init.lua | 2 +- kong/init.lua | 5 ++++- kong/runloop/events.lua | 1 - 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/kong/clustering/services/sync/hooks.lua b/kong/clustering/services/sync/hooks.lua index 660bec095084..a25441239c79 100644 --- a/kong/clustering/services/sync/hooks.lua +++ b/kong/clustering/services/sync/hooks.lua @@ -22,13 +22,13 @@ local function get_all_nodes_with_sync_cap() local ret = {} local ret_n = 0 - local res, err = kong.db.clustering_data_planes:page(1000) + local res, err = kong.db.clustering_data_planes:page(512) if err then return nil, "unable to query DB " .. err end - if not res then - return nil, "node is not connected, node_id: " .. node_id + if not res then + return {} end for _, row in ipairs(res) do diff --git a/kong/db/strategies/connector.lua b/kong/db/strategies/connector.lua index 3f03cddc11f7..bd1ed71a3af7 100644 --- a/kong/db/strategies/connector.lua +++ b/kong/db/strategies/connector.lua @@ -5,8 +5,8 @@ local fmt = string.format local Connector = { defaults = { pagination = { - page_size = 1000, - max_page_size = 50000, + page_size = 512, + max_page_size = 512, }, }, } diff --git a/kong/db/strategies/off/init.lua b/kong/db/strategies/off/init.lua index 749a0f0af833..a0a1047bbbcb 100644 --- a/kong/db/strategies/off/init.lua +++ b/kong/db/strategies/off/init.lua @@ -162,7 +162,7 @@ local function page_for_prefix(self, prefix, size, offset, options, follow) end if err_or_more then - return ret, nil, last_key + return ret, nil, last_key .. "1" end return ret diff --git a/kong/init.lua b/kong/init.lua index e049d5f8088f..4a110902c404 100644 --- a/kong/init.lua +++ b/kong/init.lua @@ -869,7 +869,6 @@ function Kong.init_worker() err) return end - kong.core_cache = core_cache kong.db:set_events_handler(worker_events) @@ -913,6 +912,8 @@ function Kong.init_worker() end elseif declarative_entities then + kong.core_cache = core_cache + ok, err = load_declarative_config(kong.configuration, declarative_entities, declarative_meta, @@ -938,6 +939,8 @@ function Kong.init_worker() end end + kong.core_cache = core_cache + local is_not_control_plane = not is_control_plane(kong.configuration) if is_not_control_plane then ok, err = execute_cache_warmup(kong.configuration) diff --git a/kong/runloop/events.lua b/kong/runloop/events.lua index 760a75da77ed..4c74ca390602 100644 --- a/kong/runloop/events.lua +++ b/kong/runloop/events.lua @@ -170,7 +170,6 @@ end local function dao_crud_handler(data) - ngx.log(ngx.ERR, "dao_crud_handler") local schema = data.schema if not schema then log(ERR, "[events] missing schema in crud subscriber")