]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/lua: fix a crash when D4N is enabled 67638/head
authorNithya Balachandran <nithya.balachandran@ibm.com>
Wed, 4 Mar 2026 06:19:00 +0000 (06:19 +0000)
committerNithya Balachandran <nithya.balachandran@ibm.com>
Wed, 4 Mar 2026 06:23:48 +0000 (06:23 +0000)
This change addresses a crash in Lua which happens when the lua
Background is not set in the LuaManager. Specifically, this occurs
when rgw_filter is set to d4n, as the env.driver is not the rados
driver in that scenario.

Fixes: https://tracker.ceph.com/issues/75306
Signed-off-by: Nithya Balachandran <nithya.balachandran@ibm.com>
src/rgw/driver/rados/rgw_sal_rados.cc
src/rgw/rgw_sal_store.h

index 39c46d6b98b64cdcf81e9fd24c4e272c21f53cce..f56f386c8cc3f30fb369e5e5efaf482a41fcf0d5 100644 (file)
@@ -5362,6 +5362,9 @@ std::string RadosLuaManager::get_script_for_watch_handle(uint64_t handle) {
 }
 
 int RadosLuaManager::watch_script(const DoutPrefixProvider* dpp, const std::string& script_oid) {
+  if(!lua_background) {
+    return 0;
+  }
 
   if (get_watch_handle_for_script(script_oid) == 0) {
     uint64_t w_handle;
@@ -5384,7 +5387,9 @@ int RadosLuaManager::watch_script(const DoutPrefixProvider* dpp, const std::stri
 }
 
 int RadosLuaManager::unwatch_script(const DoutPrefixProvider* dpp, const std::string& script_oid) {
-
+  if(!lua_background) {
+    return 0;
+  }
   if (!ioctx_scripts.is_valid()) {
     ldpp_dout(dpp, 1) << "ERROR: invalid pool when unwatch Lua script " << script_oid << dendl;
     return 0;
@@ -5441,23 +5446,27 @@ std::tuple<rgw::lua::LuaCodeType, int> RadosLuaManager::get_script_or_bytecode(c
     ldpp_dout(dpp, 10) << "WARNING: missing pool when reading Lua script " << dendl;
     return std::make_tuple("", 0);
   }
-  std::vector<char> lua_bytecode;
-  lua_bytecode.clear();
-  // First try to get the bytecode
-  int r = lua_background->get_script_bytecode(key, lua_bytecode);
-  if (r == 0) {
-    return std::make_tuple(lua_bytecode, 0);
-  }
 
+  if (lua_background) {
+    std::vector<char> lua_bytecode;
+    lua_bytecode.clear();
+    // First try to get the bytecode
+    int r = lua_background->get_script_bytecode(key, lua_bytecode);
+    if (r == 0) {
+      return std::make_tuple(lua_bytecode, 0);
+    }
+  }
   std::string script;
   bufferlist bl;
-  r = rgw_get_system_obj(store->svc()->sysobj, pool, key, bl, nullptr, nullptr, y, dpp);
+  int r = rgw_get_system_obj(store->svc()->sysobj, pool, key, bl, nullptr, nullptr, y, dpp);
   if (r < 0) {
     return std::make_tuple("", r);
   }
 
   // The bytecode has not been cached yet. Let the lua background know.
-  lua_background->process_script_add(key);
+  if (lua_background) {
+    lua_background->process_script_add(key);
+  }
 
   auto iter = bl.cbegin();
   try {
@@ -5544,7 +5553,9 @@ void RadosLuaManager::handle_script_update_notify(const DoutPrefixProvider* dpp,
     return;
   }
   // Let the background thread know to remove the bytecode from the cache
-  lua_background->process_script_add(key);
+  if (lua_background) {
+    lua_background->process_script_add(key);
+  }
   ack_script_update(dpp, notify_id, cookie, 0);
 }
 
index f37d2752f59273ffdd7f4fd8afed4a7d4c7d5f2e..28626a2e2ed6f0eb52287b5ca8f89bf369c1ba05 100644 (file)
@@ -534,7 +534,7 @@ public:
 
   StoreLuaManager() = default;
   StoreLuaManager(const std::string& __luarocks_path) :
-    _luarocks_path(__luarocks_path) {}
+    _luarocks_path(__luarocks_path), lua_background(nullptr) {}
   virtual ~StoreLuaManager() = default;
 };