Skip to content

Commit

Permalink
add memory check
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Mar 23, 2023
1 parent bd23161 commit ff96a8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/graph/executor/StorageAccessExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ folly::Future<std::vector<Value>> StorageAccessExecutor::getProps(
param, std::move(vertices), vertexPropPtr, nullptr, nullptr, false, {}, -1, nullptr)
.via(runner())
.thenValue([this](PropRpcResponse &&resp) {
memory::MemoryCheckGuard guard;
addStats(resp);
return handlePropResp(std::move(resp));
});
Expand Down
12 changes: 10 additions & 2 deletions src/graph/executor/algo/AllPathsExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ folly::Future<std::vector<Row>> AllPathsExecutor::doBuildPath(
}));
}
}
return folly::collect(futures).via(runner()).thenValue(
[pathPtr = std::move(currentPathPtr)](std::vector<std::vector<Row>>&& paths) {
return folly::collect(futures)
.via(runner())
.thenValue([pathPtr = std::move(currentPathPtr)](std::vector<std::vector<Row>>&& paths) {
memory::MemoryCheckGuard guard;
std::vector<Row> result = std::move(*pathPtr);
for (auto& path : paths) {
Expand All @@ -418,6 +419,13 @@ folly::Future<std::vector<Row>> AllPathsExecutor::doBuildPath(
std::make_move_iterator(path.end()));
}
return result;
})
.thenError(folly::tag_t<std::bad_alloc>{},
[](const std::bad_alloc&) {
return folly::makeFuture<Status>(Executor::memoryExceededStatus());
})
.thenError(folly::tag_t<std::exception>{}, [](const std::exception& e) {
return folly::makeFuture<Status>(std::runtime_error(e.what()));
});
}

Expand Down

0 comments on commit ff96a8c

Please sign in to comment.