| 164 | } |
| 165 | |
| 166 | Status QueryState::Init(const ExecQueryFInstancesRequestPB* exec_rpc_params, |
| 167 | const TExecPlanFragmentInfo& fragment_info) { |
| 168 | std::lock_guard<std::mutex> l(init_lock_); |
| 169 | // Decremented in QueryExecMgr::StartQueryHelper() on success or by the caller of |
| 170 | // Init() on failure. We need to do this before any returns because Init() always |
| 171 | // returns a resource refcount to its caller. |
| 172 | AcquireBackendResourceRefcount(); |
| 173 | |
| 174 | if (IsCancelled()) return Status::CANCELLED; |
| 175 | |
| 176 | RETURN_IF_ERROR(DebugAction(query_options(), "QUERY_STATE_INIT")); |
| 177 | |
| 178 | ExecEnv* exec_env = ExecEnv::GetInstance(); |
| 179 | |
| 180 | RuntimeProfile* jvm_host_profile = RuntimeProfile::Create(&obj_pool_, "JVM", false); |
| 181 | host_profile_->AddChild(jvm_host_profile); |
| 182 | |
| 183 | int64_t gc_count = JvmMemoryCounterMetric::GC_COUNT->GetValue(); |
| 184 | PROFILE_GcCount.Instantiate(jvm_host_profile, |
| 185 | [gc_count]() { |
| 186 | return JvmMemoryCounterMetric::GC_COUNT->GetValue() - gc_count; |
| 187 | }); |
| 188 | |
| 189 | int64_t gc_time_millis = JvmMemoryCounterMetric::GC_TIME_MILLIS->GetValue(); |
| 190 | PROFILE_GcTimeMillis.Instantiate(jvm_host_profile, |
| 191 | [gc_time_millis]() { |
| 192 | return JvmMemoryCounterMetric::GC_TIME_MILLIS->GetValue() - gc_time_millis; |
| 193 | }); |
| 194 | |
| 195 | int64_t gc_num_warn_threshold_exceeded = |
| 196 | JvmMemoryCounterMetric::GC_NUM_WARN_THRESHOLD_EXCEEDED->GetValue(); |
| 197 | PROFILE_GcNumWarnThresholdExceeded.Instantiate(jvm_host_profile, |
| 198 | [gc_num_warn_threshold_exceeded]() { |
| 199 | return JvmMemoryCounterMetric::GC_NUM_WARN_THRESHOLD_EXCEEDED->GetValue() |
| 200 | - gc_num_warn_threshold_exceeded; |
| 201 | }); |
| 202 | |
| 203 | int64_t gc_num_info_threshold_exceeded = |
| 204 | JvmMemoryCounterMetric::GC_NUM_INFO_THRESHOLD_EXCEEDED->GetValue(); |
| 205 | PROFILE_GcNumInfoThresholdExceeded.Instantiate(jvm_host_profile, |
| 206 | [gc_num_info_threshold_exceeded]() { |
| 207 | return JvmMemoryCounterMetric::GC_NUM_INFO_THRESHOLD_EXCEEDED->GetValue() |
| 208 | - gc_num_info_threshold_exceeded; |
| 209 | }); |
| 210 | |
| 211 | int64_t gc_total_extra_sleep_time_millis = |
| 212 | JvmMemoryCounterMetric::GC_TOTAL_EXTRA_SLEEP_TIME_MILLIS->GetValue(); |
| 213 | PROFILE_GcTotalExtraSleepTimeMillis.Instantiate(jvm_host_profile, |
| 214 | [gc_total_extra_sleep_time_millis]() { |
| 215 | return JvmMemoryCounterMetric::GC_TOTAL_EXTRA_SLEEP_TIME_MILLIS->GetValue() |
| 216 | - gc_total_extra_sleep_time_millis; |
| 217 | }); |
| 218 | |
| 219 | // Initialize resource tracking counters. |
| 220 | if (query_ctx().trace_resource_usage) { |
| 221 | SystemStateInfo* system_state_info = exec_env->system_state_info(); |
| 222 | host_profile_->AddSamplingTimeSeriesCounter( |
| 223 | "HostCpuUserPercentage", TUnit::BASIS_POINTS, [system_state_info] () { |
nothing calls this directly
no test coverage detected