Audit of warn! and error! - #5640
Conversation
| // TODO: May need to split this from module errors vs host errors | ||
| log::warn!("Internal error while invoking procedure {procedure}: {e:#}"); | ||
| StatusCode::INTERNAL_SERVER_ERROR |
There was a problem hiding this comment.
Could we preserve whether this failure came from module code or the host? Module errors should remain low-level and eventually go to module logs, while internal host failures may need to stay at error! for alerting.
| if ws_version == WsVersion::V1 | ||
| && let MessageHandleError::Execution(err) = e | ||
| { | ||
| // TODO: Review log level after guest/client execution errors can be distinguished from internal failures. | ||
| log::error!("{err:#}"); | ||
| // If the send task has exited, also exit this recv task. | ||
| if unordered_tx.send(err.into()).is_err() { |
There was a problem hiding this comment.
This looks to combine module errors with possible host errors, that leads me to lean error! for now
There was a problem hiding this comment.
If we can't distinguish, I think we should prefer warn for now. I don't have context on where this error comes from or what we'd be splitting up; can you create a follow-up ticket under the "Alerting" header and mark it P2?
| .map_err(|e| { | ||
| // TODO: Review log level after user SQL errors can be distinguished from internal database failures. | ||
| log::warn!("{e}"); | ||
| (StatusCode::BAD_REQUEST, e.to_string()) |
There was a problem hiding this comment.
Same as other areas we might want to split this up so we can use error! if there is a database failure.
There was a problem hiding this comment.
Can you create a follow-up ticket?
| // TODO: Review each caller and split this helper by the appropriate log severity. | ||
| pub fn log_and_500(e: impl std::fmt::Display) -> ErrorResponse { | ||
| log::error!("internal error: {e:#}"); | ||
| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:#}")).into() |
There was a problem hiding this comment.
This seems to be very broadly used which makes it hard to know if it should be reduced from error! my gut reaction is to change it to warn! and slowly clean up it's use?
There was a problem hiding this comment.
Please change to warn for now, and any place you're already editing that has a log_and_500 directly next to its own more specific log line, remove the log_and_500 call and replace with directly returning the error response. You may want to move the error response into a new helper function.
| // TODO: Review log level after configured issuers can be distinguished from arbitrary token issuers. | ||
| log::warn!("Error fetching public key for issuer {raw_issuer}: {e:?}"); |
There was a problem hiding this comment.
This one I'm not 100% sure if we need to split up or count everything as warn!
There was a problem hiding this comment.
I have no clue. At this stage I'm unconcerned.
| // TODO: Review log level after migration/user errors can be distinguished from internal database failures. | ||
| log::warn!("Database update failed: {} @ {}", e, stdb.database_identity()); | ||
| system_logger.warn(&format!("Database update failed: {e}")); | ||
| let (_, tx_metrics, reducer) = stdb.rollback_mut_tx(tx); |
There was a problem hiding this comment.
Another spot where it looks like real failures can be mixed in with user issues.
| // TODO: Review log level after guest view errors can be distinguished from materialization failures. | ||
| log::error!("Error materializing view `{view_name}`: {err:?}"); | ||
| ViewOutcome::Failed(format!("Error materializing view `{view_name}`: {err}")) |
There was a problem hiding this comment.
This one looked similar as above but I'm not certain if it's true that it can be mixed here.
There was a problem hiding this comment.
Another follow-up ticket? And, can @joshua-spacetime weigh in as to whether user errors can happen here, which I assume would be if a view function panics.
|
FYI #5320 is about to merge which tweaks some logs as well |
Signed-off-by: Jason Larabie <jason@clockworklabs.io>
| // TODO: May need to split this from module errors vs host errors | ||
| log::warn!("Internal error while invoking procedure {procedure}: {e:#}"); | ||
| StatusCode::INTERNAL_SERVER_ERROR |
| if ws_version == WsVersion::V1 | ||
| && let MessageHandleError::Execution(err) = e | ||
| { | ||
| // TODO: Review log level after guest/client execution errors can be distinguished from internal failures. | ||
| log::error!("{err:#}"); | ||
| // If the send task has exited, also exit this recv task. | ||
| if unordered_tx.send(err.into()).is_err() { |
There was a problem hiding this comment.
If we can't distinguish, I think we should prefer warn for now. I don't have context on where this error comes from or what we'd be splitting up; can you create a follow-up ticket under the "Alerting" header and mark it P2?
| .map_err(|e| { | ||
| // TODO: Review log level after user SQL errors can be distinguished from internal database failures. | ||
| log::warn!("{e}"); | ||
| (StatusCode::BAD_REQUEST, e.to_string()) |
There was a problem hiding this comment.
Can you create a follow-up ticket?
| // TODO: Review each caller and split this helper by the appropriate log severity. | ||
| pub fn log_and_500(e: impl std::fmt::Display) -> ErrorResponse { | ||
| log::error!("internal error: {e:#}"); | ||
| (StatusCode::INTERNAL_SERVER_ERROR, format!("{e:#}")).into() |
There was a problem hiding this comment.
Please change to warn for now, and any place you're already editing that has a log_and_500 directly next to its own more specific log line, remove the log_and_500 call and replace with directly returning the error response. You may want to move the error response into a new helper function.
| // TODO: Review log level after configured issuers can be distinguished from arbitrary token issuers. | ||
| log::warn!("Error fetching public key for issuer {raw_issuer}: {e:?}"); |
There was a problem hiding this comment.
I have no clue. At this stage I'm unconcerned.
| Some(ptr) => self.delete(ST_CLIENT_ID, ptr).map(drop)?, | ||
| _ => { | ||
| log::error!( | ||
| log::warn!( |
There was a problem hiding this comment.
@joshua-spacetime how can this (and the other previously error! logs in this file) happen, and how bad is it?
| } | ||
| Err(e) => { | ||
| // TODO: Review log level after retryable cleanup errors can be distinguished from internal database failures. | ||
| log::error!( |
There was a problem hiding this comment.
What user errors can get mixed in here?
| let res = self | ||
| .maybe_take_snapshot(database_state.as_ref()) | ||
| .await | ||
| // TODO: Review log level after lifecycle errors can be distinguished from snapshot creation failures. |
There was a problem hiding this comment.
Please create a follow-up ticket.
| // TODO: Review log level after client SQL errors can be distinguished from internal database failures. | ||
| log::error!("PG: Error for database {database}: {err}"); |
There was a problem hiding this comment.
Downgrade to warn, at least until the TODO is done. Please make a follow-up ticket, but mark it P3.
| // TODO: Do not log the supplied password/token; then classify credential errors separately from provider failures. | ||
| log::error!( |
There was a problem hiding this comment.
Please downgrade to warn, and make a P3 follow-up, as above.
Description of Changes
Reviewed all warn! and error! lines for host side issues to get ready for alerting.
API and ABI breaking changes
No breaking changes.
Expected complexity level and risk
1 - Only changes to logging
Testing
cargo testagainst impacted crates