| 345 | } |
| 346 | |
| 347 | Task::~Task() { |
| 348 | folly::json::serialization_opts opts; |
| 349 | opts.allow_nan_inf = true; |
| 350 | VLOG(1) << "Task finished: " << taskId_ << ", state: " |
| 351 | << folly::json::serialize(taskStats().serialize(), opts); |
| 352 | // TODO(spershin): Temporary code designed to reveal what causes SIGABRT in |
| 353 | // jemalloc when destroying some Tasks. |
| 354 | std::string clearStage; |
| 355 | bytedance::bolt::process::ThreadDebugInfo debugInfoForTask{ |
| 356 | queryCtx_->queryId(), taskId_, [&]() { |
| 357 | LOG(ERROR) << "Task::~Task(" << taskId_ |
| 358 | << "), failure during clearing stage: " << clearStage; |
| 359 | }}; |
| 360 | bytedance::bolt::process::ScopedThreadDebugInfo scopedInfo(debugInfoForTask); |
| 361 | |
| 362 | BOLT_TEST_ADJUST("bytedance::bolt::exec::Task::~Task", this); |
| 363 | |
| 364 | clearStage = "removeSpillDirectoryIfExists"; |
| 365 | removeSpillDirectoryIfExists(); |
| 366 | |
| 367 | // TODO(spershin): Temporary code designed to reveal what causes SIGABRT in |
| 368 | // jemalloc when destroying some Tasks. |
| 369 | #define CLEAR(_action_) \ |
| 370 | clearStage = #_action_; \ |
| 371 | _action_; |
| 372 | CLEAR(threadFinishPromises_.clear()); |
| 373 | CLEAR(splitGroupStates_.clear()); |
| 374 | CLEAR(taskStats_ = TaskStats()); |
| 375 | CLEAR(stateChangePromises_.clear()); |
| 376 | CLEAR(taskCompletionPromises_.clear()); |
| 377 | CLEAR(taskReadyToRunPromises_.clear()); |
| 378 | CLEAR(splitsStates_.clear()); |
| 379 | CLEAR(drivers_.clear()); |
| 380 | CLEAR(driverFactories_.clear()); |
| 381 | CLEAR(onError_ = [](std::exception_ptr) {}); |
| 382 | CLEAR(exchangeClientByPlanNode_.clear()); |
| 383 | CLEAR(exchangeClients_.clear()); |
| 384 | CLEAR(exception_ = nullptr); |
| 385 | CLEAR(nodePools_.clear()); |
| 386 | CLEAR(childPools_.clear()); |
| 387 | CLEAR(pool_.reset()); |
| 388 | CLEAR(planFragment_ = core::PlanFragment()); |
| 389 | CLEAR(queryCtx_.reset()); |
| 390 | clearStage = "exiting ~Task()"; |
| 391 | } |
| 392 | |
| 393 | void Task::init(std::optional<common::SpillDiskOptions>&& spillDiskOpts) { |
| 394 | BOLT_CHECK(driverFactories_.empty()); |