From 9c4983d21f74121d34bcf7cab5d9b3b4c72ea4da Mon Sep 17 00:00:00 2001 From: gal salomon Date: Thu, 8 Jan 2026 18:46:55 +0000 Subject: [PATCH] rgw/d4n: passing the dpp to RedisPool::acquire to fix nullptr crash Fix segfault when Redis connection pool is exhausted by passing the DoutPrefixProvider parameter through redis_exec_cp() to acquire(), preventing null reference in maybe_warn_about_blocking() Signed-off-by: gal salomon --- src/rgw/driver/d4n/d4n_directory.cc | 14 ++++++++------ src/rgw/driver/d4n/d4n_directory.h | 8 +++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/rgw/driver/d4n/d4n_directory.cc b/src/rgw/driver/d4n/d4n_directory.cc index efc30293dc51a..daadabed8dbc0 100644 --- a/src/rgw/driver/d4n/d4n_directory.cc +++ b/src/rgw/driver/d4n/d4n_directory.cc @@ -51,14 +51,15 @@ void redis_exec(std::shared_ptr conn, } template -void redis_exec_cp(std::shared_ptr pool, +void redis_exec_cp(const DoutPrefixProvider* dpp, + std::shared_ptr pool, boost::system::error_code& ec, const boost::redis::request& req, boost::redis::response& resp, optional_yield y) { //purpose: Execute a Redis command using a connection from the pool - std::shared_ptr conn = pool->acquire(); + std::shared_ptr conn = pool->acquire(dpp); try { if (y) { @@ -89,13 +90,14 @@ void redis_exec(std::shared_ptr conn, } } -void redis_exec_cp(std::shared_ptr pool, +void redis_exec_cp(const DoutPrefixProvider* dpp, + std::shared_ptr pool, boost::system::error_code& ec, const boost::redis::request& req, boost::redis::generic_response& resp, optional_yield y) { //purpose: Execute a Redis command using a connection from the pool - std::shared_ptr conn = pool->acquire(); + std::shared_ptr conn = pool->acquire(dpp); try { if (y) { @@ -136,7 +138,7 @@ void redis_exec_connection_pool(const DoutPrefixProvider* dpp, ldpp_dout(dpp, 0) << "Directory::" << __func__ << " not using connection-pool, it's using the shared connection " << dendl; } else[[likely]] - redis_exec_cp(redis_pool, ec, req, resp, y); + redis_exec_cp(dpp, redis_pool, ec, req, resp, y); } template @@ -154,7 +156,7 @@ void redis_exec_connection_pool(const DoutPrefixProvider* dpp, ldpp_dout(dpp, 0) << "Directory::" << __func__ << " not using connection-pool, it's using the shared connection " << dendl; } else[[likely]] - redis_exec_cp(redis_pool, ec, req, resp, y); + redis_exec_cp(dpp, redis_pool, ec, req, resp, y); } int BucketDirectory::zadd(const DoutPrefixProvider* dpp, const std::string& bucket_id, double score, const std::string& member, optional_yield y, Pipeline* pipeline) diff --git a/src/rgw/driver/d4n/d4n_directory.h b/src/rgw/driver/d4n/d4n_directory.h index 26c899d2275e7..f20cb00d9b2a8 100644 --- a/src/rgw/driver/d4n/d4n_directory.h +++ b/src/rgw/driver/d4n/d4n_directory.h @@ -34,7 +34,7 @@ public: cancel_all(); } - std::shared_ptr acquire() { + std::shared_ptr acquire(const DoutPrefixProvider* dpp = nullptr) { std::unique_lock lock(m_aquire_release_mtx); if (!m_is_pool_connected) { @@ -46,10 +46,12 @@ public: } if (m_pool.empty()) { - maybe_warn_about_blocking(nullptr); + if (dpp) { + maybe_warn_about_blocking(dpp); + } //wait until m_pool is not empty m_cond_var.wait(lock, [this] { return !m_pool.empty(); }); - } + } auto conn = m_pool.front(); m_pool.pop_front(); return conn; -- 2.47.3