From: Mark Kogan Date: Thu, 23 May 2024 12:17:22 +0000 (+0000) Subject: rgw: delay the RGW process exit until all actice requests have completed X-Git-Tag: v20.0.0~948^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=575f5d461706b02a596d5ce959e5fb1aa87c1d8c;p=ceph.git 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 --- diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index 5cb7aee81f1e..e9d651fad8ab 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 ace3b7aff49e..855b9650f0ca 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();