diff --git a/src/paimon/common/executor/future.h b/src/paimon/common/executor/future.h index fe6509a21..8e9f4d87f 100644 --- a/src/paimon/common/executor/future.h +++ b/src/paimon/common/executor/future.h @@ -45,6 +45,9 @@ namespace paimon { /// execution. /// /// @note If `func` returns `void`, the returned future is of type `std::future`. +/// +/// TODO: Since paimon-cpp uses `Status`/`Result` for error handling throughout, the exception +/// capture logic (try/catch + set_exception) in `Via()` will be removed in the future. template auto Via(Executor* executor, Func&& func) -> std::future { using ResultType = decltype(func()); diff --git a/src/paimon/core/operation/orphan_files_cleaner_impl.cpp b/src/paimon/core/operation/orphan_files_cleaner_impl.cpp index 7eea87977..1f7896f9e 100644 --- a/src/paimon/core/operation/orphan_files_cleaner_impl.cpp +++ b/src/paimon/core/operation/orphan_files_cleaner_impl.cpp @@ -97,11 +97,14 @@ Result> OrphanFilesCleanerImpl::Clean() { } PAIMON_ASSIGN_OR_RAISE(std::set all_dirs, ListPaimonFileDirs()); std::vector>>> file_statuses_futures; + ScopeGuard file_statuses_guard( + [&file_statuses_futures]() { CollectAll(file_statuses_futures); }); for (const auto& dir : all_dirs) { file_statuses_futures.push_back( Via(executor_.get(), [this, dir] { return TryBestListingDirs(dir); })); } PAIMON_ASSIGN_OR_RAISE(std::set used_file_names, GetUsedFiles()); + file_statuses_guard.Release(); Duration duration; std::set need_to_deletes;