| 473 | } |
| 474 | |
| 475 | void QueryState::UpdateBackendExecState() { |
| 476 | DFAKE_SCOPED_LOCK(backend_exec_state_lock_); |
| 477 | { |
| 478 | BackendExecState cur_state = backend_exec_state_; |
| 479 | unique_lock<SpinLock> l(status_lock_); |
| 480 | // We shouldn't call this function if we're already in a terminal state. |
| 481 | DCHECK(cur_state == BackendExecState::PREPARING || |
| 482 | cur_state == BackendExecState::EXECUTING) |
| 483 | << " Current State: " << BackendExecStateToString(cur_state) |
| 484 | << " | Current Status: " << overall_status_.GetDetail(); |
| 485 | if (overall_status_.IsCancelled()) { |
| 486 | // Received cancellation - go to CANCELLED state. |
| 487 | backend_exec_state_ = BackendExecState::CANCELLED; |
| 488 | } else if (!overall_status_.ok()) { |
| 489 | // Error while executing - go to ERROR state. |
| 490 | backend_exec_state_ = BackendExecState::ERROR; |
| 491 | } else { |
| 492 | // Transition to the next state in the lifecycle. |
| 493 | backend_exec_state_ = cur_state == BackendExecState::PREPARING ? |
| 494 | BackendExecState::EXECUTING : BackendExecState::FINISHED; |
| 495 | } |
| 496 | } |
| 497 | // Send one last report if the query has reached the terminal state |
| 498 | // and the coordinator is active. |
| 499 | if (IsTerminalState()) { |
| 500 | VLOG_QUERY << "UpdateBackendExecState(): last report for " << PrintId(query_id()); |
| 501 | while (is_coord_active_.Load() && !ReportExecStatus()) { |
| 502 | SleepForMs(GetReportWaitTimeMs()); |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | Status QueryState::GetFInstanceState( |
| 508 | const TUniqueId& instance_id, FragmentInstanceState** fi_state) { |
nothing calls this directly
no test coverage detected