From: kchheda3 Date: Thu, 20 Feb 2025 18:53:44 +0000 (-0500) Subject: rgw/log: Fix crash during shutdown with ops-log enable. X-Git-Tag: v20.3.0~447^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=374ddbc0e8767feda1d596517451293371211cc5;p=ceph.git rgw/log: Fix crash during shutdown with ops-log enable. Ensure the env.olog member variable is destructed at last, once all the frontends have stopped accepting new connections and have finished processing the existing connections. Signed-off-by: kchheda3 --- diff --git a/src/rgw/rgw_appmain.cc b/src/rgw/rgw_appmain.cc index 2a04ff4ec95..ded764dde39 100644 --- a/src/rgw/rgw_appmain.cc +++ b/src/rgw/rgw_appmain.cc @@ -407,7 +407,7 @@ void rgw::AppMain::init_opslog() olog_manifold->add_sink(ops_log_file); } olog_manifold->add_sink(new OpsLogRados(env.driver)); - olog = olog_manifold; + env.olog.reset(olog_manifold); } /* init_opslog */ int rgw::AppMain::init_frontends2(RGWLib* rgwlib) @@ -449,7 +449,6 @@ int rgw::AppMain::init_frontends2(RGWLib* rgwlib) // initialize RGWProcessEnv env.rest = &rest; - env.olog = olog; env.auth_registry = rgw::auth::StrategyRegistry::create( dpp->get_cct(), *implicit_tenant_context, env.driver); env.ratelimiting = ratelimiter.get(); @@ -597,8 +596,6 @@ void rgw::AppMain::shutdown(std::function finalize_async_signals) ldh.reset(nullptr); // deletes ldap helper if it was created rgw_log_usage_finalize(); - delete olog; - if (lua_background) { lua_background->shutdown(); } diff --git a/src/rgw/rgw_lib.cc b/src/rgw/rgw_lib.cc index 59443c52b02..5ffb7cf632c 100644 --- a/src/rgw/rgw_lib.cc +++ b/src/rgw/rgw_lib.cc @@ -316,7 +316,7 @@ namespace rgw { << e.what() << dendl; } if (should_log) { - rgw_log_op(nullptr /* !rest */, s, op, env.olog); + rgw_log_op(nullptr /* !rest */, s, op, env.olog.get()); } int http_ret = s->err.http_ret; diff --git a/src/rgw/rgw_main.h b/src/rgw/rgw_main.h index d106485855a..3a729aa6309 100644 --- a/src/rgw/rgw_main.h +++ b/src/rgw/rgw_main.h @@ -67,7 +67,6 @@ class AppMain { std::vector fe_configs; std::multimap fe_map; std::unique_ptr ldh; - OpsLogSink* olog = nullptr; RGWREST rest; std::unique_ptr lua_background; std::unique_ptr implicit_tenant_context; diff --git a/src/rgw/rgw_process.cc b/src/rgw/rgw_process.cc index 8d0b020ae57..fe1ff8c6e30 100644 --- a/src/rgw/rgw_process.cc +++ b/src/rgw/rgw_process.cc @@ -342,7 +342,8 @@ int process_request(const RGWProcessEnv& penv, "WARNING: failed to execute pre request script. " "error: " << rc << dendl; } else { - rc = rgw::lua::request::execute(driver, rest, penv.olog, s, op, script); + rc = rgw::lua::request::execute(driver, rest, penv.olog.get(), s, op, + script); if (rc < 0) { ldpp_dout(op, 5) << "WARNING: failed to execute pre request script. " @@ -440,7 +441,8 @@ done: "WARNING: failed to read post request script. " "error: " << rc << dendl; } else { - rc = rgw::lua::request::execute(driver, rest, penv.olog, s, op, script); + rc = rgw::lua::request::execute(driver, rest, penv.olog.get(), s, op, + script); if (rc < 0) { ldpp_dout(op, 5) << "WARNING: failed to execute post request script. " @@ -459,7 +461,7 @@ done: perfcounter->inc(l_rgw_qactive, -1); } if (should_log) { - rgw_log_op(rest, s, op, penv.olog); + rgw_log_op(rest, s, op, penv.olog.get()); } if (op) { diff --git a/src/rgw/rgw_process_env.h b/src/rgw/rgw_process_env.h index 710340f0a25..d298c15069a 100644 --- a/src/rgw/rgw_process_env.h +++ b/src/rgw/rgw_process_env.h @@ -42,7 +42,7 @@ struct RGWProcessEnv { rgw::sal::Driver* driver = nullptr; rgw::SiteConfig* site = nullptr; RGWREST *rest = nullptr; - OpsLogSink *olog = nullptr; + std::unique_ptr olog; std::unique_ptr auth_registry; ActiveRateLimiter* ratelimiting = nullptr;