From c8ea95564cb4a2e5f8cc795ef87961930be8355f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 19 Sep 2024 22:57:23 +0000 Subject: [PATCH 1/3] reload of TLS certificates after a crash #4658 Closes #4658 --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 382b42363..85efe4f20 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1474,6 +1474,9 @@ bool ProxySQL_daemonize_phase3() { proxy_info("ProxySQL SHA1 checksum: %s\n", binary_sha1); } call_execute_on_exit_failure(); + // automatic reload of TLS certificates after a crash , see #4658 + std::string msg; + ProxySQL_create_or_load_TLS(false, msg); parent_close_error_log(); return false; } From 061198dda146477d1577a5f8c9aa2d2b05de1fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 19 Sep 2024 23:01:43 +0000 Subject: [PATCH 2/3] Honor --initial after a crash , see #4659 Closes #4659 --- src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 85efe4f20..9dd86b804 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1477,6 +1477,13 @@ bool ProxySQL_daemonize_phase3() { // automatic reload of TLS certificates after a crash , see #4658 std::string msg; ProxySQL_create_or_load_TLS(false, msg); + // Honor --initial after a crash , see #4659 + if (GloVars.__cmd_proxysql_initial==true) { + std::cerr << "Renaming database file " << GloVars.admindb << endl; + char *newpath=(char *)malloc(strlen(GloVars.admindb)+8); + sprintf(newpath,"%s.bak",GloVars.admindb); + rename(GloVars.admindb,newpath); // FIXME: should we check return value, or ignore whatever it successed or not? + } parent_close_error_log(); return false; } From 774b405a74f3bd2b8527cd1f8d2c661f53ffd973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 19 Sep 2024 23:13:03 +0000 Subject: [PATCH 3/3] Make call_execute_on_exit_failure() more verbose --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9dd86b804..76f02a073 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1380,15 +1380,15 @@ bool ProxySQL_daemonize_phase2() { * @note This function does not return if an error occurs; it exits the process. */ void call_execute_on_exit_failure() { + // Log a message indicating the attempt to call the external script + proxy_info("Trying to call external script after exit failure: %s\n", GloVars.execute_on_exit_failure ? GloVars.execute_on_exit_failure : "(null)"); + // Check if the global variable execute_on_exit_failure is NULL if (GloVars.execute_on_exit_failure == NULL) { // Exit the function if the variable is not set return; } - // Log a message indicating the attempt to call the external script - proxy_error("Trying to call external script after exit failure: %s\n", GloVars.execute_on_exit_failure); - // Fork a child process pid_t cpid; cpid = fork();