| 634 | } // function ImpalaServer::IsWorkloadManagementShuttingDown |
| 635 | |
| 636 | void ImpalaServer::WorkloadManagementWorker(const Version& target_schema_version) { |
| 637 | { |
| 638 | lock_guard<mutex> l(workload_mgmt_state_mu_); |
| 639 | workload_mgmt_state_ = WorkloadManagementState::STARTING; |
| 640 | } |
| 641 | |
| 642 | { |
| 643 | lock_guard<mutex> l(workload_mgmt_state_mu_); |
| 644 | workload_mgmt_state_ = WorkloadManagementState::STARTED; |
| 645 | } |
| 646 | |
| 647 | { |
| 648 | lock_guard<mutex> l(workload_mgmt_state_mu_); |
| 649 | // This condition will evaluate to false only if a clean shutdown was initiated while |
| 650 | // the previous function was running. |
| 651 | if (LIKELY(workload_mgmt_state_ == WorkloadManagementState::STARTED)) { |
| 652 | workload_mgmt_state_ = WorkloadManagementState::RUNNING; |
| 653 | } else { |
| 654 | LOG(INFO) << "Not starting workload management processing thread because " |
| 655 | << "coordinator shutdown was initiated."; |
| 656 | return; // Note: early return |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | // Non-values portion of the sql DML to insert records into the completed queries |
| 661 | // tables. This portion of the statement is constant and thus is only generated once. |
| 662 | const string log_table_name = QueryLogTableName(true); |
| 663 | const string insert_dml_prefix = _dmlPrefix(log_table_name, target_schema_version); |
| 664 | VLOG(2) << "Workload Management insert sql prefix: " << insert_dml_prefix; |
| 665 | |
| 666 | // Setup default query options that will be provided on all queries that insert rows |
| 667 | // into the completed queries table. |
| 668 | InternalServer::QueryOptionMap insert_query_opts; |
| 669 | |
| 670 | insert_query_opts[TImpalaQueryOptions::TIMEZONE] = "UTC"; |
| 671 | insert_query_opts[TImpalaQueryOptions::QUERY_TIMEOUT_S] = std::to_string( |
| 672 | FLAGS_query_log_write_timeout_s < 1 ? FLAGS_query_log_write_interval_s : |
| 673 | FLAGS_query_log_write_timeout_s); |
| 674 | if (!FLAGS_query_log_request_pool.empty()) { |
| 675 | insert_query_opts[TImpalaQueryOptions::REQUEST_POOL] = FLAGS_query_log_request_pool; |
| 676 | } |
| 677 | insert_query_opts[TImpalaQueryOptions::FETCH_ROWS_TIMEOUT_MS] = "0"; |
| 678 | insert_query_opts[TImpalaQueryOptions::EXEC_TIME_LIMIT_S] = |
| 679 | std::to_string(FLAGS_query_log_dml_exec_timeout_s); |
| 680 | if (!FLAGS_debug_actions.empty()) { |
| 681 | insert_query_opts[TImpalaQueryOptions::DEBUG_ACTION] = FLAGS_debug_actions; |
| 682 | } |
| 683 | // Hide analyzed query since it can be prohibitively long. |
| 684 | insert_query_opts[TImpalaQueryOptions::HIDE_ANALYZED_QUERY] = "true"; |
| 685 | |
| 686 | while (true) { |
| 687 | // Exit this thread if a shutdown was initiated. |
| 688 | if (IsWorkloadManagementShuttingDown()) { |
| 689 | _completed_queries_shutdown_cv.notify_all(); |
| 690 | return; // Note: early return |
| 691 | } |
| 692 | |
| 693 | // Sleep this thread until it is time to process queued completed queries or the |
nothing calls this directly
no test coverage detected