From 8a71069517c856cbc27aa624b7f9893129893c79 Mon Sep 17 00:00:00 2001 From: Gustavo Garcia Date: Thu, 22 May 2025 11:29:36 +0200 Subject: [PATCH] Improve MySQL connection error logging to include actual MySQL error message (#1679) Address #270 MySQL reconnectiong after priviledge drop and reporting missleading error log. "Cannot open MySQL DB connection: <%s>, runtime error\n" Always include the mysql error message for additional context. --- src/apps/relay/dbdrivers/dbd_mysql.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/relay/dbdrivers/dbd_mysql.c b/src/apps/relay/dbdrivers/dbd_mysql.c index 238316c..638dbe1 100644 --- a/src/apps/relay/dbdrivers/dbd_mysql.c +++ b/src/apps/relay/dbdrivers/dbd_mysql.c @@ -295,8 +295,8 @@ static MYSQL *get_mydb_connection(void) { MYSQL *conn = mysql_real_connect(mydbconnection, co->host, co->user, co->password, co->dbname, co->port, NULL, CLIENT_IGNORE_SIGPIPE); if (!conn) { - TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open MySQL DB connection: <%s>, runtime error\n", - pud->userdb_sanitized); + TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open MySQL DB connection: <%s>, runtime error: %s\n", + pud->userdb_sanitized, mysql_error(mydbconnection)); mysql_close(mydbconnection); mydbconnection = NULL; } else if (mysql_select_db(mydbconnection, co->dbname)) {