Skip to content

Commit 50d5ec6

Browse files
rui-moLakehouse Engine Bot
authored andcommitted
[14722] Fix memory leak caused by asynchronous prefetch
Alchemy-item: (ID = 901) [OAP] [14722] Fix memory leak caused by asynchronous prefetch commit 1/1 - 075e790
1 parent a5b2ed3 commit 50d5ec6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

velox/common/caching/AsyncDataCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ class CoalescedLoad {
445445
return state_;
446446
}
447447

448-
void cancel() {
448+
virtual void cancel() {
449449
setEndState(State::kCancelled);
450450
}
451451

velox/dwio/common/DirectBufferedInput.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ class DirectCoalescedLoad : public cache::CoalescedLoad {
102102
return size;
103103
}
104104

105+
void cancel() override {
106+
folly::SemiFuture<bool> waitFuture(false);
107+
if (state() == State::kLoading && !loadOrFuture(&waitFuture)) {
108+
waitFuture.wait();
109+
}
110+
for (auto& request : requests_) {
111+
pool_->freeNonContiguous(request.data);
112+
}
113+
CoalescedLoad::cancel();
114+
}
115+
105116
private:
106117
const std::shared_ptr<IoStatistics> ioStats_;
107118
const std::shared_ptr<filesystems::File::IoStats> fsStats_;

0 commit comments

Comments
 (0)