From 965b48e8d137334412e83c514a61fa5d37577d47 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 3 Jul 2019 10:56:43 -0700 Subject: [PATCH] rgw: svc.mdlog: init oldest log period only if we're syncing Need to diffrerentiate between need to sync and actually syncing. Zone might need to sync, but we're running in radosgw-admin and we don't actually sync. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 2 +- src/rgw/rgw_rest_log.cc | 6 +++--- src/rgw/rgw_service.cc | 9 +++++---- src/rgw/rgw_service.h | 10 +++++----- src/rgw/rgw_sync.cc | 1 - src/rgw/services/svc_mdlog.cc | 5 +++-- src/rgw/services/svc_mdlog.h | 4 +++- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 280741c4373..2efc833af5f 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1314,7 +1314,7 @@ int RGWRados::init_svc(bool raw) return svc.init_raw(cct, use_cache); } - return svc.init(cct, use_cache); + return svc.init(cct, use_cache, run_sync_thread); } int RGWRados::init_ctl() diff --git a/src/rgw/rgw_rest_log.cc b/src/rgw/rgw_rest_log.cc index 9f3567664ef..0fcb3f1d36e 100644 --- a/src/rgw/rgw_rest_log.cc +++ b/src/rgw/rgw_rest_log.cc @@ -397,7 +397,7 @@ void RGWOp_BILog_List::execute() { } if (!bucket_instance.empty()) { - rgw_bucket b(rgw_bucket_key(tenant_name, bucket_name, bucket_instance)); + rgw_bucket b(rgw_bucket_key(tenant_name, bn, bucket_instance)); http_ret = store->get_bucket_instance_info(*s->sysobj_ctx, b, bucket_info, NULL, NULL, s->yield); if (http_ret < 0) { ldpp_dout(s, 5) << "could not get bucket instance info for bucket instance id=" << bucket_instance << dendl; @@ -490,7 +490,7 @@ void RGWOp_BILog_Info::execute() { } if (!bucket_instance.empty()) { - rgw_bucket b(rgw_bucket_key(tenant_name, bucket_name, bucket_instance)); + rgw_bucket b(rgw_bucket_key(tenant_name, bn, bucket_instance)); http_ret = store->get_bucket_instance_info(*s->sysobj_ctx, b, bucket_info, NULL, NULL, s->yield); if (http_ret < 0) { ldpp_dout(s, 5) << "could not get bucket instance info for bucket instance id=" << bucket_instance << dendl; @@ -554,7 +554,7 @@ void RGWOp_BILog_Delete::execute() { } if (!bucket_instance.empty()) { - rgw_bucket b(rgw_bucket_key(tenant_name, bucket_name, bucket_instance)); + rgw_bucket b(rgw_bucket_key(tenant_name, bn, bucket_instance)); http_ret = store->get_bucket_instance_info(*s->sysobj_ctx, b, bucket_info, NULL, NULL, s->yield); if (http_ret < 0) { ldpp_dout(s, 5) << "could not get bucket instance info for bucket instance id=" << bucket_instance << dendl; diff --git a/src/rgw/rgw_service.cc b/src/rgw/rgw_service.cc index 34a7271d024..0f909a6b1a6 100644 --- a/src/rgw/rgw_service.cc +++ b/src/rgw/rgw_service.cc @@ -44,7 +44,8 @@ RGWServices_Def::~RGWServices_Def() int RGWServices_Def::init(CephContext *cct, bool have_cache, - bool raw) + bool raw, + bool run_sync) { finisher = std::make_unique(cct); bucket_sobj = std::make_unique(cct); @@ -52,7 +53,7 @@ int RGWServices_Def::init(CephContext *cct, bilog_rados = std::make_unique(cct); cls = std::make_unique(cct); datalog_rados = std::make_unique(cct); - mdlog = std::make_unique(cct); + mdlog = std::make_unique(cct, run_sync); meta = std::make_unique(cct); meta_be_sobj = std::make_unique(cct); meta_be_otp = std::make_unique(cct); @@ -253,11 +254,11 @@ void RGWServices_Def::shutdown() } -int RGWServices::do_init(CephContext *_cct, bool have_cache, bool raw) +int RGWServices::do_init(CephContext *_cct, bool have_cache, bool raw, bool run_sync) { cct = _cct; - int r = _svc.init(cct, have_cache, raw); + int r = _svc.init(cct, have_cache, raw, run_sync); if (r < 0) { return r; } diff --git a/src/rgw/rgw_service.h b/src/rgw/rgw_service.h index e4269120223..1bbbb786a71 100644 --- a/src/rgw/rgw_service.h +++ b/src/rgw/rgw_service.h @@ -100,7 +100,7 @@ struct RGWServices_Def RGWServices_Def(); ~RGWServices_Def(); - int init(CephContext *cct, bool have_cache, bool raw_storage); + int init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync); void shutdown(); }; @@ -135,14 +135,14 @@ struct RGWServices RGWSI_SysObj_Core *core{nullptr}; RGWSI_User *user{nullptr}; - int do_init(CephContext *cct, bool have_cache, bool raw_storage); + int do_init(CephContext *cct, bool have_cache, bool raw_storage, bool run_sync); - int init(CephContext *cct, bool have_cache) { - return do_init(cct, have_cache, false); + int init(CephContext *cct, bool have_cache, bool run_sync) { + return do_init(cct, have_cache, false, run_sync); } int init_raw(CephContext *cct, bool have_cache) { - return do_init(cct, have_cache, true); + return do_init(cct, have_cache, true, false); } void shutdown() { _svc.shutdown(); diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index 0270a0aecef..ea7f61883d6 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -1265,7 +1265,6 @@ int RGWMetaSyncSingleEntryCR::operate() { if (error_injection && rand() % 10000 < cct->_conf->rgw_sync_meta_inject_err_probability * 10000.0) { - ldpp_dout(sync_env->dpp, 0) << __FILE__ << ":" << __LINE__ << ": injecting meta sync error on key=" << raw_key << dendl; return set_cr_error(-EIO); } diff --git a/src/rgw/services/svc_mdlog.cc b/src/rgw/services/svc_mdlog.cc index a8f35fe837e..45868e8fc28 100644 --- a/src/rgw/services/svc_mdlog.cc +++ b/src/rgw/services/svc_mdlog.cc @@ -18,7 +18,7 @@ using Svc = RGWSI_MDLog::Svc; using Cursor = RGWPeriodHistory::Cursor; -RGWSI_MDLog::RGWSI_MDLog(CephContext *cct) : RGWServiceInstance(cct) { +RGWSI_MDLog::RGWSI_MDLog(CephContext *cct, bool _run_sync) : RGWServiceInstance(cct), run_sync(_run_sync) { } RGWSI_MDLog::~RGWSI_MDLog() { @@ -45,7 +45,8 @@ int RGWSI_MDLog::do_start() period_history.reset(new RGWPeriodHistory(cct, period_puller.get(), current_period)); - if (svc.zone->need_to_sync()) { + if (run_sync && + svc.zone->need_to_sync()) { // initialize the log period history svc.mdlog->init_oldest_log_period(); } diff --git a/src/rgw/services/svc_mdlog.h b/src/rgw/services/svc_mdlog.h index 7649233e7a0..b2e7e4f38aa 100644 --- a/src/rgw/services/svc_mdlog.h +++ b/src/rgw/services/svc_mdlog.h @@ -47,13 +47,15 @@ class RGWSI_MDLog : public RGWServiceInstance // use the current period's log for mutating operations RGWMetadataLog* current_log{nullptr}; + bool run_sync; + // pulls missing periods for period_history std::unique_ptr period_puller; // maintains a connected history of periods std::unique_ptr period_history; public: - RGWSI_MDLog(CephContext *cct); + RGWSI_MDLog(CephContext *cct, bool run_sync); virtual ~RGWSI_MDLog(); struct Svc { -- 2.39.5