diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 4947d410afa4..1baa0164dd8a 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -876,6 +876,7 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target, } params.prefix = prefix_iter->first; do { + auto offset = 0; results.objs.clear(); ret = target->list(this, params, 1000, results, null_yield); if (ret < 0) { @@ -885,7 +886,7 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target, return ret; } - for (auto obj_iter = results.objs.begin(); obj_iter != results.objs.end(); ++obj_iter) { + for (auto obj_iter = results.objs.begin(); obj_iter != results.objs.end(); ++obj_iter, ++offset) { std::tuple t1 = {prefix_iter->second, *obj_iter}; worker->workpool->enqueue(WorkItem{t1}); @@ -894,6 +895,15 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target, } } /* for objs */ + if ((offset % 100) == 0) { + if (worker_should_stop(stop_at, once)) { + ldpp_dout(this, 5) << __func__ << " interval budget EXPIRED worker " + << worker->ix + << dendl; + return 0; + } + } + std::this_thread::sleep_for(std::chrono::milliseconds(delay_ms)); } while(results.is_truncated); } /* for prefix_map */ @@ -1637,10 +1647,18 @@ int RGWLC::bucket_lc_process(string& shard_id, LCWorker* worker, LCOpRule orule(oenv); orule.build(); // why can't ctor do it? rgw_bucket_dir_entry* o{nullptr}; - for (; ol.get_obj(this, &o /* , fetch_barrier */); ol.next()) { + for (auto offset = 0; ol.get_obj(this, &o /* , fetch_barrier */); ++offset, ol.next()) { orule.update(); std::tuple t1 = {orule, *o}; worker->workpool->enqueue(WorkItem{t1}); + if ((offset % 100) == 0) { + if (worker_should_stop(stop_at, once)) { + ldpp_dout(this, 5) << __func__ << " interval budget EXPIRED worker " + << worker->ix + << dendl; + return 0; + } + } } worker->workpool->drain(); }