Skip to content

Commit

Permalink
Revert "feat(pdk): add lmdb memory info to pdk.node.get_memory_stats …
Browse files Browse the repository at this point in the history
…function"

This reverts commit d90ce12.
  • Loading branch information
oowl authored and windmgc committed Jul 13, 2023
1 parent b38d09e commit 4bdb258
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 84 deletions.
41 changes: 1 addition & 40 deletions kong/pdk/node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
local utils = require "kong.tools.utils"
local ffi = require "ffi"
local private_node = require "kong.pdk.private.node"
local lmdb = require "resty.lmdb"


local floor = math.floor
Expand All @@ -19,7 +18,6 @@ local shared = ngx.shared
local C = ffi.C
local ffi_new = ffi.new
local ffi_str = ffi.string
local lmdb_get_env_info = lmdb.get_env_info

local NODE_ID_KEY = "kong:node_id"

Expand Down Expand Up @@ -123,17 +121,7 @@ local function new(self)
-- http_allocated_gc = 1102,
-- pid = 18005
-- }
-- },
-- -- if the `kong` uses dbless mode, the following will be present:
-- lmdb = {
-- map_size: "128.00 MiB",
-- used_size: "0.02 MiB",
-- last_used_page: 6,
-- last_txnid: 2,
-- max_readers: 126,
-- current_readers: 16
-- },
--}
-- }
-- }
--
-- local res = kong.node.get_memory_stats("k", 1)
Expand All @@ -159,15 +147,6 @@ local function new(self)
-- pid = 18005
-- }
-- }
-- -- if the `kong` uses dbless mode, the following will be present:
-- lmdb = {
-- map_size: "131072 KB",
-- used_size: "20.48 KB",
-- last_used_page: 6,
-- last_txnid: 2,
-- max_readers: 126,
-- current_readers: 16
-- },
-- }
function _NODE.get_memory_stats(unit, scale)
-- validate arguments
Expand Down Expand Up @@ -250,24 +229,6 @@ local function new(self)
}
end

if kong and kong.configuration and kong.configuration.database == "off" then
local lmdb_info, err = lmdb_get_env_info()
if err then
res.lmdb = self.table.new(0, 1)
res.lmdb.err = "could not get kong lmdb status: " .. err

else
local info = self.table.new(0, 6)
info.map_size = convert_bytes(lmdb_info.map_size, unit, scale)
info.used_size = convert_bytes(lmdb_info.last_used_page * lmdb_info.page_size, unit, scale)
info.last_used_page = lmdb_info.last_used_page
info.last_txnid = lmdb_info.last_txnid
info.max_readers = lmdb_info.max_readers
info.current_readers = lmdb_info.num_readers
res.lmdb = info
end
end

return res
end

Expand Down
44 changes: 0 additions & 44 deletions t/01-pdk/12-node/02-get_memory_stats.t
Original file line number Diff line number Diff line change
Expand Up @@ -536,47 +536,3 @@ workers_lua_vms
(?:\d+: 1024\s*){1,2}\Z
--- no_error_log
[error]
=== TEST 11: node.get_memory_stats() returns lmdb stats
--- main_config
lmdb_environment_path /tmp/dbless.lmdb;
lmdb_map_size 128m;
--- http_config eval
qq{
$t::Util::HttpConfig
lua_shared_dict kong 24k;
lua_shared_dict kong_db_cache 32k;
init_worker_by_lua_block {
local runloop_handler = require "kong.runloop.handler"
runloop_handler._update_lua_mem(true)
-- NOTE: insert garbage
ngx.shared.kong:set("kong:mem:foo", "garbage")
}
}
--- config
location = /t {
content_by_lua_block {
local PDK = require "kong.pdk"
local pdk = PDK.new()
kong = {}
kong.configuration = {}
kong.configuration.database = "off"
local res = pdk.node.get_memory_stats()
ngx.say(" lmdb map size: ", res.lmdb.map_size)
ngx.say(" lmdb map used size: ", res.lmdb.used_size)
}
}
--- request
GET /t
--- response_body_like chomp
lmdb map size: 134217728
lmdb map used size: \d+
--- no_error_log
[error]

0 comments on commit 4bdb258

Please sign in to comment.