diff --git a/cpp-ch/local-engine/Shuffle/PartitionWriter.cpp b/cpp-ch/local-engine/Shuffle/PartitionWriter.cpp index a1d9ee8b7c28..e200e59ec302 100644 --- a/cpp-ch/local-engine/Shuffle/PartitionWriter.cpp +++ b/cpp-ch/local-engine/Shuffle/PartitionWriter.cpp @@ -286,9 +286,8 @@ void CelebornPartitionWriter::stop() void Partition::addBlock(DB::Block & block) { - std::unique_lock lock(mtx, std::try_to_lock); - if (lock.owns_lock()) - blocks.emplace_back(std::move(block)); + std::unique_lock lock(mtx); + blocks.emplace_back(std::move(block)); } bool Partition::empty() const @@ -313,6 +312,7 @@ size_t Partition::spill(DB::NativeWriter & writer) { raw_size += writer.write(block); } + blocks.clear(); return raw_size; } else