Repository navigation
squid: rgw: Fix crashes on realm reload - #70295
Conversation
… header Just like rgw_asio_frontend_timer.h, factor out the Connection struct and ConnectionList class from the anonymous namespace in rgw_asio_frontend.cc to a new header rgw_asio_frontend_connection.h (under namespace rgw::asio). This is especially needed to get better coverage thru unittesting. This is non-functional: no logic changes, the types, methods, and behavior are identical as before. The frontend .cc uses type aliases to maintain the same unqualified names. Signed-off-by: Oguzhan Ozmen <[email protected]> (cherry picked from commit 222a393) Fixes: https://tracker.ceph.com/issues/78306 Signed-off-by: Adam C. Emerson <[email protected]>
ConnectionList::close() is called from the main thread during
AsioFrontend::stop(), but io_context pool threads may still have
pending async_write operations on those sockets. The old code called
socket.close() which is a boost::asio thread-safety violation:
- it NULLifies descriptor_data in the epoll reactor which causes
concurrent start_op calls to dereference NULL (SIGSEGV), or
- it deregisters the fd from epoll, orphaning pending operations so
their completion handlers would never fire (hang)
Fix by using socket.cancel() + native ::shutdown():
- cancel() dequeues pending operations from the reactor's
per-descriptor queue and adds completions with
operation_aborted. This should handle writes blocked in epoll.
- shutdown(fd, SHUT_RDWR) disables the transport so any
strand-queued writes that haven't entered epoll yet will fail
with EPIPE on the next send() attempt
Also remove connections.clear() since coroutines exited via I/O error
and their RAII Guard removes them from the list on destruction.
This follows the same principle as the fix for
https://tracker.ceph.com/issues/58670 which handles the same scenario
in timeout_handler path.
Bottomlime, socket operations must not be performed from outside the owning
strand.
Fixes: https://tracker.ceph.com/issues/77658
Signed-off-by: Oguzhan Ozmen <[email protected]>
(cherry picked from commit 15915c8)
Fixes: https://tracker.ceph.com/issues/78306
Signed-off-by: Adam C. Emerson <[email protected]>
This is meant to be used in unittesting. Signed-off-by: Oguzhan Ozmen <[email protected]> (cherry picked from commit 179b873) Fixes: https://tracker.ceph.com/issues/78306 Signed-off-by: Adam C. Emerson <[email protected]>
Tests: https://tracker.ceph.com/issues/77658 Signed-off-by: Oguzhan Ozmen <[email protected]> (cherry picked from commit 19748f1) Conflicts: src/test/rgw/CMakeLists.txt - Added test came after targets existing in main but not squid Fixes: https://tracker.ceph.com/issues/78306 Signed-off-by: Adam C. Emerson <[email protected]>
Without this we can end up in an infinite loop where we just fill the log with -ECANCELED from `get_next()`. Duplicates a check in the `blocked_operations` loop. Fixes: https://tracker.ceph.com/issues/76094 Signed-off-by: Adam C. Emerson <[email protected]> (cherry picked from commit 17f994f) Fixes: https://tracker.ceph.com/issues/78120 Signed-off-by: Adam C. Emerson <[email protected]>
To prevent a race condition/crash on realm reload where sync was trying to put objects through quota before quota was initialized. Fixes: https://tracker.ceph.com/issues/76094 Fixes: https://tracker.ceph.com/issues/77883 Signed-off-by: Adam C. Emerson <[email protected]> (cherry picked from commit e8639cc) Conflicts: src/rgw/driver/rados/rgw_rados.cc - Relative to main, we lack the restore thread and have the index completion manager. Fixes: https://tracker.ceph.com/issues/78120 Fixes: https://tracker.ceph.com/issues/78370 Signed-off-by: Adam C. Emerson <[email protected]>
Previously if we received an rvalue function object we would call a moved-from object on all but the first thread. In practice this didn't cause an issue, but only because of the functions we were passing. Fixes: https://tracker.ceph.com/issues/76094 Signed-off-by: Adam C. Emerson <[email protected]> (cherry picked from commit 3ab380f) Fixes: https://tracker.ceph.com/issues/78120 Signed-off-by: Adam C. Emerson <[email protected]>
AsioFrontend::pause() (and stop()) call ConnectionList::close() from the realm reloader thread. That invokes socket.close() on every live connection from a thread that isn't the connection's asio strand, so the reactor deregisters each socket's descriptor_state racing against the coroutine that handles the connection. If a keep-alive connection is starting its next async_read_some() on its strand at the same time, epoll_reactor::start_op() dereferences the descriptor_state that close has already freed and radosgw segfaults in an io_context_pool thread. This matches the race pattern fixed for timeout_timer in 86ad0b8: any caller that touches socket state from outside the strand needs to be serialized with the coroutine. Store the coroutine's strand executor on Connection and dispatch the close onto that strand in ConnectionList::close(). The lambda captures an intrusive_ptr to Connection so the object lives until the close actually runs, since connections.clear() unlinks the list entry right after dispatch. Tracker: https://tracker.ceph.com/issues/76094 Signed-off-by: Lumir Sliva <[email protected]> Update `unittest_rgw_asio_frontend` to run the `io_context` and execute in a coroutine to match the environment in RGW. Signed-off-by: Adam C. Emerson <[email protected]> (cherry picked from commit 1430b88) Conflicts: src/rgw/rgw_asio_frontend.cc - Graceful shutdown option does not exist in squid Fixes: https://tracker.ceph.com/issues/78120 Signed-off-by: Adam C. Emerson <[email protected]>
There was a problem hiding this comment.
Ceph Release Engineering Audit Report
Automated Backport Parity Review
Discrepancies detected between the backport PR and the original source PR(s). Please see the Commit Parity Visualizer below.
Commit Parity Visualizer
| BACKPORT PR #70295 | SOURCE PR |
SOURCE STATUS |
|---|---|---|
0dcd788 rgw: Check going_down in other-than-interval_set loop |
PR #68920 | 17f994f rgw: Check going_down in other-than-interval_set loop |
| bb82013 rgw/rados: Initialize things before starting threads that use them | e8639cc rgw/rados: Initialize things before starting threads that use them | |
| <<<< MISSING IN BACKPORT >>>> | 3a09906 rgw: Fix name and add operators for io_context holder | |
0df2815 common/async: io_context_pool no longer moves from init function |
3ab380f common/async: io_context_pool no longer moves from init function |
|
| 3cdeb0c rgw/beast: dispatch connection close on strand during pause | 1430b88 rgw/beast: dispatch connection close on strand during pause | |
| 1b2e698 rgw/beast: (non-functional) refactor Connection and ConnectionList to header | PR #69713 | 222a393 rgw/beast: (non-functional) refactor Connection and ConnectionList to header |
| 98d1d48 rgw/beast: fix shutdown crash in ConnectionList::close() | 15915c8 rgw/beast: fix shutdown crash in ConnectionList::close() | |
| 02cdb3a rgw/beast: (non-functional change) add size method to ConnectionList | 179b873 rgw/beast: (non-functional change) add size method to ConnectionList | |
| 2055416 test/rgw/beast: add unit test for ConnectionList shutdown behavior | 19748f1 test/rgw/beast: add unit test for ConnectionList shutdown behavior |
Automated Backport Parity Review - Cherry-Pick Conflicts / Deviations
A conflict or deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.
This does not necessarily indicate an issue but a maintainer should review.
**Click to expand conflict summaries.**
Deviation in Backport 2055416 (cherry-pick of 19748f1)
Affected File(s)
src/test/rgw/CMakeLists.txt
Range Diff
Click to expand
--- Original (19748f17)
+++ Backport (20554163)
@@ -2,3 +2,11 @@
Tests: https://tracker.ceph.com/issues/77658
Signed-off-by: Oguzhan Ozmen <[email protected]>
+(cherry picked from commit 19748f1767b85b44c17acca7318957118e196fdf)
+
+Conflicts:
+ src/test/rgw/CMakeLists.txt
+ - Added test came after targets existing in main but not squid
+
+Fixes: https://tracker.ceph.com/issues/78306
+Signed-off-by: Adam C. Emerson <[email protected]>
================================================================================
RANGE DIFF
================================================================================
1: 19748f1767b ! 1: 20554163dc0 test/rgw/beast: add unit test for ConnectionList shutdown behavior
@@ Commit message
Tests: https://tracker.ceph.com/issues/77658
Signed-off-by: Oguzhan Ozmen <[email protected]>
+ (cherry picked from commit 19748f1767b85b44c17acca7318957118e196fdf)
+
+ Conflicts:
+ src/test/rgw/CMakeLists.txt
+ - Added test came after targets existing in main but not squid
+
+ Fixes: https://tracker.ceph.com/issues/78306
+ Signed-off-by: Adam C. Emerson <[email protected]>
## src/test/rgw/CMakeLists.txt ##
-@@ src/test/rgw/CMakeLists.txt: add_executable(unittest_rgw_async_utils test_rgw_async_utils.cc)
- add_ceph_unittest(unittest_rgw_async_utils)
- target_link_libraries(unittest_rgw_async_utils ${rgw_libs} ${UNITTEST_LIBS})
+@@ src/test/rgw/CMakeLists.txt: if(WITH_RADOSGW_POSIX)
+ ${rgw_libs} ${LMDB_LIBRARIES})
+ endif(WITH_RADOSGW_POSIX)
+add_executable(unittest_rgw_asio_frontend_connection test_rgw_asio_frontend_connection.cc)
+add_ceph_unittest(unittest_rgw_asio_frontend_connection)Deviation in Backport bb82013 (cherry-pick of e8639cc)
Affected File(s)
src/rgw/driver/rados/rgw_rados.cc
Range Diff
Click to expand
--- Original (e8639cc9)
+++ Backport (bb82013f)
@@ -6,3 +6,13 @@
Fixes: https://tracker.ceph.com/issues/76094
Fixes: https://tracker.ceph.com/issues/77883
Signed-off-by: Adam C. Emerson <[email protected]>
+(cherry picked from commit e8639cc9d4960cbe2a5bbdbf97a673b827c6bde9)
+
+Conflicts:
+ src/rgw/driver/rados/rgw_rados.cc
+ - Relative to main, we lack the restore thread and have the index
+ completion manager.
+
+Fixes: https://tracker.ceph.com/issues/78120
+Fixes: https://tracker.ceph.com/issues/78370
+Signed-off-by: Adam C. Emerson <[email protected]>
================================================================================
RANGE DIFF
================================================================================
1: e8639cc9d49 ! 1: bb82013fcc1 rgw/rados: Initialize things before starting threads that use them
@@ Commit message
Fixes: https://tracker.ceph.com/issues/76094
Fixes: https://tracker.ceph.com/issues/77883
Signed-off-by: Adam C. Emerson <[email protected]>
+ (cherry picked from commit e8639cc9d4960cbe2a5bbdbf97a673b827c6bde9)
+
+ Conflicts:
+ src/rgw/driver/rados/rgw_rados.cc
+ - Relative to main, we lack the restore thread and have the index
+ completion manager.
+
+ Fixes: https://tracker.ceph.com/issues/78120
+ Fixes: https://tracker.ceph.com/issues/78370
+ Signed-off-by: Adam C. Emerson <[email protected]>
## src/rgw/driver/rados/rgw_rados.cc ##
-@@ src/rgw/driver/rados/rgw_rados.cc: int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y, rgw
+@@ src/rgw/driver/rados/rgw_rados.cc: int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y)
auto& zone_params = svc.zone->get_zone_params();
auto& zone = svc.zone->get_zone();
@@ src/rgw/driver/rados/rgw_rados.cc: int RGWRados::init_complete(const DoutPrefixP
+ lc = new RGWLC();
+ lc->initialize(cct, this->driver);
+
-+ restore = make_unique<rgw::restore::Restore>();
-+ ret = restore->initialize(cct, this->driver);
-+
-+ if (ret < 0) {
-+ ldpp_dout(dpp, 0) << "ERROR: failed to initialize restore thread" << dendl;
-+ return ret;
-+ }
-+
+ quota_handler = RGWQuotaHandler::generate_handler(dpp, this->driver, quota_threads);
+
+ bucket_index_max_shards = (cct->_conf->rgw_override_bucket_index_max_shards ? cct->_conf->rgw_override_bucket_index_max_shards :
@@ src/rgw/driver/rados/rgw_rados.cc: int RGWRados::init_complete(const DoutPrefixP
+
+ // disable reshard thread based on zone/zonegroup support
+ run_reshard_thread = run_reshard_thread && svc.zone->can_reshard();
++
++ index_completion_manager = new RGWIndexCompletionManager(this);
+
/* no point of running sync thread if we don't have a master zone configured
or there is no rest_master_conn */
if (!svc.zone->need_to_sync()) {
-@@ src/rgw/driver/rados/rgw_rados.cc: int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y, rgw
+@@ src/rgw/driver/rados/rgw_rados.cc: int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y)
data_notifier->start();
}
@@ src/rgw/driver/rados/rgw_rados.cc: int RGWRados::init_complete(const DoutPrefixP
if (use_lc_thread)
lc->start_processor();
-- restore = make_unique<rgw::restore::Restore>();
-- ret = restore->initialize(cct, this->driver);
--
-- if (ret < 0) {
-- ldpp_dout(dpp, 0) << "ERROR: failed to initialize restore thread" << dendl;
-- return ret;
-- }
--
- if (use_restore_thread)
- restore->start_processor();
-
- quota_handler = RGWQuotaHandler::generate_handler(dpp, this->driver, quota_threads);
-
- bucket_index_max_shards = (cct->_conf->rgw_override_bucket_index_max_shards ? cct->_conf->rgw_override_bucket_index_max_shards :
@@ src/rgw/driver/rados/rgw_rados.cc: int RGWRados::init_complete(const DoutPrefixP
if (run_reshard_thread) {
reshard->start_processor();
}
+
+- index_completion_manager = new RGWIndexCompletionManager(this);
+-
+ if (run_notification_thread) {
+ if (!rgw::notify::init(dpp, driver, *svc.site)) {
+ ldpp_dout(dpp, 0) << "ERROR: failed to initialize notification manager" << dendl;Deviation in Backport 3cdeb0c (cherry-pick of 1430b88)
Affected File(s)
src/rgw/rgw_asio_frontend.cc
Range Diff
Click to expand
--- Original (1430b885)
+++ Backport (3cdeb0c8)
@@ -26,3 +26,11 @@
execute in a coroutine to match the environment in RGW.
Signed-off-by: Adam C. Emerson <[email protected]>
+(cherry picked from commit 1430b8855352b4d682e1186005861f18e9eb7e45)
+
+Conflicts:
+ src/rgw/rgw_asio_frontend.cc
+ - Graceful shutdown option does not exist in squid
+
+Fixes: https://tracker.ceph.com/issues/78120
+Signed-off-by: Adam C. Emerson <[email protected]>
================================================================================
RANGE DIFF
================================================================================
1: 1430b885535 ! 1: 3cdeb0c8753 rgw/beast: dispatch connection close on strand during pause
@@ Commit message
execute in a coroutine to match the environment in RGW.
Signed-off-by: Adam C. Emerson <[email protected]>
+ (cherry picked from commit 1430b8855352b4d682e1186005861f18e9eb7e45)
+
+ Conflicts:
+ src/rgw/rgw_asio_frontend.cc
+ - Graceful shutdown option does not exist in squid
+
+ Fixes: https://tracker.ceph.com/issues/78120
+ Signed-off-by: Adam C. Emerson <[email protected]>
## src/rgw/rgw_asio_frontend.cc ##
@@ src/rgw/rgw_asio_frontend.cc: void AsioFrontend::on_accept(Listener& l, tcp::socket stream)
@@ src/rgw/rgw_asio_frontend.cc: void AsioFrontend::on_accept(Listener& l, tcp::soc
boost::system::error_code ec;
@@ src/rgw/rgw_asio_frontend.cc: void AsioFrontend::stop()
}
-
+ ssl_reload_timer.cancel();
// close all connections
- connections.close(ec);
+ connections.close();
pause_mutex.cancel();
}
-@@ src/rgw/rgw_asio_frontend.cc: void AsioFrontend::pause()
- const bool graceful_stop{ g_ceph_context->_conf->rgw_graceful_stop };
- if (!graceful_stop) {
- // close all connections so outstanding requests fail quickly
-- connections.close(ec);
-+ connections.close();
- }
-
- // pause and wait until outstanding requests complete
## src/rgw/rgw_asio_frontend_connection.h ##
@@How to proceed:
- Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git
Conflicts:block intact) and include an explanation for changes. - Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
- Component Leads (Review): Please review the Range Diff(s) above to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting
/audit override.
Be familiar with the rules and guidelines for writing backports.
🛟 Need Help?
If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.
📋 Component Lead / Release Manager
To override the audit failure, apply releng-audit-override label or comment /audit override.
When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.
|
/audit override |
|
✅ Audit Override Applied by @adamemerson. |
|
This PR has been added to wip-yuri9-testing-20260720.140823-squid. |
Original trackers: https://tracker.ceph.com/issues/76094 https://tracker.ceph.com/issues/77658
Backport trackers: https://tracker.ceph.com/issues/78120 https://tracker.ceph.com/issues/78306
Original PRs: #68920 #69713
3a09906 is intentionally not included. It was a change to a cleanup (#66721) that does not need to be backported.