From 22ff0feea41b0ce3460ebcfcbdf062eedaf816be Mon Sep 17 00:00:00 2001 From: Miro Stauder Date: Fri, 13 Jan 2023 09:58:43 +0000 Subject: [PATCH 1/3] bump version to 2.5.0 at the beginning of the development cycle --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d89724d45e..e7dae05864 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ DEBUG=${ALL_DEBUG} #export OPTZ #export EXTRALINK export MAKE -export CURVER?=2.4.6 +export CURVER?=2.5.0 ifneq (,$(wildcard /etc/os-release)) DISTRO := $(shell gawk -F= '/^NAME/{print $$2}' /etc/os-release) else From b1a14bd303ef104a966ade5d831d0c950aff7c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 17 Jan 2023 22:23:43 +0000 Subject: [PATCH 2/3] If SSL is used for frontend connections or fast_forward , try to consume all the bytes on the network buffer --- lib/ClickHouse_Server.cpp | 6 +++--- lib/MySQL_Thread.cpp | 8 +++++--- lib/ProxySQL_Admin.cpp | 6 +++--- src/SQLite3_Server.cpp | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/ClickHouse_Server.cpp b/lib/ClickHouse_Server.cpp index b3b61061cf..ef3b2ec0e4 100644 --- a/lib/ClickHouse_Server.cpp +++ b/lib/ClickHouse_Server.cpp @@ -1375,11 +1375,11 @@ static void *child_mysql(void *arg) { // PMC-10004 // we probably should use SSL_pending() and/or SSL_has_pending() to determine // if there is more data to be read, but it doesn't seem to be working. - // Therefore we hardcored the values 4096 (4K) as a special case and - // we try to call read_from_net() again. + // Therefore we try to call read_from_net() again as long as there is data. // Previously we hardcoded 16KB but it seems that it can return in smaller // chunks of 4KB. - while (rb > 0 && rb%4096 == 0) { + // We finally removed the chunk size as it seems that any size is possible. + while (rb > 0) { rb = myds->read_from_net(); if (myds->net_failure) goto __exit_child_mysql; myds->read_pkts(); diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 6c07718122..64b6f592d0 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -3598,15 +3598,17 @@ bool MySQL_Thread::process_data_on_data_stream(MySQL_Data_Stream *myds, unsigned // PMC-10004 // we probably should use SSL_pending() and/or SSL_has_pending() to determine // if there is more data to be read, but it doesn't seem to be working. - // Therefore we hardcored the value 16384 (16KB) as a special case and - // we try to call read_from_net() again + // Therefore we try to call read_from_net() again as long as there is data. + // Previously we hardcoded 16KB but it seems that it can return in smaller + // chunks of 4KB. + // We finally removed the chunk size as it seems that any size is possible. /* int sslp = SSL_pending(myds->ssl); int sslhp = SSL_has_pending(myds->ssl); proxy_debug(PROXY_DEBUG_NET, 5, "Session=%p: in fast_forward mode and SSL read %d bytes , SSL_pending: %d bytes , SSL_has_pending: %d\n", myds->sess, rb, sslp, sslhp); */ proxy_debug(PROXY_DEBUG_NET, 5, "Session=%p, DataStream=%p , thread_session_id=%u -- in fast_forward mode and SSL read %d bytes\n", myds->sess, myds, myds->sess->thread_session_id, rb); - while (rb == 16384) { + while (rb > 0) { rb = myds->read_from_net(); if (rb > 0 && myds->myds_type == MYDS_FRONTEND) { status_variables.stvar[st_var_queries_frontends_bytes_recv] += rb; diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 54f8644a9b..238f188308 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -5466,11 +5466,11 @@ void *child_mysql(void *arg) { // PMC-10004 // we probably should use SSL_pending() and/or SSL_has_pending() to determine // if there is more data to be read, but it doesn't seem to be working. - // Therefore we hardcored the values 4096 (4K) as a special case and - // we try to call read_from_net() again. + // Therefore we try to call read_from_net() again as long as there is data. // Previously we hardcoded 16KB but it seems that it can return in smaller // chunks of 4KB. - while (rb > 0 && rb%4096 == 0) { + // We finally removed the chunk size as it seems that any size is possible. + while (rb > 0) { rb = myds->read_from_net(); if (myds->net_failure) goto __exit_child_mysql; myds->read_pkts(); diff --git a/src/SQLite3_Server.cpp b/src/SQLite3_Server.cpp index 3c04a3f742..34fd09e727 100644 --- a/src/SQLite3_Server.cpp +++ b/src/SQLite3_Server.cpp @@ -944,11 +944,11 @@ static void *child_mysql(void *arg) { // PMC-10004 // we probably should use SSL_pending() and/or SSL_has_pending() to determine // if there is more data to be read, but it doesn't seem to be working. - // Therefore we hardcored the values 4096 (4K) as a special case and - // we try to call read_from_net() again. + // Therefore we try to call read_from_net() again as long as there is data. // Previously we hardcoded 16KB but it seems that it can return in smaller // chunks of 4KB. - while (rb > 0 && rb%4096 == 0) { + // We finally removed the chunk size as it seems that any size is possible. + while (rb > 0) { rb = myds->read_from_net(); if (myds->net_failure) goto __exit_child_mysql; myds->read_pkts(); From 79764d039772639711cafdc4efe63dae097dcc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 18 Jan 2023 08:50:25 +0000 Subject: [PATCH 3/3] Adding some cleanup after ssl_fast_forward tests --- test/tap/tests/test_ssl_fast_forward-1-t.cpp | 9 +++++++++ test/tap/tests/test_ssl_fast_forward-2-t.cpp | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/test/tap/tests/test_ssl_fast_forward-1-t.cpp b/test/tap/tests/test_ssl_fast_forward-1-t.cpp index 9cdb7dfa82..b075ef632f 100644 --- a/test/tap/tests/test_ssl_fast_forward-1-t.cpp +++ b/test/tap/tests/test_ssl_fast_forward-1-t.cpp @@ -66,6 +66,11 @@ std::vector queries_SQL2 = { "INSERT INTO tbl1459 SELECT NULL , i1 + id, i2 + id FROM tbl1459", }; +std::vector queries_SQL4 = { + "DROP TABLE IF EXISTS tbl1459", + "VACUUM", +}; + std::vector queries_limits = { 1, 10, 20, 27, 103, 169, 320, 450, 512, 619, 915, 1022, 1033, 1145, 1516, 1920, 2034, 5014, 9932, 10111, @@ -255,6 +260,10 @@ int main(int argc, char** argv) { + // clean up + if (run_queries_sets(queries_SQL4, mysqls[0], "Running on SQLite3")) + return exit_status(); + for (int i=0; i<5; i++) { diag("Connection %d has thread_id: %lu", i, mysqls[i]->thread_id); diff --git a/test/tap/tests/test_ssl_fast_forward-2-t.cpp b/test/tap/tests/test_ssl_fast_forward-2-t.cpp index 0ed6038949..dd5b0b9a3b 100644 --- a/test/tap/tests/test_ssl_fast_forward-2-t.cpp +++ b/test/tap/tests/test_ssl_fast_forward-2-t.cpp @@ -55,6 +55,11 @@ std::vector queries_SQL3 = { "CREATE TABLE tbl1459v (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , t1 VARCHAR)", }; +std::vector queries_SQL4 = { + "DROP TABLE IF EXISTS tbl1459v", + "VACUUM", +}; + int run_queries_sets(std::vector& queries, MYSQL *my, const std::string& message_prefix) { for (std::vector::iterator it = queries.begin(); it != queries.end(); it++) { @@ -246,6 +251,9 @@ int main(int argc, char** argv) { } } } + // clean up + if (run_queries_sets(queries_SQL4, mysqls[0], "Running on SQLite3")) + return exit_status(); mysql_close(mysqladmin);