From 575f5d461706b02a596d5ce959e5fb1aa87c1d8c Mon Sep 17 00:00:00 2001 From: Mark Kogan Date: Thu, 23 May 2024 12:17:22 +0000 Subject: [PATCH] rgw: delay the RGW process exit until all actice requests have completed Wait for up to `rgw_exit_timeout_secs` for all outstanding requests to complete before exiting unconditionally. (new HTTP requests will not be accepted during this time.) Fixes: https://tracker.ceph.com/issues/66205 Signed-off-by: Mark Kogan --- src/common/options/rgw.yaml.in | 12 ++++++++++++ src/rgw/rgw_asio_frontend.cc | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index 5cb7aee81f1e4..e9d651fad8abf 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -1867,6 +1867,18 @@ options: services: - rgw with_legacy: true +- name: rgw_graceful_stop + type: bool + level: advanced + desc: Delay the shutdown until all outstanding requests have completed + long_desc: Wait for up to `rgw_exit_timeout_secs` for all outstanding requests to complete + before exiting unconditionally. (new HTTP requests will not be accepted during this time.) + default: false + services: + - rgw + see_also: + - rgw_exit_timeout_secs + with_legacy: true - name: rgw_get_obj_window_size type: size level: advanced diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index ace3b7aff49e9..855b9650f0ca5 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -1086,6 +1086,20 @@ void AsioFrontend::stop() for (auto& listener : listeners) { listener.acceptor.close(ec); } + + const bool graceful_stop{ g_ceph_context->_conf->rgw_graceful_stop }; + if (graceful_stop) { + ldout(ctx(), 4) << "frontend pausing and waiting for outstanding requests to complete..." << dendl; + pause_mutex.lock(ec); + if (ec) { + ldout(ctx(), 1) << "frontend failed to pause: " << ec.message() << dendl; + } else { + ldout(ctx(), 4) << "frontend paused" << dendl; + } + ldout(ctx(), 4) << "frontend outstanding requests have completed" << dendl; + pause_mutex.unlock(); + } + // close all connections connections.close(ec); pause_mutex.cancel(); -- 2.39.5