| 188 | } |
| 189 | |
| 190 | bool RuntimeState::LogError(const ErrorMsg& message, int vlog_level) { |
| 191 | lock_guard<SpinLock> l(error_log_lock_); |
| 192 | // All errors go to the log. If the amount of errors logged to vlog level 1 exceed |
| 193 | // or equal max_error_logs_per_instance, then that error will be downgraded to vlog |
| 194 | // level 2. |
| 195 | int user_max_errors = query_options().max_errors; |
| 196 | if (vlog_level == 1 && user_max_errors >= 0 |
| 197 | && vlog_1_errors >= FLAGS_max_error_logs_per_instance) { |
| 198 | vlog_level = 2; |
| 199 | } |
| 200 | |
| 201 | if (VLOG_IS_ON(vlog_level)) { |
| 202 | VLOG(vlog_level) << "Error from query " << PrintId(query_id()) << ": " |
| 203 | << message.msg(); |
| 204 | } |
| 205 | |
| 206 | if (vlog_level == 1 && user_max_errors >= 0) { |
| 207 | vlog_1_errors++; |
| 208 | DCHECK_LE(vlog_1_errors, FLAGS_max_error_logs_per_instance); |
| 209 | if (vlog_1_errors == FLAGS_max_error_logs_per_instance) { |
| 210 | VLOG(vlog_level) << "Query " << PrintId(query_id()) << " printed " |
| 211 | << FLAGS_max_error_logs_per_instance |
| 212 | << " non-fatal error to log level 1 (INFO). Further non-fatal " |
| 213 | << "error will be downgraded to log level 2 (DEBUG)."; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | TErrorCode::type code = message.error(); |
| 218 | if (ErrorCount(error_log_) < max_errors() |
| 219 | || (code != TErrorCode::GENERAL && error_log_.find(code) != error_log_.end())) { |
| 220 | // Appending general error is expensive since it writes the entire message to the |
| 221 | // error_log_ map. Meanwhile, appending non-general (specific) error that already |
| 222 | // exist in error_log_ is cheap since it only increment count. |
| 223 | AppendError(&error_log_, message); |
| 224 | return true; |
| 225 | } |
| 226 | return false; |
| 227 | } |
| 228 | |
| 229 | void RuntimeState::GetUnreportedErrors(ErrorLogMapPB* new_errors) { |
| 230 | new_errors->clear(); |
no test coverage detected