Skip to content

Commit

Permalink
rgwlc: prevent lc for one bucket from exceeding time budget
Browse files Browse the repository at this point in the history
Fixes: https://tracker.ceph.com/issues/57951

Signed-off-by: Matt Benjamin <[email protected]>
  • Loading branch information
mattbenjamin committed Oct 31, 2022
1 parent 3b874e9 commit 617ffcc
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 @@ -880,6 +880,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 @@ -889,7 +890,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 @@ -898,6 +899,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 @@ -1641,10 +1651,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 617ffcc

Please sign in to comment.