diff --git a/.requirements b/.requirements index 40370da56ac5..855f031539d0 100644 --- a/.requirements +++ b/.requirements @@ -16,7 +16,7 @@ LIBEXPAT_SHA256=d4cf38d26e21a56654ffe4acd9cd5481164619626802328506a2869afab29ab3 # Note: git repositories can be loaded from local path if path is set as value LUA_KONG_NGINX_MODULE=3eb89666f84348fa0599d4e0a29ccf89511e8b75 # 0.13.0 -LUA_RESTY_LMDB=890b3caf45bd052e319e48349ef393ec93e08ac4 # 1.5.0 +LUA_RESTY_LMDB=9da0e9f3313960d06e2d8e718b7ac494faa500f1 # 1.6.0 LUA_RESTY_EVENTS=bc85295b7c23eda2dbf2b4acec35c93f77b26787 # 0.3.1 LUA_RESTY_SIMDJSON=7e6466ce91b2bc763b45701a4f055e94b1e8143b # 1.1.0 LUA_RESTY_WEBSOCKET=966c69c39f03029b9b42ec0f8e55aaed7d6eebc0 # 0.4.0.1 diff --git a/changelog/unreleased/kong/bump-lua-resty-lmdb-2.yml b/changelog/unreleased/kong/bump-lua-resty-lmdb-2.yml new file mode 100644 index 000000000000..a6afd3691ceb --- /dev/null +++ b/changelog/unreleased/kong/bump-lua-resty-lmdb-2.yml @@ -0,0 +1,3 @@ +message: Bumped lua-resty-lmdb to 1.6.0. Allowing page_size to be 1. +type: dependency +scope: Core diff --git a/kong/db/strategies/off/init.lua b/kong/db/strategies/off/init.lua index a80772224f27..d8a3e3e58b28 100644 --- a/kong/db/strategies/off/init.lua +++ b/kong/db/strategies/off/init.lua @@ -112,18 +112,11 @@ local function select_by_key(schema, key, follow) end -local LMDB_MIN_PAGE_SIZE = 2 - - local function page_for_prefix(self, prefix, size, offset, options, follow) if not size then size = self.connector:get_page_size(options) end - -- LMDB 'page_size' can not be less than 2 - -- see: https://github.com/Kong/lua-resty-lmdb?tab=readme-ov-file#page - size = math.max(size, LMDB_MIN_PAGE_SIZE) - offset = offset or prefix local res, err_or_more = lmdb_prefix.page(offset, prefix, nil, size) diff --git a/spec/02-integration/04-admin_api/07-upstreams_routes_spec.lua b/spec/02-integration/04-admin_api/07-upstreams_routes_spec.lua index 8012e5d4d849..3b65063bf265 100644 --- a/spec/02-integration/04-admin_api/07-upstreams_routes_spec.lua +++ b/spec/02-integration/04-admin_api/07-upstreams_routes_spec.lua @@ -835,3 +835,64 @@ describe("Admin API: #" .. strategy, function() end) end + +for _, strategy in helpers.all_strategies() do + describe("#regression #" .. strategy, function() + local client + lazy_setup(function() + local bp, _ = helpers.get_db_utils(strategy) + bp.upstreams:insert { + name = "my-upstream", + slots = 100, + } + bp.upstreams:insert { + name = "my-upstream-2", + slots = 100, + } + bp.upstreams:insert { + name = "my-upstream-3", + slots = 100, + } + + assert(helpers.start_kong{ + database = strategy + }) + client = assert(helpers.admin_client()) + end) + + lazy_teardown(function() + if client then client:close() end + helpers.stop_kong() + end) + + it("page size 1", function() + local res = assert(client:send { + method = "GET", + path = "/upstreams?size=1" + }) + assert.response(res).has.status(200) + local json = assert.response(res).has.jsonbody() + assert.equal(1, #json.data) + assert.truthy(json.offset) + + res = assert(client:send { + method = "GET", + path = "/upstreams", + query = {size = 1, offset = json.offset} + }) + assert.response(res).has.status(200) + local json = assert.response(res).has.jsonbody() + assert.equal(1, #json.data) + assert.truthy(json.offset) + + res = assert(client:send { + method = "GET", + path = "/upstreams?size=2" + }) + assert.response(res).has.status(200) + local json = assert.response(res).has.jsonbody() + assert.equal(2, #json.data) + assert.truthy(json.offset) + end) + end) +end \ No newline at end of file