| 130 | } |
| 131 | |
| 132 | void ControlService::ExecQueryFInstances(const ExecQueryFInstancesRequestPB* request, |
| 133 | ExecQueryFInstancesResponsePB* response, RpcContext* rpc_context) { |
| 134 | DebugActionNoFail(FLAGS_debug_actions, "EXEC_QUERY_FINSTANCES_DELAY"); |
| 135 | DCHECK(request->has_coord_state_idx()); |
| 136 | DCHECK(request->has_plan_fragment_info_sidecar_idx()); |
| 137 | DCHECK(request->has_query_ctx_sidecar_idx()); |
| 138 | // Deserialize the sidecars. The QueryState will make a copy of the TQueryCtx and |
| 139 | // TExecPlanFragmentInfo, so we can deallocate the deserialized values after |
| 140 | // StartQuery(). TODO: can we avoid this extra copy? |
| 141 | TExecPlanFragmentInfo fragment_info; |
| 142 | const Status& fragment_info_sidecar_status = |
| 143 | GetSidecar(request->plan_fragment_info_sidecar_idx(), rpc_context, &fragment_info); |
| 144 | if (!fragment_info_sidecar_status.ok()) { |
| 145 | RespondAndReleaseRpc(fragment_info_sidecar_status, response, rpc_context); |
| 146 | return; |
| 147 | } |
| 148 | TQueryCtx query_ctx; |
| 149 | const Status& query_ctx_sidecar_status = |
| 150 | GetSidecar(request->query_ctx_sidecar_idx(), rpc_context, &query_ctx); |
| 151 | if (!query_ctx_sidecar_status.ok()) { |
| 152 | RespondAndReleaseRpc(query_ctx_sidecar_status, response, rpc_context); |
| 153 | return; |
| 154 | } |
| 155 | ScopedThreadContext scoped_tdi(GetThreadDebugInfo(), query_ctx.query_id); |
| 156 | VLOG_QUERY << "ExecQueryFInstances():" |
| 157 | << " query_id=" << PrintId(query_ctx.query_id) |
| 158 | << " coord=" << query_ctx.coord_hostname << ":" |
| 159 | << query_ctx.coord_ip_address.port |
| 160 | << " #instances=" << fragment_info.fragment_instance_ctxs.size(); |
| 161 | Status resp_status; |
| 162 | if (UNLIKELY(fragment_info.fragments.size() == 0 |
| 163 | || fragment_info.fragment_instance_ctxs.size() == 0)) { |
| 164 | resp_status = Status(Substitute("ExecQueryFInstances() failed: query_id=: $0, " |
| 165 | "no instance in TExecPlanFragmentInfo", PrintId(query_ctx.query_id))); |
| 166 | LOG(ERROR) << resp_status.msg().msg(); |
| 167 | RespondAndReleaseRpc(resp_status, response, rpc_context); |
| 168 | return; |
| 169 | } |
| 170 | resp_status = ExecEnv::GetInstance()->query_exec_mgr()->StartQuery( |
| 171 | request, query_ctx, fragment_info); |
| 172 | if (!resp_status.ok()) { |
| 173 | LOG(INFO) << "ExecQueryFInstances() failed: query_id=" << PrintId(query_ctx.query_id) |
| 174 | << ": " << resp_status.GetDetail(); |
| 175 | } |
| 176 | RespondAndReleaseRpc(resp_status, response, rpc_context); |
| 177 | } |
| 178 | |
| 179 | void ControlService::ReportExecStatus(const ReportExecStatusRequestPB* request, |
| 180 | ReportExecStatusResponsePB* response, RpcContext* rpc_context) { |
nothing calls this directly
no test coverage detected