| 619 | } |
| 620 | |
| 621 | Status ClientRequestState::ExecQueryOrDmlRequest( |
| 622 | const TQueryExecRequest& query_exec_request, bool isAsync) { |
| 623 | // we always need at least one plan fragment |
| 624 | DCHECK(query_exec_request.plan_exec_info.size() > 0); |
| 625 | |
| 626 | if (query_exec_request.__isset.query_plan) { |
| 627 | stringstream plan_ss; |
| 628 | // Add some delimiters to make it clearer where the plan |
| 629 | // begins and the profile ends |
| 630 | plan_ss << "\n----------------\n" |
| 631 | << query_exec_request.query_plan |
| 632 | << "----------------"; |
| 633 | summary_profile_->AddInfoStringRedacted("Plan", plan_ss.str()); |
| 634 | } |
| 635 | // Add info strings consumed by CM: Estimated mem and tables missing stats. |
| 636 | if (query_exec_request.__isset.per_host_mem_estimate) { |
| 637 | stringstream ss; |
| 638 | ss << query_exec_request.per_host_mem_estimate; |
| 639 | summary_profile_->AddInfoString(PER_HOST_MEM_KEY, ss.str()); |
| 640 | } |
| 641 | if (!query_exec_request.query_ctx.__isset.parent_query_id && |
| 642 | query_exec_request.query_ctx.__isset.tables_missing_stats && |
| 643 | !query_exec_request.query_ctx.tables_missing_stats.empty()) { |
| 644 | summary_profile_->AddInfoString(TABLES_MISSING_STATS_KEY, |
| 645 | PrintTableList(query_exec_request.query_ctx.tables_missing_stats)); |
| 646 | } |
| 647 | |
| 648 | if (!query_exec_request.query_ctx.__isset.parent_query_id && |
| 649 | query_exec_request.query_ctx.__isset.tables_with_corrupt_stats && |
| 650 | !query_exec_request.query_ctx.tables_with_corrupt_stats.empty()) { |
| 651 | summary_profile_->AddInfoString(TABLES_WITH_CORRUPT_STATS_KEY, |
| 652 | PrintTableList(query_exec_request.query_ctx.tables_with_corrupt_stats)); |
| 653 | } |
| 654 | |
| 655 | if (query_exec_request.query_ctx.__isset.tables_missing_diskids && |
| 656 | !query_exec_request.query_ctx.tables_missing_diskids.empty()) { |
| 657 | summary_profile_->AddInfoString(TABLES_WITH_MISSING_DISK_IDS_KEY, |
| 658 | PrintTableList(query_exec_request.query_ctx.tables_missing_diskids)); |
| 659 | } |
| 660 | |
| 661 | // Don't start executing the query if Cancel() was called concurrently with Exec(). |
| 662 | RETURN_IF_CANCELLED(this); |
| 663 | if (isAsync) { |
| 664 | // Don't transition to PENDING inside the FinishExecQueryOrDmlRequest thread because |
| 665 | // the query should be in the PENDING state before the Exec RPC returns. |
| 666 | UpdateNonErrorExecState(ExecState::PENDING); |
| 667 | RETURN_IF_ERROR(Thread::Create("query-exec-state", "async-exec-thread", |
| 668 | &ClientRequestState::FinishExecQueryOrDmlRequest, this, &async_exec_thread_, |
| 669 | true)); |
| 670 | } else { |
| 671 | // Update query_status_ as necessary. |
| 672 | FinishExecQueryOrDmlRequest(); |
| 673 | return query_status_; |
| 674 | } |
| 675 | return Status::OK(); |
| 676 | } |
| 677 | |
| 678 | void ClientRequestState::FinishExecQueryOrDmlRequest() { |
nothing calls this directly
no test coverage detected