From 9850d9daebdb2cf2d06c4df0bb6d0eb271ccf3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 22 Mar 2026 16:11:15 +0100 Subject: [PATCH] Fix stats_global substring collision and reload failure tracking 1. stats_global strstr match: add exclusion guards for stats_mysql_global and stats_pgsql_global to prevent spurious stats___global() calls and unnecessary ssl_mutex contention on every MySQL/PgSQL global stats query. 2. TLS reload failure tracking: set tls_last_load_ok=false and update tls_load_count/tls_last_load_timestamp on non-bootstrap reload failures. Previously, a failed PROXYSQL RELOAD TLS would leave stale SUCCESS status in stats_global. --- lib/ProxySQL_Admin.cpp | 2 +- src/proxy_tls.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 3d5c702be..7f9ae9fa6 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -1450,7 +1450,7 @@ bool ProxySQL_Admin::GenericRefreshStatistics(const char *query_no_space, unsign { stats_pgsql_client_host_cache_reset = true; refresh = true; } if (strstr(query_no_space,"stats_tls_certificates")) { stats_tls_certificates=true; refresh=true; } - if (strstr(query_no_space,"stats_global")) + if (strstr(query_no_space,"stats_global") && !strstr(query_no_space,"stats_mysql_global") && !strstr(query_no_space,"stats_pgsql_global")) { stats_global=true; refresh=true; } if (strstr(query_no_space,"stats_proxysql_servers_checksums")) { stats_proxysql_servers_checksums = true; refresh = true; } diff --git a/src/proxy_tls.cpp b/src/proxy_tls.cpp index 56a3e9bd0..38acc553f 100644 --- a/src/proxy_tls.cpp +++ b/src/proxy_tls.cpp @@ -485,6 +485,12 @@ int ProxySQL_create_or_load_TLS(bool bootstrap, std::string& msg) { // Completely disable session tickets and session-cache. See comment above. SSL_CTX_set_options(GloVars.global.ssl_ctx, SSL_OP_NO_TICKET); SSL_CTX_set_session_cache_mode(GloVars.global.ssl_ctx, SSL_SESS_CACHE_OFF); + } else if (!bootstrap) { + // Record reload failure in TLS tracking stats + std::lock_guard lock(GloVars.global.ssl_mutex); + GloVars.global.tls_load_count++; + GloVars.global.tls_last_load_timestamp = time(NULL); + GloVars.global.tls_last_load_ok = false; } X509_free(x509); EVP_PKEY_free(pkey);