From 88720546031b56f5311fa7ab9aee49cb5f1abef5 Mon Sep 17 00:00:00 2001 From: groot Date: Tue, 10 Mar 2020 19:47:23 +0800 Subject: [PATCH] #1609 Refine Compact function Signed-off-by: groot --- core/src/db/DBImpl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/db/DBImpl.cpp b/core/src/db/DBImpl.cpp index 9a59281d83..9d10dd5a2a 100644 --- a/core/src/db/DBImpl.cpp +++ b/core/src/db/DBImpl.cpp @@ -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);