From 3dbc971f8b6092d2de43e727774c4ab50f31bc1d Mon Sep 17 00:00:00 2001 From: Oshry Avraham Date: Wed, 29 Jan 2025 00:58:18 +0200 Subject: [PATCH] rgw/lua: Fix - Reset Lua background start time for accurate time limit Resolved an issue where the Lua background would always exceed the execution time limit. Signed-off-by: Oshrey Avraham --- src/rgw/rgw_lua_background.cc | 1 + src/rgw/rgw_lua_utils.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_lua_background.cc b/src/rgw/rgw_lua_background.cc index 8121a774332..9182ba45b37 100644 --- a/src/rgw/rgw_lua_background.cc +++ b/src/rgw/rgw_lua_background.cc @@ -154,6 +154,7 @@ void Background::run() { ldpp_dout(dpp, 10) << "Lua background thread resumed" << dendl; } + lguard.reset_start_time(); const auto rc = read_script(); if (rc == -ENOENT || rc == -EAGAIN) { // either no script or paused, nothing to do diff --git a/src/rgw/rgw_lua_utils.h b/src/rgw/rgw_lua_utils.h index be7c13b20e2..5a3ce96a926 100644 --- a/src/rgw/rgw_lua_utils.h +++ b/src/rgw/rgw_lua_utils.h @@ -70,7 +70,7 @@ void stack_dump(lua_State* L); class lua_state_guard { const std::size_t max_memory; const std::chrono::milliseconds max_runtime; - const ceph::real_clock::time_point start_time; + ceph::real_clock::time_point start_time; const DoutPrefixProvider* const dpp; lua_State* const state; @@ -82,6 +82,7 @@ class lua_state_guard { const DoutPrefixProvider* _dpp); ~lua_state_guard(); lua_State* get() { return state; } + void reset_start_time() { start_time = ceph::real_clock::now(); } }; int dostring(lua_State* L, const char* str); -- 2.47.3