From ad69fb0401356a585fbd1492b0abb86241681b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Thu, 8 Oct 2026 11:29:08 +0500 Subject: [PATCH] Do not report an SQL error as "the database is not running" Only the client's own connection errors (ERROR 2003 and 2002, "Can't connect") count as a stopped database. The SQLSTATE 22003 of an out-of-range value contains "2003" and hid the real error of a failing release migration. The message now also carries the client's last line. Co-Authored-By: Claude Sonnet 5.5 --- changelog.d/20261008-database-error-not-misread.md | 7 +++++++ crates/coa-core/src/db.rs | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changelog.d/20261008-database-error-not-misread.md diff --git a/changelog.d/20261008-database-error-not-misread.md b/changelog.d/20261008-database-error-not-misread.md new file mode 100644 index 0000000..e98b252 --- /dev/null +++ b/changelog.d/20261008-database-error-not-misread.md @@ -0,0 +1,7 @@ +--- +area: manager +type: fixed +audience: admins +title: A failing database update is no longer reported as "database not running" +--- +An SQL error whose message contained the number 2003, such as an out-of-range value, was shown as "The database is not running". The real error is now shown. diff --git a/crates/coa-core/src/db.rs b/crates/coa-core/src/db.rs index 0024b7a..0786ad6 100644 --- a/crates/coa-core/src/db.rs +++ b/crates/coa-core/src/db.rs @@ -176,10 +176,13 @@ impl Db { fn fail(&self, stderr: &[u8]) -> Error { let text = String::from_utf8_lossy(stderr); - let down = text.contains("2003") || text.contains("Can't connect") || text.contains("is not running") || text.contains("No such container"); + // Only the client's own connection errors mean "not running": the number 2003 or the words can also appear inside + // the message of an ordinary SQL error (a duplicate entry, a row number) and must not hide it. + let down = text.contains("ERROR 2003") || text.contains("ERROR 2002") || text.contains("Can't connect to MySQL server") + || text.contains("No such container") || text.contains("is not running"); let code = if down { ErrorCode::DatabaseNotRunning } else { ErrorCode::Unknown }; match code { - ErrorCode::DatabaseNotRunning => Error::Invalid("The database is not running. Start the server first.".into()), + ErrorCode::DatabaseNotRunning => Error::Invalid(format!("The database is not running. Start the server first. ({})", text.trim().lines().last().unwrap_or("").chars().take(300).collect::())), _ => Error::Invalid(format!("database command failed: {}", text.trim().lines().last().unwrap_or(""))), } }