| 3249 | } |
| 3250 | |
| 3251 | Status ImpalaServer::CheckResourceLimits(ClientRequestState* crs) { |
| 3252 | Coordinator* coord = crs->GetCoordinator(); |
| 3253 | // Coordinator may be null if query has not started executing, check again later. |
| 3254 | if (coord == nullptr) return Status::OK(); |
| 3255 | Coordinator::ResourceUtilization utilization = coord->ComputeQueryResourceUtilization(); |
| 3256 | |
| 3257 | // CPU time consumed by the query so far |
| 3258 | int64_t cpu_time_ns = utilization.cpu_sys_ns + utilization.cpu_user_ns; |
| 3259 | int64_t cpu_limit_s = crs->query_options().cpu_limit_s; |
| 3260 | int64_t cpu_limit_ns = cpu_limit_s * 1000'000'000L; |
| 3261 | if (cpu_limit_ns > 0 && cpu_time_ns > cpu_limit_ns) { |
| 3262 | Status err = Status::Expected(TErrorCode::CPU_LIMIT_EXCEEDED, |
| 3263 | PrintId(crs->query_id()), PrettyPrinter::Print(cpu_limit_s, TUnit::TIME_S)); |
| 3264 | VLOG_QUERY << err.msg().msg(); |
| 3265 | return err; |
| 3266 | } |
| 3267 | |
| 3268 | int64_t scan_bytes = utilization.bytes_read; |
| 3269 | int64_t scan_bytes_limit = crs->query_options().scan_bytes_limit; |
| 3270 | if (scan_bytes_limit > 0 && scan_bytes > scan_bytes_limit) { |
| 3271 | Status err = Status::Expected(TErrorCode::SCAN_BYTES_LIMIT_EXCEEDED, |
| 3272 | PrintId(crs->query_id()), PrettyPrinter::Print(scan_bytes_limit, TUnit::BYTES)); |
| 3273 | VLOG_QUERY << err.msg().msg(); |
| 3274 | return err; |
| 3275 | } |
| 3276 | |
| 3277 | auto& max_join_node_entry = utilization.MaxJoinNodeRowsProduced(); |
| 3278 | int32_t join_node_id = max_join_node_entry.first; |
| 3279 | int64_t join_rows_produced = max_join_node_entry.second; |
| 3280 | int64_t join_rows_produced_limit = crs->query_options().join_rows_produced_limit; |
| 3281 | if (join_rows_produced_limit > 0 && join_rows_produced > join_rows_produced_limit) { |
| 3282 | Status err = Status::Expected(TErrorCode::JOIN_ROWS_PRODUCED_LIMIT_EXCEEDED, |
| 3283 | PrintId(crs->query_id()), |
| 3284 | PrettyPrinter::Print(join_rows_produced_limit, TUnit::UNIT), join_node_id); |
| 3285 | VLOG_QUERY << err.msg().msg(); |
| 3286 | return err; |
| 3287 | } |
| 3288 | // Query is within the resource limits, check again later. |
| 3289 | return Status::OK(); |
| 3290 | } |
| 3291 | |
| 3292 | void ImpalaServer::ExpireQuery(ClientRequestState* crs, const Status& status, |
| 3293 | bool unregister) { |
nothing calls this directly
no test coverage detected