Skip to content

Commit

Permalink
rgw: get elastic search info in start_sync, avoid creating new corout…
Browse files Browse the repository at this point in the history
…ines manager

Fixes: https://tracker.ceph.com/issues/43199

Signed-off-by: Chang Liu <[email protected]>
  • Loading branch information
liuchang0812 committed Dec 16, 2019
1 parent 25a3c76 commit 2cd512e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
6 changes: 5 additions & 1 deletion src/rgw/rgw_data_sync.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,11 @@ class RGWDataSyncCR : public RGWCoroutine {
}

yield call(data_sync_module->start_sync(sync_env));

if (retcode < 0) {
tn->log(0, SSTR("ERROR: failed to start sync, retcode=" << retcode));
return set_cr_error(retcode);
}

yield {
if ((rgw_data_sync_info::SyncState)sync_status.sync_info.state == rgw_data_sync_info::StateSync) {
tn->log(10, SSTR("spawning " << num_shards << " shards sync"));
Expand Down
31 changes: 12 additions & 19 deletions src/rgw/rgw_sync_module_es.cc
Original file line number Diff line number Diff line change
Expand Up @@ -817,31 +817,24 @@ class RGWElasticDataSyncModule : public RGWDataSyncModule {

void init(RGWDataSyncEnv *sync_env, uint64_t instance_id) override {
conf->init_instance(sync_env->store->svc()->zone->get_realm(), instance_id);
// try to get elastic search version
RGWCoroutinesManager crs(sync_env->store->ctx(), sync_env->store->getRados()->get_cr_registry());
RGWHTTPManager http_manager(sync_env->store->ctx(), crs.get_completion_mgr());
int ret = http_manager.start();
if (ret < 0) {
return;
}
ret = crs.run(new RGWReadRESTResourceCR<ESInfo>(sync_env->cct,
conf->conn.get(),
&http_manager,
"/", nullptr,
&(conf->default_headers),
&(conf->es_info)));
http_manager.stop();
if (ret < 0) {
ldout(sync_env->cct, 1) << conf->id << ": fetch elastic info failed: " << ret << dendl;
} else {
ldout(sync_env->cct, 5) << conf->id << ": got elastic version=" << conf->es_info.get_version_str() << dendl;
}
}

RGWCoroutine *init_sync(RGWDataSyncEnv *sync_env) override {
ldout(sync_env->cct, 5) << conf->id << ": init" << dendl;
return new RGWElasticInitConfigCBCR(sync_env, conf);
}

RGWCoroutine *start_sync(RGWDataSyncEnv *sync_env) override {
ldout(sync_env->cct, 5) << conf->id << ": start_sync" << dendl;
// try to get elastic search version
return new RGWReadRESTResourceCR<ESInfo>(sync_env->cct,
conf->conn.get(),
sync_env->http_manager,
"/", nullptr,
&(conf->default_headers),
&(conf->es_info));
}

RGWCoroutine *sync_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, std::optional<uint64_t> versioned_epoch, rgw_zone_set *zones_trace) override {
ldout(sync_env->cct, 10) << conf->id << ": sync_object: b=" << bucket_info.bucket << " k=" << key << " versioned_epoch=" << versioned_epoch.value_or(0) << dendl;
if (!conf->should_handle_operation(bucket_info)) {
Expand Down

0 comments on commit 2cd512e

Please sign in to comment.