Skip to content

Commit

Permalink
[VL] Query hangs on destroying memory manager (#4232)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhztheplayer authored Dec 29, 2023
1 parent 385b252 commit fcb31fc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cpp/velox/compute/VeloxRuntime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ std::shared_ptr<Datasource> VeloxRuntime::createDatasource(
const std::string& filePath,
MemoryManager* memoryManager,
std::shared_ptr<arrow::Schema> schema) {
auto veloxPool = getAggregateVeloxPool(memoryManager);
static std::atomic_uint32_t id{0UL};
auto veloxPool = getAggregateVeloxPool(memoryManager)->addAggregateChild("datasource." + std::to_string(id++));
// Pass a dedicate pool for S3 sink as can't share veloxPool
// with parquet writer.
auto s3SinkPool = getLeafVeloxPool(memoryManager);
Expand Down
21 changes: 19 additions & 2 deletions cpp/velox/memory/VeloxMemoryManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,25 @@ bool VeloxMemoryManager::tryDestructSafe() {
veloxAggregatePool_.reset();

// Velox memory manager considered safe to destruct when no alive pools.
if (veloxMemoryManager_ && veloxMemoryManager_->numPools() != 0) {
return false;
if (veloxMemoryManager_) {
if (veloxMemoryManager_->numPools() > 1) {
return false;
}
if (veloxMemoryManager_->numPools() == 1) {
// Assert the pool is spill pool
// See https://github.com/facebookincubator/velox/commit/e6f84e8ac9ef6721f527a2d552a13f7e79bdf72e
int32_t spillPoolCount = 0;
veloxMemoryManager_->testingDefaultRoot().visitChildren([&](velox::memory::MemoryPool* child) -> bool {
if (child == veloxMemoryManager_->spillPool()) {
spillPoolCount++;
}
return true;
});
GLUTEN_CHECK(spillPoolCount == 1, "Illegal pool count state: spillPoolCount: " + std::to_string(spillPoolCount));
}
if (veloxMemoryManager_->numPools() < 1) {
GLUTEN_CHECK(false, "Unreachable code");
}
}
veloxMemoryManager_.reset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,10 @@ class VeloxTestSettings extends BackendTestSettings {
// error message mismatch is accepted
.exclude("schema mismatch failure error message for parquet reader")
.exclude("schema mismatch failure error message for parquet vectorized reader")
// [PATH_NOT_FOUND] Path does not exist:
// file:/opt/spark331/sql/core/src/test/resources/test-data/timestamp-nanos.parquet
// May require for newer spark.test.home
.excludeByPrefix("SPARK-40819")
enableSuite[GlutenParquetThriftCompatibilitySuite]
// Rewrite for file locating.
.exclude("Read Parquet file generated by parquet-thrift")
Expand Down

0 comments on commit fcb31fc

Please sign in to comment.