Add logging for too long file GC.

This commit is contained in:
levlam 2022-08-30 12:05:38 +03:00
parent 9fc456f434
commit 031e2246ec

View File

@ -30,7 +30,7 @@ int VERBOSITY_NAME(file_gc) = VERBOSITY_NAME(INFO);
void FileGcWorker::run_gc(const FileGcParameters &parameters, std::vector<FullFileInfo> files,
Promise<FileGcResult> promise) {
auto begin_time = Time::now();
VLOG(file_gc) << "Start files gc with " << parameters;
VLOG(file_gc) << "Start files GC with " << parameters;
// quite stupid implementations
// needs a lot of memory
// may write something more clever, but i will need at least 2 passes over the files
@ -88,7 +88,7 @@ void FileGcWorker::run_gc(const FileGcParameters &parameters, std::vector<FullFi
auto do_remove_file = [&removed_stats](const FullFileInfo &info) {
removed_stats.add_copy(info);
auto status = unlink(info.path);
LOG_IF(WARNING, status.is_error()) << "Failed to unlink file \"" << info.path << "\" during files gc: " << status;
LOG_IF(WARNING, status.is_error()) << "Failed to unlink file \"" << info.path << "\" during files GC: " << status;
send_closure(G()->file_manager(), &FileManager::on_file_unlink,
FullLocalFileLocation(info.file_type, info.path, info.mtime_nsec));
};
@ -117,7 +117,7 @@ void FileGcWorker::run_gc(const FileGcParameters &parameters, std::vector<FullFi
return true;
}
if (static_cast<double>(info.mtime_nsec) * 1e-9 > now - parameters.immunity_delay_) {
// new files are immune to gc
// new files are immune to GC
time_immunity_ignored_cnt++;
new_stats.add_copy(info);
return true;
@ -177,7 +177,7 @@ void FileGcWorker::run_gc(const FileGcParameters &parameters, std::vector<FullFi
auto end_time = Time::now();
VLOG(file_gc) << "Finish files gc: " << tag("time", end_time - begin_time) << tag("total", file_cnt)
VLOG(file_gc) << "Finish files GC: " << tag("time", end_time - begin_time) << tag("total", file_cnt)
<< tag("removed", remove_by_atime_cnt + remove_by_count_cnt + remove_by_size_cnt)
<< tag("total_size", format::as_size(total_size))
<< tag("total_removed_size", format::as_size(total_removed_size))
@ -186,6 +186,12 @@ void FileGcWorker::run_gc(const FileGcParameters &parameters, std::vector<FullFi
<< tag("time_immunity", time_immunity_ignored_cnt)
<< tag("owner_dialog_id_immunity", owner_dialog_id_ignored_cnt)
<< tag("exclude_owner_dialog_id_immunity", exclude_owner_dialog_id_ignored_cnt);
if (end_time - begin_time > 1.0) {
LOG(WARNING) << "Finish file GC: " << tag("time", end_time - begin_time) << tag("total", file_cnt)
<< tag("removed", remove_by_atime_cnt + remove_by_count_cnt + remove_by_size_cnt)
<< tag("total_size", format::as_size(total_size))
<< tag("total_removed_size", format::as_size(total_removed_size));
}
promise.set_value({std::move(new_stats), std::move(removed_stats)});
}