destroy all files that reference main file
This commit is contained in:
parent
057d20d0c9
commit
aa2bdf02d8
@ -3714,31 +3714,31 @@ void FileManager::memory_cleanup() {
|
|||||||
is_closed_ = true;
|
is_closed_ = true;
|
||||||
auto time = std::time(nullptr);
|
auto time = std::time(nullptr);
|
||||||
|
|
||||||
for (unsigned int i = 1; i < file_id_info_.size(); i++) {
|
for (unsigned int i = 0; i < file_id_info_.size(); i++) {
|
||||||
if (time - file_id_insert_time_[i] > 5 /* DELETE FILES OLDER THAN X SECONDS */) {
|
|
||||||
empty_file_ids_.push_back(i);
|
|
||||||
file_id_insert_time_[i] = INT64_MAX;
|
|
||||||
|
|
||||||
auto &node = file_nodes_[file_id_info_[i].node_id_];
|
auto &node = file_nodes_[file_id_info_[i].node_id_];
|
||||||
|
|
||||||
if (node != nullptr) {
|
if (node != nullptr && ((int32) i) == node->main_file_id_.get()) {
|
||||||
node->set_upload_priority(0);
|
if (time - file_id_insert_time_[i] > 5 /* MAIN FILE TTL */) {
|
||||||
node->set_download_priority(0);
|
for (auto &file_id : node->file_ids_) {
|
||||||
node->set_generate_priority(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
file_nodes_[file_id_info_[i].node_id_] = nullptr;
|
/* DESTROY QUERIES */
|
||||||
file_id_info_[i].node_id_ = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto &empty_id : empty_file_ids_) {
|
|
||||||
for (auto &query_id : queries_container_.ids()) {
|
for (auto &query_id : queries_container_.ids()) {
|
||||||
auto query = queries_container_.get(query_id);
|
auto query = queries_container_.get(query_id);
|
||||||
if (query->file_id_.get() == empty_id) {
|
if (((int32) i) == query->file_id_.get()) {
|
||||||
on_error(query_id, Status::Error(500, "FILE_MANAGER_RESTART"));
|
on_error(query_id, Status::Error(500, "FILE_MANAGER_RESTART"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DESTROY FILE */
|
||||||
|
try_forget_file_id(file_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DESTROY MAIN FILE */
|
||||||
|
file_id_insert_time_[i] = INT64_MAX;
|
||||||
|
file_id_info_[i] = FileIdInfo();
|
||||||
|
file_nodes_[file_id_info_[i].node_id_] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << empty_file_ids_.size() << " empty ids and " << queries_container_.size() << " running queries";
|
LOG(INFO) << empty_file_ids_.size() << " empty ids and " << queries_container_.size() << " running queries";
|
||||||
|
Reference in New Issue
Block a user