From 5045509b724cbfe0311366fd2bbc36c7753e0852 Mon Sep 17 00:00:00 2001 From: Nayuta Yanagisawa Date: Thu, 23 Dec 2021 21:07:28 +0900 Subject: [PATCH 1/2] MDEV-27184 Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed, Assertion `str.alloced_length() >= str.length() + data_len' failed Spider crashes on a query that inserts some rows including float. This is because Spider allocates a string of insufficient length. --- .../spider/bugfix/r/mdev_27184.result | 21 +++++++++++++ .../mysql-test/spider/bugfix/t/mdev_27184.cnf | 2 ++ .../spider/bugfix/t/mdev_27184.test | 31 +++++++++++++++++++ storage/spider/spd_db_mysql.cc | 2 +- 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_27184.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_27184.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_27184.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_27184.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_27184.result new file mode 100644 index 00000000000..8a3d9da1dc4 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_27184.result @@ -0,0 +1,21 @@ +# +# MDEV-27184 Assertion `(old_top == initial_top (av) && old_size == 0) || +# ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && +# ((unsigned long) old_end & (pagesize - 1)) == 0)' failed, +# Assertion `str.alloced_length() >= str.length() + data_len' failed +# +for master_1 +for child2 +for child3 +connection master_1; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +CREATE TABLE tbl_a (a FLOAT) ENGINE=SPIDER; +INSERT INTO tbl_a VALUES +(0xF5A7),(0xF5A8),(0xF5A9),(0xF5AA),(0xF5AB),(0xF5AC),(0xF5AD),(0xF5AE), +(0xF5A7),(0xF5A8),(0xF5A9),(0xF5AA),(0xF5AB),(0xF5AC),(0xF5AD),(0xF5AE); +ERROR HY000: Unable to connect to foreign data source: localhost +DROP DATABASE auto_test_remote; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_27184.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_27184.cnf new file mode 100644 index 00000000000..b0853e32654 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_27184.cnf @@ -0,0 +1,2 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_27184.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_27184.test new file mode 100644 index 00000000000..9d3922b2c48 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_27184.test @@ -0,0 +1,31 @@ +--echo # +--echo # MDEV-27184 Assertion `(old_top == initial_top (av) && old_size == 0) || +--echo # ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && +--echo # ((unsigned long) old_end & (pagesize - 1)) == 0)' failed, +--echo # Assertion `str.alloced_length() >= str.length() + data_len' failed +--echo # + +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +--connection master_1 +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +CREATE TABLE tbl_a (a FLOAT) ENGINE=SPIDER; + +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +INSERT INTO tbl_a VALUES + (0xF5A7),(0xF5A8),(0xF5A9),(0xF5AA),(0xF5AB),(0xF5AC),(0xF5AD),(0xF5AE), + (0xF5A7),(0xF5A8),(0xF5A9),(0xF5AA),(0xF5AB),(0xF5AC),(0xF5AD),(0xF5AE); + +DROP DATABASE auto_test_remote; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index ee3c25d914c..3425a97049f 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -4243,7 +4243,7 @@ int spider_db_mariadb_util::append_column_value( } else if (float_value) { if (str->reserve(SPIDER_SQL_CAST_LEN + ptr->length() + - SPIDER_SQL_AS_FLOAT_LEN, SPIDER_SQL_CLOSE_PAREN_LEN)) + SPIDER_SQL_AS_FLOAT_LEN + SPIDER_SQL_CLOSE_PAREN_LEN)) { DBUG_RETURN(HA_ERR_OUT_OF_MEM); } From a48d2ec866751e9da76066bf3a30f99da9031ab0 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 28 Dec 2021 16:37:14 +0200 Subject: [PATCH 2/2] Add --valgrind to VERSION() string for valgrind builds Fixes main.sp-no-valgrind for valgrind builds not done with BUILD scripts --- sql/mysqld.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index af68d28dd9f..310dcada671 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -9038,10 +9038,12 @@ void set_server_version(char *buf, size_t size) { bool is_log= opt_log || global_system_variables.sql_log_slow || opt_bin_log; bool is_debug= IF_DBUG(!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug"), 0); + bool is_valgrind= IF_VALGRIND(!strstr(MYSQL_SERVER_SUFFIX_STR, "-valgrind"), 0); strxnmov(buf, size - 1, MYSQL_SERVER_VERSION, MYSQL_SERVER_SUFFIX_STR, IF_EMBEDDED("-embedded", ""), + is_valgrind ? "-valgrind" : "", is_debug ? "-debug" : "", is_log ? "-log" : "", NullS);