This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new be8b3fe  fix: add ScopeGuard to wait async tasks before early return 
in OrphanFilesCleanerImpl::Clean() (#307) (#150)
be8b3fe is described below

commit be8b3fe249b1f615a00cc6a757e72264a0363de8
Author: Zhang Jiawei <[email protected]>
AuthorDate: Tue Jul 14 14:54:31 2026 +0800

    fix: add ScopeGuard to wait async tasks before early return in 
OrphanFilesCleanerImpl::Clean() (#307) (#150)
---
 src/paimon/common/executor/future.h                     | 3 +++
 src/paimon/core/operation/orphan_files_cleaner_impl.cpp | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/paimon/common/executor/future.h 
b/src/paimon/common/executor/future.h
index d858c3a..fb5110b 100644
--- a/src/paimon/common/executor/future.h
+++ b/src/paimon/common/executor/future.h
@@ -47,6 +47,9 @@ namespace paimon {
 /// execution.
 ///
 /// @note If `func` returns `void`, the returned future is of type 
`std::future<void>`.
+///
+/// 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 <typename Func>
 auto Via(Executor* executor, Func&& func) -> std::future<decltype(func())> {
     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 9fa4b3b..5790d30 100644
--- a/src/paimon/core/operation/orphan_files_cleaner_impl.cpp
+++ b/src/paimon/core/operation/orphan_files_cleaner_impl.cpp
@@ -99,11 +99,14 @@ Result<std::set<std::string>> 
OrphanFilesCleanerImpl::Clean() {
     }
     PAIMON_ASSIGN_OR_RAISE(std::set<std::string> all_dirs, 
ListPaimonFileDirs());
     std::vector<std::future<std::vector<std::unique_ptr<FileStatus>>>> 
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<std::string> used_file_names, 
GetUsedFiles());
+    file_statuses_guard.Release();
 
     Duration duration;
     std::set<std::string> need_to_deletes;

Reply via email to