]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/lua: Fix - Reset Lua background start time for accurate time limit
authorOshry Avraham <oshry.dev@gmail.com>
Tue, 28 Jan 2025 22:58:18 +0000 (00:58 +0200)
committerOshry Avraham <oshry.dev@gmail.com>
Tue, 28 Jan 2025 22:58:18 +0000 (00:58 +0200)
Resolved an issue where the Lua background would always exceed the execution time limit.

Signed-off-by: Oshrey Avraham <oshrey16@gmail.com>
src/rgw/rgw_lua_background.cc
src/rgw/rgw_lua_utils.h

index 8121a774332a2db5f38de2686a7e852656c1fb2e..9182ba45b37887fbb3e7ca9e6d029da2e58cba43 100644 (file)
@@ -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
index be7c13b20e21f838319a941b9dbe8ce322ffaf22..5a3ce96a92685d124dbc69f867f243e1798dc855 100644 (file)
@@ -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);