| 806 | } |
| 807 | |
| 808 | Status ImpalaServer::GetRuntimeProfileOutput(const string& user, |
| 809 | const QueryHandle& query_handle, TRuntimeProfileFormat::type format, |
| 810 | RuntimeProfileOutput* profile) { |
| 811 | // For queries in INITIALIZED state, the profile information isn't populated yet. |
| 812 | if (query_handle->exec_state() == ClientRequestState::ExecState::INITIALIZED) { |
| 813 | return Status::Expected("Query plan is not ready."); |
| 814 | } |
| 815 | lock_guard<mutex> l(*query_handle->lock()); |
| 816 | int64_t start_time_ns = MonotonicNanos(); |
| 817 | RETURN_IF_ERROR(CheckProfileAccess( |
| 818 | user, query_handle->effective_user(), query_handle->user_has_profile_access())); |
| 819 | if (query_handle->GetCoordinator() != nullptr) { |
| 820 | UpdateExecSummary(query_handle); |
| 821 | } |
| 822 | if (format == TRuntimeProfileFormat::BASE64) { |
| 823 | RETURN_IF_ERROR( |
| 824 | query_handle->profile()->SerializeToArchiveString(profile->string_output)); |
| 825 | } else if (format == TRuntimeProfileFormat::THRIFT) { |
| 826 | query_handle->profile()->ToThrift(profile->thrift_output); |
| 827 | } else if (format == TRuntimeProfileFormat::JSON) { |
| 828 | query_handle->profile()->ToJson(profile->json_output); |
| 829 | } else { |
| 830 | DCHECK_EQ(format, TRuntimeProfileFormat::STRING); |
| 831 | query_handle->profile()->PrettyPrint(profile->string_output); |
| 832 | } |
| 833 | int64_t elapsed_time_ns = MonotonicNanos() - start_time_ns; |
| 834 | if (elapsed_time_ns > FLAGS_slow_profile_dump_warning_threshold_ms * 1000 * 1000) { |
| 835 | LOG(WARNING) << "Slow in dumping " << format << " profile of " |
| 836 | << PrintId(query_handle->query_id()) << ". User " << user |
| 837 | << " held the lock for " << PrettyPrinter::Print(elapsed_time_ns, TUnit::TIME_NS) |
| 838 | << " (" << elapsed_time_ns << "ns). This might block client in fetching query " |
| 839 | << "results."; |
| 840 | } |
| 841 | query_handle->UpdateGetInFlightProfileTime(elapsed_time_ns); |
| 842 | return Status::OK(); |
| 843 | } |
| 844 | |
| 845 | Status ImpalaServer::GetQueryRecord(const TUniqueId& query_id, |
| 846 | shared_ptr<QueryStateRecord>* query_record, |
no test coverage detected