Skip to content

Commit

Permalink
[chore](recycler) log num deleted objects (apache#39353)
Browse files Browse the repository at this point in the history
  • Loading branch information
w41ter authored Aug 14, 2024
1 parent 0dca9ef commit 51d0dfd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
14 changes: 13 additions & 1 deletion cloud/src/recycler/obj_storage_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@

#include "recycler/obj_storage_client.h"

#include <chrono>

#include "cpp/sync_point.h"
#include "recycler/sync_executor.h"
#include "recycler/util.h"

using namespace std::chrono;

namespace doris::cloud {

Expand All @@ -28,6 +31,9 @@ ObjectStorageResponse ObjStorageClient::delete_objects_recursively_(ObjectStorag
int64_t expired_time,
size_t batch_size) {
TEST_SYNC_POINT_CALLBACK("ObjStorageClient::delete_objects_recursively_", &batch_size);
size_t num_deleted_objects = 0;
auto start_time = steady_clock::now();

auto list_iter = list_objects(path);

ObjectStorageResponse ret;
Expand All @@ -42,6 +48,7 @@ ObjectStorageResponse ObjStorageClient::delete_objects_recursively_(ObjectStorag
continue;
}

num_deleted_objects++;
keys.emplace_back(std::move(obj->key));
if (keys.size() < batch_size) {
continue;
Expand Down Expand Up @@ -70,6 +77,11 @@ ObjectStorageResponse ObjStorageClient::delete_objects_recursively_(ObjectStorag
}
}

auto elapsed = duration_cast<milliseconds>(steady_clock::now() - start_time).count();
LOG(INFO) << "delete objects under " << path.bucket << "/" << path.key
<< " finished, ret=" << ret.ret << ", finished=" << finished
<< ", num_deleted_objects=" << num_deleted_objects << ", cost=" << elapsed << " ms";

ret = finished ? ret : -1;

return ret;
Expand Down
12 changes: 4 additions & 8 deletions cloud/src/recycler/recycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,6 @@ int InstanceRecycler::recycle_tablets(int64_t table_id, int64_t index_id, int64_
return {std::string_view(), range_move};
}
++num_recycled;
LOG_INFO("k is {}, is empty {}", k, k.empty());
return {k, range_move};
});
} else {
Expand All @@ -1157,10 +1156,7 @@ int InstanceRecycler::recycle_tablets(int64_t table_id, int64_t index_id, int64_
}
return true;
}());
sync_executor.add([k]() mutable -> TabletKeyPair {
LOG_INFO("k is {}, is empty {}", k, k.empty());
return {k, true};
});
sync_executor.add([k]() mutable -> TabletKeyPair { return {k, true}; });
++num_recycled;
}
return 0;
Expand Down Expand Up @@ -1433,7 +1429,7 @@ int InstanceRecycler::recycle_tablet(int64_t tablet_id) {

std::unique_ptr<int, std::function<void(int*)>> defer_log_statistics((int*)0x01, [&](int*) {
auto cost = duration<float>(steady_clock::now() - start_time).count();
LOG_INFO("recycle rowsets finished, cost={}s", cost)
LOG_INFO("recycle the rowsets of dropped tablet finished, cost={}s", cost)
.tag("instance_id", instance_id_)
.tag("tablet_id", tablet_id);
});
Expand Down Expand Up @@ -1618,7 +1614,7 @@ int InstanceRecycler::recycle_rowsets() {
// old version `RecycleRowsetPB` may has empty resource_id, just remove the kv.
LOG(INFO) << "delete the recycle rowset kv that has empty resource_id, key="
<< hex(k) << " value=" << proto_to_json(rowset);
rowset_keys.push_back(std::string(k));
rowset_keys.emplace_back(k);
return -1;
}
// decode rowset_id
Expand Down Expand Up @@ -1664,7 +1660,7 @@ int InstanceRecycler::recycle_rowsets() {
return -1;
}
} else {
rowset_keys.push_back(std::string(k));
rowset_keys.emplace_back(k);
if (rowset_meta->num_segments() > 0) { // Skip empty rowset
rowsets.push_back(std::move(*rowset_meta));
}
Expand Down
6 changes: 2 additions & 4 deletions cloud/src/recycler/sync_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
#include <glog/logging.h>

#include <future>
#include <iostream>
#include <string>

#include "common/logging.h"
#include "common/simple_thread_pool.h"

namespace doris::cloud {
Expand Down Expand Up @@ -54,10 +52,10 @@ class SyncExecutor {
auto current_time_second = time(nullptr);
current_time.tv_sec = current_time_second + 300;
current_time.tv_nsec = 0;
auto msg = fmt::format("{} has already taken 5 min", _name_tag);
while (0 != _count.timed_wait(current_time)) {
current_time.tv_sec += 300;
LOG(WARNING) << msg;
LOG(WARNING) << _name_tag << " has already taken 5 min, cost: "
<< time(nullptr) - current_time_second << " seconds";
}
*finished = !_stop_token;
std::vector<T> res;
Expand Down

0 comments on commit 51d0dfd

Please sign in to comment.