From 2b23bd31029ef71ea5562a515187db083b4bf00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 3 Feb 2021 22:10:57 +0100 Subject: [PATCH] Avoid MySQL bug 102266 #3276 ProxySQL is sending a lot of data to MySQL server using CLIENT_CONNECT_ATTRS in order to not hit MySQL bug https://bugs.mysql.com/bug.php?id=102266 . See also https://github.com/sysown/proxysql/issues/3276 --- lib/mysql_connection.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 5ab2ca4f4..4519c7e8d 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -12,6 +12,8 @@ #include +extern char * binary_sha1; + extern const MARIADB_CHARSET_INFO * proxysql_find_charset_nr(unsigned int nr); MARIADB_CHARSET_INFO * proxysql_find_charset_name(const char *name); @@ -539,6 +541,28 @@ void MySQL_Connection::connect_start() { mysql_options(mysql, MYSQL_OPT_NONBLOCK, 0); mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "program_name", "proxysql"); mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "_server_host", parent->address); + { + time_t __timer; + char __buffer[25]; + struct tm *__tm_info; + time(&__timer); + __tm_info = localtime(&__timer); + strftime(__buffer, 25, "%Y-%m-%d %H:%M:%S", __tm_info); + mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "connection_creation_time", __buffer); + unsigned long long t1=monotonic_time(); + sprintf(__buffer,"%llu",(t1-GloVars.global.start_time)/1000/1000); + mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "proxysql_uptime", __buffer); + sprintf(__buffer,"%d", parent->myhgc->hid); + mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "hostgroup_id", __buffer); + mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "compile_time", __TIMESTAMP__); + mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "proxysql_version", PROXYSQL_VERSION); + if (binary_sha1) { + mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "proxysql_sha1", binary_sha1); + } else { + mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "proxysql_sha1", "unknown"); + } + mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "mysql_bug_102266", "ProxySQL is sending a lot of data to MySQL server using CLIENT_CONNECT_ATTRS in order to not hit MySQL bug https://bugs.mysql.com/bug.php?id=102266 . See also https://github.com/sysown/proxysql/issues/3276"); + } if (parent->use_ssl) { mysql_ssl_set(mysql, mysql_thread___ssl_p2s_key, mysql_thread___ssl_p2s_cert, mysql_thread___ssl_p2s_ca, NULL, mysql_thread___ssl_p2s_cipher); }