| 1326 | } |
| 1327 | |
| 1328 | void ClientRequestState::Wait() { |
| 1329 | // block until results are ready |
| 1330 | Status status = WaitInternal(); |
| 1331 | // Rows are available now (for SELECT statement), so start the 'wait' timer that tracks |
| 1332 | // how long Impala waits for the client to fetch rows. For other statements, track the |
| 1333 | // time until a Close() is received. |
| 1334 | MarkInactive(); |
| 1335 | { |
| 1336 | lock_guard<mutex> l(lock_); |
| 1337 | if (returns_result_set()) { |
| 1338 | query_events()->MarkEvent("Rows available"); |
| 1339 | if (LIKELY(status.code() != TErrorCode::CANCELLED) && otel_trace_query()) { |
| 1340 | otel_trace_manager_->AddChildSpanEvent("RowsAvailable"); |
| 1341 | } |
| 1342 | } else { |
| 1343 | query_events()->MarkEvent("Request finished"); |
| 1344 | UpdateEndTime(); |
| 1345 | } |
| 1346 | discard_result(UpdateQueryStatus(status)); |
| 1347 | } |
| 1348 | |
| 1349 | if (status.ok()) { |
| 1350 | if (stmt_type() == TStmtType::DDL) { |
| 1351 | DCHECK(catalog_op_type() != TCatalogOpType::DDL || request_result_set_ != nullptr); |
| 1352 | } |
| 1353 | // It is possible the query already failed at this point and ExecState is ERROR. In |
| 1354 | // this case, the call to UpdateNonErrorExecState(FINISHED) does not change the |
| 1355 | // ExecState. |
| 1356 | UpdateNonErrorExecState(ExecState::FINISHED); |
| 1357 | } |
| 1358 | // UpdateQueryStatus() or UpdateNonErrorExecState() have updated exec_state_. |
| 1359 | DCHECK(exec_state() == ExecState::FINISHED || exec_state() == ExecState::ERROR |
| 1360 | || retry_state() == RetryState::RETRYING || retry_state() == RetryState::RETRIED); |
| 1361 | // Notify all the threads blocked on Wait() to finish and then log the query events, |
| 1362 | // if any. |
| 1363 | { |
| 1364 | unique_lock<mutex> l(lock_); |
| 1365 | is_wait_done_ = true; |
| 1366 | } |
| 1367 | block_on_wait_cv_.NotifyAll(); |
| 1368 | LogQueryEvents(); |
| 1369 | } |
| 1370 | |
| 1371 | Status ClientRequestState::WaitInternal() { |
| 1372 | // Explain requests have already populated the result set. Nothing to do here. |
no test coverage detected