| 2497 | } |
| 2498 | |
| 2499 | std::string Task::toString() const { |
| 2500 | std::lock_guard<std::timed_mutex> l(mutex_); |
| 2501 | std::stringstream out; |
| 2502 | out << "{Task " << shortId(taskId_) << " (" << taskId_ << ")" << std::endl; |
| 2503 | |
| 2504 | if (exception_) { |
| 2505 | out << "Error: " << errorMessageLocked() << std::endl; |
| 2506 | } |
| 2507 | |
| 2508 | if (planFragment_.planNode) { |
| 2509 | out << "Plan:\n" |
| 2510 | << planFragment_.planNode->toString(true, true) << std::endl; |
| 2511 | } |
| 2512 | |
| 2513 | size_t numRemainingDrivers{0}; |
| 2514 | for (const auto& driver : drivers_) { |
| 2515 | if (driver) { |
| 2516 | ++numRemainingDrivers; |
| 2517 | } |
| 2518 | } |
| 2519 | |
| 2520 | if (numRemainingDrivers > 0) { |
| 2521 | bool addedCaption{false}; |
| 2522 | for (auto& driver : drivers_) { |
| 2523 | if (driver) { |
| 2524 | if (!addedCaption) { |
| 2525 | out << "drivers:\n"; |
| 2526 | addedCaption = true; |
| 2527 | } |
| 2528 | out << driver->toString() << std::endl; |
| 2529 | } |
| 2530 | } |
| 2531 | } |
| 2532 | |
| 2533 | if (!driversClosedByTask_.empty()) { |
| 2534 | bool addedCaption{false}; |
| 2535 | for (auto& driver : driversClosedByTask_) { |
| 2536 | auto zombieDriver = driver.lock(); |
| 2537 | if (zombieDriver) { |
| 2538 | if (!addedCaption) { |
| 2539 | out << "zombie drivers:\n"; |
| 2540 | addedCaption = true; |
| 2541 | } |
| 2542 | out << zombieDriver->toString() |
| 2543 | << ", refcount: " << zombieDriver.use_count() - 1 << std::endl; |
| 2544 | } |
| 2545 | } |
| 2546 | } |
| 2547 | |
| 2548 | out << "}"; |
| 2549 | return out.str(); |
| 2550 | } |
| 2551 | |
| 2552 | folly::dynamic Task::toShortJsonLocked() const { |
| 2553 | folly::dynamic obj = folly::dynamic::object; |