From 774e48edd2d902f0b0b045754950cf961b415f1e Mon Sep 17 00:00:00 2001 From: Hongze Zhang Date: Thu, 15 Aug 2024 14:53:03 +0800 Subject: [PATCH] [GLUTEN-6864] Error during spilling: The current running driver and the request driver must be from the same task --- cpp/velox/compute/WholeStageResultIterator.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpp/velox/compute/WholeStageResultIterator.cc b/cpp/velox/compute/WholeStageResultIterator.cc index eb700c6489ec..af6cf313aeea 100644 --- a/cpp/velox/compute/WholeStageResultIterator.cc +++ b/cpp/velox/compute/WholeStageResultIterator.cc @@ -239,6 +239,15 @@ int64_t WholeStageResultIterator::spillFixedSize(int64_t size) { int64_t shrunken = memoryManager_->shrink(size); // todo return the actual spilled size? if (spillStrategy_ == "auto") { + exec::DriverThreadContext* driverThreadCtx = exec::driverThreadContext(); + if (driverThreadCtx != nullptr) { + if (driverThreadCtx->driverCtx.task->taskId() != task_->taskId()) { + // Disallow one task from spilling another. This is by Velox's restriction. See + // https://github.com/facebookincubator/velox/blob/9523840ac329be4f7318338fb92cb92bcb0a8c07/velox/exec/Operator.cpp#L566-L575. + VLOG(2) << logPrefix << "One Velox task is trying to spill another, ignoring."; + return shrunken; + } + } int64_t remaining = size - shrunken; LOG(INFO) << logPrefix << "Trying to request spilling for " << remaining << " bytes..."; // suspend the driver when we are on it