#1609 Refine Compact function

Signed-off-by: groot <yihua.mo@zilliz.com>
pull/1610/head
groot 2020-03-10 19:47:23 +08:00
parent 17ec3d5e21
commit 8872054603
1 changed files with 6 additions and 1 deletions

View File

@ -687,7 +687,10 @@ DBImpl::Compact(const std::string& table_id) {
OngoingFileChecker::GetInstance().MarkOngoingFiles(files_to_compact);
Status compact_status;
for (auto& file : files_to_compact) {
for (meta::TableFilesSchema::iterator iter = files_to_compact.begin(); iter != files_to_compact.end();) {
meta::TableFileSchema file = *iter;
iter = files_to_compact.erase(iter);
// Check if the segment needs compacting
std::string segment_dir;
utils::GetParentPath(file.location_, segment_dir);
@ -724,6 +727,8 @@ DBImpl::Compact(const std::string& table_id) {
compact_status = status;
break; // meta error, could not go on
}
OngoingFileChecker::GetInstance().UnmarkOngoingFile(file);
}
OngoingFileChecker::GetInstance().UnmarkOngoingFiles(files_to_compact);