Skip to content

Commit

Permalink
radosgw-admin: 'sync error trim' loops until complete
Browse files Browse the repository at this point in the history
a single call to time_log_trim() will trim a maximum of 1000 entries.
now loops until a return code of -ENODATA indicates that all entries
in the given range were trimmed

an optional --trim-delay-ms option can be used to limit the frequency
of osd ops

Fixes: http://tracker.ceph.com/issues/24873

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 3269719)
  • Loading branch information
cbodley authored and Prashant D committed Jul 20, 2018
1 parent bd3b97c commit 17437e7
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/rgw/rgw_admin.cc
Expand Up @@ -2608,6 +2608,30 @@ static int scan_totp(CephContext *cct, ceph::real_time& now, rados::cls::otp::ot
return -ENOENT;
}

static int trim_sync_error_log(int shard_id, const ceph::real_time& start_time,
const ceph::real_time& end_time,
const string& start_marker, const string& end_marker,
int delay_ms)
{
auto oid = RGWSyncErrorLogger::get_shard_oid(RGW_SYNC_ERROR_LOG_SHARD_PREFIX,
shard_id);
// call cls_log_trim() until it returns -ENODATA
for (;;) {
int ret = store->time_log_trim(oid, start_time, end_time,
start_marker, end_marker);
if (ret == -ENODATA) {
return 0;
}
if (ret < 0) {
return ret;
}
if (delay_ms) {
std::this_thread::sleep_for(std::chrono::milliseconds(delay_ms));
}
}
// unreachable
}

int main(int argc, const char **argv)
{
vector<const char*> args;
Expand Down Expand Up @@ -2779,6 +2803,7 @@ int main(int argc, const char **argv)
vector<string> totp_pin;
int totp_seconds = 0;
int totp_window = 0;
int trim_delay_ms = 0;

for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
Expand Down Expand Up @@ -3115,6 +3140,8 @@ int main(int argc, const char **argv)
totp_seconds = atoi(val.c_str());
} else if (ceph_argparse_witharg(args, i, &val, "--totp-window", (char*)NULL)) {
totp_window = atoi(val.c_str());
} else if (ceph_argparse_witharg(args, i, &val, "--trim-delay-ms", (char*)NULL)) {
trim_delay_ms = atoi(val.c_str());
} else if (strncmp(*i, "-", 1) == 0) {
cerr << "ERROR: invalid flag " << *i << std::endl;
return EINVAL;
Expand Down Expand Up @@ -7222,9 +7249,10 @@ int main(int argc, const char **argv)
}

for (; shard_id < ERROR_LOGGER_SHARDS; ++shard_id) {
string oid = RGWSyncErrorLogger::get_shard_oid(RGW_SYNC_ERROR_LOG_SHARD_PREFIX, shard_id);
ret = store->time_log_trim(oid, start_time.to_real_time(), end_time.to_real_time(), start_marker, end_marker);
if (ret < 0 && ret != -ENODATA) {
ret = trim_sync_error_log(shard_id, start_time.to_real_time(),
end_time.to_real_time(), start_marker,
end_marker, trim_delay_ms);
if (ret < 0) {
cerr << "ERROR: sync error trim: " << cpp_strerror(-ret) << std::endl;
return -ret;
}
Expand Down

0 comments on commit 17437e7

Please sign in to comment.