From 1ec92b257a62f71accc0a3dbe0489094f09d737d Mon Sep 17 00:00:00 2001 From: Rui Mo Date: Tue, 3 Mar 2026 22:01:21 +0000 Subject: [PATCH] Follow up --- cpp/velox/memory/GlutenDirectBufferedInput.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cpp/velox/memory/GlutenDirectBufferedInput.h b/cpp/velox/memory/GlutenDirectBufferedInput.h index 3aef323da7bc..98b7fff9d9cf 100644 --- a/cpp/velox/memory/GlutenDirectBufferedInput.h +++ b/cpp/velox/memory/GlutenDirectBufferedInput.h @@ -48,6 +48,14 @@ class GlutenDirectBufferedInput : public facebook::velox::dwio::common::DirectBu ~GlutenDirectBufferedInput() override { requests_.clear(); + // Cancel all the planned loads as soon as possible to avoid unnecessary IO. + for (auto& load : coalescedLoads_) { + if (load->state() == facebook::velox::cache::CoalescedLoad::State::kPlanned) { + load->cancel(); + } + } + // Ensure all the loadings can finish in the TableScan destructor to avoid the issue that the load is still running + // when the VeloxMemoryManager used by the whole task is trying to destruct. for (auto& load : coalescedLoads_) { if (load->state() == facebook::velox::cache::CoalescedLoad::State::kLoading) { folly::SemiFuture waitFuture(false); @@ -56,7 +64,6 @@ class GlutenDirectBufferedInput : public facebook::velox::dwio::common::DirectBu std::move(waitFuture).via(&exec).wait(); } } - load->cancel(); } coalescedLoads_.clear(); }