Skip to content

Commit 1ec92b2

Browse files
committed
Follow up
1 parent 8e8a81e commit 1ec92b2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cpp/velox/memory/GlutenDirectBufferedInput.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ class GlutenDirectBufferedInput : public facebook::velox::dwio::common::DirectBu
4848

4949
~GlutenDirectBufferedInput() override {
5050
requests_.clear();
51+
// Cancel all the planned loads as soon as possible to avoid unnecessary IO.
52+
for (auto& load : coalescedLoads_) {
53+
if (load->state() == facebook::velox::cache::CoalescedLoad::State::kPlanned) {
54+
load->cancel();
55+
}
56+
}
57+
// Ensure all the loadings can finish in the TableScan destructor to avoid the issue that the load is still running
58+
// when the VeloxMemoryManager used by the whole task is trying to destruct.
5159
for (auto& load : coalescedLoads_) {
5260
if (load->state() == facebook::velox::cache::CoalescedLoad::State::kLoading) {
5361
folly::SemiFuture<bool> waitFuture(false);
@@ -56,7 +64,6 @@ class GlutenDirectBufferedInput : public facebook::velox::dwio::common::DirectBu
5664
std::move(waitFuture).via(&exec).wait();
5765
}
5866
}
59-
load->cancel();
6067
}
6168
coalescedLoads_.clear();
6269
}

0 commit comments

Comments
 (0)