From: Adam C. Emerson Date: Wed, 1 Apr 2026 19:40:12 +0000 (-0400) Subject: rgw/rados: Initialize things before starting threads that use them X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e8639cc9d4960cbe2a5bbdbf97a673b827c6bde9;p=ceph.git rgw/rados: Initialize things before starting threads that use them 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 --- diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 5907e907534..697d9582371 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -1371,6 +1371,47 @@ int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y, rgw auto& zone_params = svc.zone->get_zone_params(); auto& zone = svc.zone->get_zone(); + binfo_cache = new RGWChainedCacheImpl; + binfo_cache->init(svc.cache); + + topic_cache = new RGWChainedCacheImpl; + topic_cache->init(svc.cache); + + lc = new RGWLC(); + lc->initialize(cct, this->driver); + + restore = make_unique(); + 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 : + zone.bucket_index_max_shards); + if (bucket_index_max_shards > get_max_bucket_shards()) { + bucket_index_max_shards = get_max_bucket_shards(); + ldpp_dout(dpp, 1) << __func__ << " bucket index max shards is too large, reset to value: " + << get_max_bucket_shards() << dendl; + } + ldpp_dout(dpp, 20) << __func__ << " bucket index max shards: " << bucket_index_max_shards << dendl; + + bool need_tombstone_cache = !svc.zone->get_zone_data_notify_to_map().empty(); /* have zones syncing from us */ + + if (need_tombstone_cache) { + obj_tombstone_cache = new tombstone_cache_t(cct->_conf->rgw_obj_tombstone_cache_size); + } + + reshard_wait = std::make_shared(); + + reshard = new RGWReshard(this->driver); + + // disable reshard thread based on zone/zonegroup support + run_reshard_thread = run_reshard_thread && svc.zone->can_reshard(); + /* 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()) { @@ -1449,53 +1490,12 @@ int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y, rgw data_notifier->start(); } - binfo_cache = new RGWChainedCacheImpl; - binfo_cache->init(svc.cache); - - topic_cache = new RGWChainedCacheImpl; - topic_cache->init(svc.cache); - - lc = new RGWLC(); - lc->initialize(cct, this->driver); - if (use_lc_thread) lc->start_processor(); - restore = make_unique(); - 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 : - zone.bucket_index_max_shards); - if (bucket_index_max_shards > get_max_bucket_shards()) { - bucket_index_max_shards = get_max_bucket_shards(); - ldpp_dout(dpp, 1) << __func__ << " bucket index max shards is too large, reset to value: " - << get_max_bucket_shards() << dendl; - } - ldpp_dout(dpp, 20) << __func__ << " bucket index max shards: " << bucket_index_max_shards << dendl; - - bool need_tombstone_cache = !svc.zone->get_zone_data_notify_to_map().empty(); /* have zones syncing from us */ - - if (need_tombstone_cache) { - obj_tombstone_cache = new tombstone_cache_t(cct->_conf->rgw_obj_tombstone_cache_size); - } - - reshard_wait = std::make_shared(); - - reshard = new RGWReshard(this->driver); - - // disable reshard thread based on zone/zonegroup support - run_reshard_thread = run_reshard_thread && svc.zone->can_reshard(); - if (run_reshard_thread) { reshard->start_processor(); }