Skip to content

Commit

Permalink
Merge pull request #48683 from linuxbox2/wip-rgwlc-faststop
Browse files Browse the repository at this point in the history
rgwlc: prevent lc for one bucket from exceeding time budget

Reviewed-by: Adam C. Emerson <[email protected]>
  • Loading branch information
ivancich authored Feb 18, 2023
2 parents 27b35a6 + 617ffcc commit 1a0f7d2
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/rgw/rgw_lc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<lc_op, rgw_bucket_dir_entry> t1 =
{prefix_iter->second, *obj_iter};
worker->workpool->enqueue(WorkItem{t1});
Expand All @@ -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 */
Expand Down Expand Up @@ -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<LCOpRule, rgw_bucket_dir_entry> 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();
}
Expand Down

0 comments on commit 1a0f7d2

Please sign in to comment.