From bdc961acc7ae9d5a3661ac425e936cd03dc5ccbb Mon Sep 17 00:00:00 2001 From: Sachin Date: Wed, 10 Jul 2019 11:51:43 +0530 Subject: [PATCH 1/7] MDEV-17588 replicate-do filters cause errors when creating filtered-out tables on master with syntax unsupported on slave Add only test case for MDEV , because MDEV-19653 already fixed the issue. --- mysql-test/suite/rpl/r/mdev_17588.result | 32 +++++++++++++++++ mysql-test/suite/rpl/t/mdev_17588-slave.opt | 1 + mysql-test/suite/rpl/t/mdev_17588.test | 39 +++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 mysql-test/suite/rpl/r/mdev_17588.result create mode 100644 mysql-test/suite/rpl/t/mdev_17588-slave.opt create mode 100644 mysql-test/suite/rpl/t/mdev_17588.test diff --git a/mysql-test/suite/rpl/r/mdev_17588.result b/mysql-test/suite/rpl/r/mdev_17588.result new file mode 100644 index 00000000000..fea28a311b4 --- /dev/null +++ b/mysql-test/suite/rpl/r/mdev_17588.result @@ -0,0 +1,32 @@ +include/master-slave.inc +[connection master] +create table t1 (a int) engine=innodb; +create table t2 (a int); +create table t3 (a int) engine=innodb; +include/save_master_gtid.inc +include/wait_for_slave_sql_error.inc [errno=1286] +Last_Error = 'Error 'Unknown storage engine 'innodb'' on query. Default database: 'test'. Query: 'create table t1 (a int) engine=innodb'' +STOP SLAVE IO_THREAD; +include/wait_for_slave_to_stop.inc +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; +include/start_slave.inc +include/sync_with_master_gtid.inc +show tables; +Tables_in_test +t2 +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +show create table t1; +ERROR 42S02: Table 'test.t1' doesn't exist +show create table t3; +ERROR 42S02: Table 'test.t3' doesn't exist +drop table if exists t1; +drop table if exists t2; +drop table if exists t3; +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +CALL mtr.add_suppression('Slave: Unknown storage engine .* Error_code: 1286'); +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/mdev_17588-slave.opt b/mysql-test/suite/rpl/t/mdev_17588-slave.opt new file mode 100644 index 00000000000..d73dbeca51a --- /dev/null +++ b/mysql-test/suite/rpl/t/mdev_17588-slave.opt @@ -0,0 +1 @@ +--loose-disable-innodb --replicate-ignore-table=test.t3 diff --git a/mysql-test/suite/rpl/t/mdev_17588.test b/mysql-test/suite/rpl/t/mdev_17588.test new file mode 100644 index 00000000000..e9a340cbd25 --- /dev/null +++ b/mysql-test/suite/rpl/t/mdev_17588.test @@ -0,0 +1,39 @@ +--source include/master-slave.inc +--source include/have_innodb.inc + +--connection master +create table t1 (a int) engine=innodb; +create table t2 (a int); +create table t3 (a int) engine=innodb; +--source include/save_master_gtid.inc + +--connection slave +# Using ER_UNKNOWN_STORAGE_ENGINE wont work +let $slave_sql_errno= 1286; +--source include/wait_for_slave_sql_error.inc +--let $status_items= Last_Error +--source include/show_slave_status.inc +STOP SLAVE IO_THREAD; +source include/wait_for_slave_to_stop.inc; +SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; +--source include/start_slave.inc +--source include/sync_with_master_gtid.inc +show tables; +show create table t2; +--error ER_NO_SUCH_TABLE +show create table t1; +--error ER_NO_SUCH_TABLE +show create table t3; + +--connection master +drop table if exists t1; +drop table if exists t2; +drop table if exists t3; +--source include/save_master_gtid.inc + +--connection slave +--source include/sync_with_master_gtid.inc + + +CALL mtr.add_suppression('Slave: Unknown storage engine .* Error_code: 1286'); +--source include/rpl_end.inc From 5d04391f58b404760c5254c8722c2da732ce2630 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 5 Jul 2019 08:37:44 +0200 Subject: [PATCH 2/7] MDEV-19726 MariaDB server or backup RPM install assumes mysql user exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also get rid of chown: cannot access ‘/var/lib/mysql’: No such file or directory before someone reports a bug that MariaDB server or backup RPM install assumes mysql datadir exists followup for bee24fe1818 --- support-files/rpm/server-postin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/rpm/server-postin.sh b/support-files/rpm/server-postin.sh index 0a5bac73f0b..deb27c98ac1 100644 --- a/support-files/rpm/server-postin.sh +++ b/support-files/rpm/server-postin.sh @@ -50,7 +50,7 @@ if [ $1 = 1 ] ; then # Change permissions so that the user that will run the MySQL daemon # owns all database files. - chown -R %{mysqld_user}:%{mysqld_group} $datadir + chown -R -f %{mysqld_user}:%{mysqld_group} $datadir if [ ! -e $datadir/mysql ]; then # Create data directory From a43edf73f38bb7ce6f20f7dd25240296108ae2d0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 8 Jul 2019 12:08:00 +0200 Subject: [PATCH 3/7] restore RESTRICT_SYMBOL_EXPORTS(zlib) that was lost in c54271723c6 remove zlib/libxml2 workaround in CONNECT --- storage/connect/CMakeLists.txt | 9 --------- zlib/CMakeLists.txt | 5 ++--- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 1d98d321486..0493e05a810 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -114,7 +114,6 @@ IF(CONNECT_WITH_LIBXML2) FIND_PACKAGE(LibXml2) IF (LIBXML2_FOUND) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) - SET(ZLIB_LIBRARY "z") # see ZLIB_INCLUDE_DIR below SET(XML_LIBRARY ${LIBXML2_LIBRARIES}) SET(CONNECT_SOURCES ${CONNECT_SOURCES} libdoc.cpp libdoc.h) add_definitions(-DLIBXML2_SUPPORT) @@ -333,14 +332,6 @@ IF(NOT TARGET connect) RETURN() ENDIF() -# Don't link with bundled zlib and systel libxml2 at the same time. -# System libxml2 uses system zlib, might conflict with the bundled one. -IF (XML_LIBRARY AND BUILD_BUNDLED_ZLIB) - GET_PROPERTY(INCS TARGET connect PROPERTY INCLUDE_DIRECTORIES) - LIST(REMOVE_ITEM INCS ${ZLIB_INCLUDE_DIR}) - SET_PROPERTY(TARGET connect PROPERTY INCLUDE_DIRECTORIES ${INCS}) -ENDIF() - IF(WIN32) IF (libmongoc-1.0_FOUND) SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt index 5d58f9a42b6..f654f98bfc4 100644 --- a/zlib/CMakeLists.txt +++ b/zlib/CMakeLists.txt @@ -124,6 +124,8 @@ string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" ADD_CONVENIENCE_LIBRARY(zlib STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +RESTRICT_SYMBOL_EXPORTS(zlib) + if(NOT CYGWIN) # This property causes shared libraries on Linux to have the full version @@ -142,7 +144,4 @@ if(CMAKE_SYSTEM_NAME MATCHES "SunOS") elseif(UNIX) # On unix-like platforms the library is almost always called libz set_target_properties(zlib PROPERTIES OUTPUT_NAME z) - if(NOT APPLE) - set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") - endif() endif() From d91dd2878acdc18cda0460354341617b31f0282a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 8 Jul 2019 18:15:47 +0200 Subject: [PATCH 4/7] MDEV-9409 workaround --- mysql-test/r/mysqld--help.result | 2 +- mysql-test/t/mysqld--help.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index db957e4c9ca..68aa84b6d18 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -1,4 +1,4 @@ -Windows bug: happens when a new line is exactly at the right offset. +Windows bug: new line disappears when it is exactly at the right offset. The following options may be given as the first argument: --print-defaults Print the program argument list and exit. --no-defaults Don't read default options from any option file. diff --git a/mysql-test/t/mysqld--help.test b/mysql-test/t/mysqld--help.test index 8b4674c140c..8924d2c45da 100644 --- a/mysql-test/t/mysqld--help.test +++ b/mysql-test/t/mysqld--help.test @@ -42,7 +42,7 @@ perl; $re2=join('|', @plugins); $skip=0; open(F, '<', "$ENV{MYSQL_TMP_DIR}/mysqld--help.txt") or die; - print "Windows bug: happens when a new line is exactly at the right offset.\n"; + print "Windows bug: new line disappears when it is exactly at the right offset.\n"; while () { next if 1../The following groups are read/; # formatting, skip line consisting entirely of dashes and blanks From e52fea3fe945b168bb25a0d33b2ca78092737d77 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Thu, 11 Jul 2019 02:55:04 -0700 Subject: [PATCH 5/7] Fix typo open_table_def() --- sql/table.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/table.cc b/sql/table.cc index 91b321930ab..94cd174ffd7 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -540,14 +540,14 @@ inline bool is_system_table_name(const char *name, uint length) SYNOPSIS open_table_def() - thd Thread handler + thd Thread handler share Fill this with table definition - db_flags Bit mask of the following flags: OPEN_VIEW + flags Bit mask of the following flags: OPEN_VIEW NOTES This function is called when the table definition is not cached in table definition cache - The data is returned in 'share', which is alloced by + The data is returned in 'share', which is allocated by alloc_table_share().. The code assumes that share is initialized. */ From aba2b41e9ed3a309bdbe8a1efe0f27c5b71cae8d Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 11 Jul 2019 18:24:27 +0530 Subject: [PATCH 6/7] MDEV-19978 Page read from tablespace is corrupted Problem: ======= Checksum fields can have value as zero. In that case, InnoDB falsely consider that page should be all zeroes. It leads to wrong detection of page corruption. Solution: ======== Remove the condition that checks if checksum fields are zero then page should be all zeroes. --- storage/innobase/buf/buf0buf.cc | 36 ++++++++++++++++----------------- storage/xtradb/buf/buf0buf.cc | 29 +++++++++++++------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 50a3c8b8b2d..73c757569ad 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -951,26 +951,26 @@ buf_page_is_corrupted( the first page of each file of the system tablespace. Ignore it for the system tablespace. */ if (!checksum_field1 && !checksum_field2) { - ulint i = 0; - do { - if (read_buf[i]) { - return true; - } - } while (++i < FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - + /* Checksum fields can have valid value as zero. + If the page is not empty then do the checksum + calculation for the page. */ + bool all_zeroes = true; + for (size_t i = 0; i < srv_page_size; i++) { #ifndef UNIV_INNOCHECKSUM - if (!space || !space->id) { - /* Skip FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION - in the system tablespace. */ - i += 8; - } -#endif - do { - if (read_buf[i]) { - return true; + if (i == FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + && (!space || !space->id)) { + i += 8; } - } while (++i < srv_page_size); - return false; +#endif + if (read_buf[i]) { + all_zeroes = false; + break; + } + } + + if (all_zeroes) { + return false; + } } switch (curr_algo) { diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 80fe62decc3..3326f734e45 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -950,24 +950,25 @@ buf_page_is_corrupted( the first page of each file of the system tablespace. Ignore it for the system tablespace. */ if (!checksum_field1 && !checksum_field2) { - ulint i = 0; - do { - if (read_buf[i]) { - return true; + /* Checksum fields can have valid value as zero. + If the page is not empty then do the checksum + calculation for the page. */ + bool all_zeroes = true; + for (size_t i = 0; i < srv_page_size; i++) { + if (i == FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + && (!space || space->id)) { + i += 8; } - } while (++i < FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - if (!space || !space->id) { - /* Skip FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION - in the system tablespace. */ - i += 8; - } - do { if (read_buf[i]) { - return true; + all_zeroes = false; + break; } - } while (++i < srv_page_size); - return false; + } + + if (all_zeroes) { + return false; + } } switch (curr_algo) { From 10ebdb7f1d7a3f6aa6a91b40a9d90f482da08e58 Mon Sep 17 00:00:00 2001 From: Sujatha Date: Mon, 15 Jul 2019 13:30:10 +0530 Subject: [PATCH 7/7] MDEV-11154: Write_on_release_cache(log_event.cc) function will not write "COMMIT", if use "mysqlbinlog ... | mysql ..." Problem: ======= Executing command, "mysqlbinlog --read-from-remote-server --host='xx.xx.xx.xx' --port=3306 --user=xxx --password=xxx --database=mysql --to-last-log mysql-bin.000001 --start-position=1098699 --stop-never |mysql -uxxx -pxxx", we found that last data read from remote couldn't commit. Analysis: ======== The purpose of 'Write_on_release_cache' is that the contents of the Cache will automatically be written to a dedicated result file on destruction. Flush operation on the result file is controlled by a flag 'FLUSH_F'. Events which require force flush upon their destruction will have to enable this 'Write_on_release_cache::FLUSH_F'. At present the 'FLUSH_F' flag is defined as an enum as shown below. enum flag { FLUSH_F }; Since 'FLUSH_F' is the first member without initialization it get the default value '0'. Because of this the following flush condition never succeeds. if (m_flags & FLUSH_F) fflush(m_file); At present the file gets flushed only during my_fclose(result_file) operation. When continuous streaming is enabled through --stop-never option it never gets flushed and hence events are not replicated. Fix: === Initialize the enum value to non zero value. --- .../r/binlog_mysqlbinlog_stop_never.result | 16 +++++ .../t/binlog_mysqlbinlog_stop_never.test | 66 +++++++++++++++++++ sql/log_event.cc | 2 +- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/binlog/r/binlog_mysqlbinlog_stop_never.result create mode 100644 mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_stop_never.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_stop_never.result new file mode 100644 index 00000000000..e94f17b9489 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_stop_never.result @@ -0,0 +1,16 @@ +RESET MASTER; +include/stop_dump_threads.inc +# Step-1: Execute some dummy statements. +CREATE TABLE t1(i int); +INSERT INTO t1 values (1); +# Step-2: Disable binary log temporarily and drop the table 't1'. +set @@SESSION.SQL_LOG_BIN = 0; +DROP TABLE t1; +set @@SESSION.SQL_LOG_BIN = 1; +# Step-3: Execute MYSQL_BINLOG with --stop-never and source it to mysql client. +# Step-4: Wait till dump thread transfer is completed. +# Step-5: Check that the data is there. +# Step-6: Cleanup +# kill the dump thread serving the mysqlbinlog --stop-never process +include/stop_dump_threads.inc +DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test new file mode 100644 index 00000000000..d73e453ce96 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_stop_never.test @@ -0,0 +1,66 @@ +# ==== Purpose ==== +# +# Test verifies that continuous streaming of binary log content using the +# "mysqlbinlog --stop-never" option and sourcing it to mysql client works +# fine. +# +# ==== Implementation ==== +# +# Steps: +# 1 - Create a table on a server on which binary log is enabled and insert +# a row. +# 2 - Disable the binary log on the server and drop the table. +# 3 - Capture the binary log output using "mysqlbinlog --stop_never" option +# and source it to mysql client. +# 4 - Query the PROCESSLIST table to ensure that the dump thread which is +# serving "stop_never" option has read entire binlog. +# 5 - Verify that the table is populated on the server. +# 6 - Cleanup. +# +# ==== References ==== +# +# MDEV-11154: Write_on_release_cache(log_event.cc) function will not write +# "COMMIT", if use "mysqlbinlog ... | mysql ..." + +--source include/not_windows.inc + +# Test is not specific to any binlog format. Hence Running only for 'row'. +--source include/have_binlog_format_row.inc + +# binlog file name is needed in the test. To use master-bin.000001, +# RESET MASTER is needed. +RESET MASTER; +# kill the dump threads if there any dump threads (may be from previous test) +--source include/stop_dump_threads.inc + +--echo # Step-1: Execute some dummy statements. +CREATE TABLE t1(i int); +INSERT INTO t1 values (1); + +--echo # Step-2: Disable binary log temporarily and drop the table 't1'. +set @@SESSION.SQL_LOG_BIN = 0; +DROP TABLE t1; +set @@SESSION.SQL_LOG_BIN = 1; + +--echo # Step-3: Execute MYSQL_BINLOG with --stop-never and source it to mysql client. +--write_file $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh +(`$MYSQL_BINLOG --read-from-remote-server --stop-never --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 | $MYSQL --user=root --protocol=tcp --host=127.0.0.1 --port=$MASTER_MYPORT`) < /dev/null > /dev/null 2>&1 & +EOF +--exec /bin/bash $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh + +--echo # Step-4: Wait till dump thread transfer is completed. +let $wait_condition= SELECT id from information_schema.processlist where processlist.command like '%Binlog%' and state like '%Master has sent%'; +--source include/wait_condition.inc + +--echo # Step-5: Check that the data is there. +let $count= 1; +let $table= test.t1; +source include/wait_until_rows_count.inc; + +--echo # Step-6: Cleanup +--echo # kill the dump thread serving the mysqlbinlog --stop-never process +--source include/stop_dump_threads.inc + +DROP TABLE t1; +--remove_file $MYSQL_TMP_DIR/mysqlbinlog_stop_never.sh + diff --git a/sql/log_event.cc b/sql/log_event.cc index 61748799a54..65f29441e1a 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -296,7 +296,7 @@ class Write_on_release_cache public: enum flag { - FLUSH_F + FLUSH_F= 1 }; typedef unsigned short flag_set;