From ffb7f8854a1e65bda8af63a4533a71986f8eb5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Wed, 2 Mar 2022 19:46:07 -0800 Subject: [PATCH 01/12] Fix failing Gitlab-CI by adding pcre2-devel as a build dependency The commits a73acf6c068a39d0bb9437e05b0b60a87e46bba8 and 4d74bac8bc8c14c2b217391b3b8860f3dc701202 updated the PCRE library to a new version, which in turn requires CMake 3.0. That does not exist in CentOS 7 nor 8, so builds started failing. Actually the build should not be downloading anything at all. The root cause was that pcre2-devel was missing from the dependencies. This was originally not detected, as the download fallback had masked the issue. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cd22fc5dd8c..507dfd900e1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -177,7 +177,7 @@ centos8: GIT_STRATEGY: fetch GIT_SUBMODULE_STRATEGY: normal script: - - yum install -y yum-utils rpm-build openssl-devel + - yum install -y yum-utils rpm-build openssl-devel pcre2-devel - yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm # dnf --enablerepo=powertools install Judy-devel #--> not found - dnf config-manager --set-enabled powertools @@ -226,7 +226,7 @@ centos7: # This repository does not have any .spec files, so install dependencies based on Fedora spec file - yum-builddep -y mariadb-server # ..with a few extra ones, as CentOS 7 is very old and these are added in newer MariaDB releases - - yum install -y yum-utils rpm-build gcc gcc-c++ bison libxml2-devel libevent-devel openssl-devel + - yum install -y yum-utils rpm-build gcc gcc-c++ bison libxml2-devel libevent-devel openssl-devel pcre2-devel - mkdir builddir; cd builddir - cmake -DRPM=$CI_JOB_NAME $CMAKE_FLAGS .. 2>&1 | tee -a ../build-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG.log - make package -j 2 2>&1 | tee -a ../build-$CI_JOB_NAME-$CI_COMMIT_REF_SLUG.log From c61249eef1a279dddc7a80631e73ebae295208a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sun, 6 Mar 2022 15:43:27 -0800 Subject: [PATCH 02/12] Fix failing Gitlab-CI by fixing CentOS 8 repo urls --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 507dfd900e1..6db89cd332f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -172,7 +172,7 @@ fedora-clang: centos8: stage: build - image: centos:8 + image: quay.io/centos/centos:stream8 # CentOS 8 is deprecated, use this Stream8 instead variables: GIT_STRATEGY: fetch GIT_SUBMODULE_STRATEGY: normal @@ -186,7 +186,7 @@ centos8: # - package Judy-devel-1.0.5-18.module_el8.3.0+757+d382997d.i686 is filtered out by modular filtering # - package Judy-devel-1.0.5-18.module_el8.3.0+757+d382997d.x86_64 is filtered out by modular filtering # Solution: install Judy-devel directly from downloaded rpm file: - - yum install -y http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/Judy-devel-1.0.5-18.module_el8.3.0+757+d382997d.x86_64.rpm + - yum install -y http://vault.centos.org/centos/8/PowerTools/x86_64/os/Packages/Judy-devel-1.0.5-18.module_el8.3.0+757+d382997d.x86_64.rpm # Use eatmydata to speed up build - yum install -y https://github.com/stewartsmith/libeatmydata/releases/download/v129/libeatmydata-129-1.fc33.x86_64.rpm - yum install -y ccache # From EPEL From e8fc62b9d7545b3762a67d0b1be325827d027cac Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 2 Mar 2022 11:48:24 +1100 Subject: [PATCH 03/12] MDEV-27936 hardware lock elision on ppc64{,le} failing to compile There is only a very small range of gcc compiler versions that allow the built_{htm} functions to be defined without -mhtm being specified as a global C{,XX}FLAGS. Because the design is centered around enable HTM only in the functional blocks that use it, this breaks on the inclusion of the htmxlintrin.h header that includes this. As a partial mitigation, extented to GNU/clang compilers, transaction functions gain the attribute "hot". In general the use of htm is around the optimistic transaction ability of the function. The key part of using the hot attribute is to place these functions together so that a maximization of icache, tlb and OS paging can ensure that these can be ready to execute by any thread/cpu with the minimum amount of overhead. POWER is particularly affected here because the xbegin/xend functions are not inline. srw_lock.cc requires the -mhtm cflag, both in the storage engine and the unit tests. --- storage/innobase/CMakeLists.txt | 10 +++++++ .../include/transactional_lock_guard.h | 28 +++++++++---------- storage/innobase/sync/srw_lock.cc | 17 ++++++++++- storage/innobase/unittest/CMakeLists.txt | 6 ++++ 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 702bb843729..acfe91ab8a6 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -380,6 +380,16 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" COMPILE_FLAGS "-O0" ) ENDIF() + +# Older gcc version insist on -mhtm flag for including the +# htmxlintrin.h header. This is also true for new gcc versions +# like 11.2.0 in Debian Sid +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64") + ADD_COMPILE_FLAGS( + sync/srw_lock.cc + COMPILE_FLAGS "-mhtm" + ) +ENDIF() IF(MSVC) IF(CMAKE_SIZEOF_VOID_P EQUAL 8) ADD_COMPILE_FLAGS( diff --git a/storage/innobase/include/transactional_lock_guard.h b/storage/innobase/include/transactional_lock_guard.h index 3167055630c..54ac055430e 100644 --- a/storage/innobase/include/transactional_lock_guard.h +++ b/storage/innobase/include/transactional_lock_guard.h @@ -45,8 +45,8 @@ bool transactional_lock_enabled(); # include # if defined __GNUC__ && !defined __INTEL_COMPILER -# define TRANSACTIONAL_TARGET __attribute__((target("rtm"))) -# define TRANSACTIONAL_INLINE __attribute__((target("rtm"),always_inline)) +# define TRANSACTIONAL_TARGET __attribute__((target("rtm"),hot)) +# define TRANSACTIONAL_INLINE __attribute__((target("rtm"),hot,always_inline)) # else # define TRANSACTIONAL_TARGET /* nothing */ # define TRANSACTIONAL_INLINE /* nothing */ @@ -70,25 +70,25 @@ TRANSACTIONAL_INLINE static inline void xabort() { _xabort(0); } TRANSACTIONAL_INLINE static inline void xend() { _xend(); } # elif defined __powerpc64__ -# include extern bool have_transactional_memory; bool transactional_lock_enabled(); -# define TRANSACTIONAL_TARGET __attribute__((target("htm"))) -# define TRANSACTIONAL_INLINE __attribute__((target("htm"),always_inline)) - -TRANSACTIONAL_INLINE static inline bool xbegin() -{ - return have_transactional_memory && - __TM_simple_begin() == _HTM_TBEGIN_STARTED; -} +# define TRANSACTIONAL_TARGET __attribute__((hot)) +# define TRANSACTIONAL_INLINE __attribute__((hot,always_inline)) +/** + Newer gcc compilers only provide __builtin_{htm} + function when the -mhtm is actually provided. So + we've got the option of including it globally, or + pushing down to one file with that enabled and removing + the inline optimization. + */ +TRANSACTIONAL_TARGET bool xbegin(); +TRANSACTIONAL_TARGET void xabort(); +TRANSACTIONAL_TARGET void xend(); # ifdef UNIV_DEBUG bool xtest(); # endif -TRANSACTIONAL_INLINE static inline void xabort() { __TM_abort(); } - -TRANSACTIONAL_INLINE static inline void xend() { __TM_end(); } # endif #endif diff --git a/storage/innobase/sync/srw_lock.cc b/storage/innobase/sync/srw_lock.cc index f406b04712a..bedbfee7b1d 100644 --- a/storage/innobase/sync/srw_lock.cc +++ b/storage/innobase/sync/srw_lock.cc @@ -55,6 +55,20 @@ TRANSACTIONAL_TARGET bool xtest() { return have_transactional_memory && _xtest(); } # endif #elif defined __powerpc64__ +# include + +__attribute__((target("htm"),hot)) +bool xbegin() +{ + return have_transactional_memory && + __TM_simple_begin() == _HTM_TBEGIN_STARTED; +} + +__attribute__((target("htm"),hot)) +void xabort() { __TM_abort(); } + +__attribute__((target("htm"),hot)) +void xend() { __TM_end(); } # ifdef __linux__ # include @@ -79,7 +93,8 @@ bool transactional_lock_enabled() } # ifdef UNIV_DEBUG -TRANSACTIONAL_TARGET bool xtest() +__attribute__((target("htm"),hot)) +bool xtest() { return have_transactional_memory && _HTM_STATE (__builtin_ttest ()) == _HTM_TRANSACTIONAL; diff --git a/storage/innobase/unittest/CMakeLists.txt b/storage/innobase/unittest/CMakeLists.txt index 1ab6157b4a9..dfd972b6f45 100644 --- a/storage/innobase/unittest/CMakeLists.txt +++ b/storage/innobase/unittest/CMakeLists.txt @@ -21,6 +21,12 @@ ADD_EXECUTABLE(innodb_fts-t innodb_fts-t.cc) TARGET_LINK_LIBRARIES(innodb_fts-t mysys mytap) ADD_DEPENDENCIES(innodb_fts-t GenError) MY_ADD_TEST(innodb_fts) +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64") + ADD_COMPILE_FLAGS( + ../sync/srw_lock.cc + COMPILE_FLAGS "-mhtm" + ) +ENDIF() ADD_EXECUTABLE(innodb_sync-t innodb_sync-t.cc ../sync/srw_lock.cc) TARGET_LINK_LIBRARIES(innodb_sync-t mysys mytap) ADD_DEPENDENCIES(innodb_sync-t GenError) From 8ea08505a159566848a8dd267d152cb74645d903 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 8 Mar 2022 09:35:03 +1100 Subject: [PATCH 04/12] MDEV-28022: Debian stretch has zstd too old zstd-1.1.3 is needed however stretch has only 1.1.2. Move to distro version based checks as checks against the apt-cache are unreliable if there is no cache. --- debian/autobake-deb.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index ae9b77a382b..c0153f0d805 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -42,6 +42,14 @@ GCCVERSION=$(gcc -dumpfullversion -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g # Debian policy and targeting Debian Sid. Then case-by-case run in autobake-deb.sh # tests for backwards compatibility and strip away parts on older builders. +CODENAME="$(lsb_release -sc)" +case "${CODENAME}" in + stretch) + # MDEV-28022 libzstd-dev-1.1.3 minimum version + sed -i -e '/libzstd-dev/d' debian/control + ;; +esac + # If libcrack2 (>= 2.9.0) is not available (before Debian Jessie and Ubuntu Trusty) # clean away the cracklib stanzas so the package can build without them. if ! apt-cache madison libcrack2-dev | grep 'libcrack2-dev *| *2\.9' >/dev/null 2>&1 @@ -72,13 +80,6 @@ then sed '/mariadb-service-convert/d' -i debian/mariadb-server-10.3.install fi -# If libzstd-dev is not available (before Debian Stretch and Ubuntu Xenial) -# remove the dependency from server and rocksdb so it can build properly -if ! apt-cache madison libzstd-dev | grep 'libzstd-dev' >/dev/null 2>&1 -then - sed '/libzstd-dev/d' -i debian/control -fi - # The binaries should be fully hardened by default. However TokuDB compilation seems to fail on # Debian Jessie and older and on Ubuntu Xenial and older with the following error message: # /usr/bin/ld.bfd.real: /tmp/ccOIwjFo.ltrans0.ltrans.o: relocation R_X86_64_PC32 against symbol @@ -139,7 +140,6 @@ source ./VERSION UPSTREAM="${MYSQL_VERSION_MAJOR}.${MYSQL_VERSION_MINOR}.${MYSQL_VERSION_PATCH}${MYSQL_VERSION_EXTRA}" PATCHLEVEL="+maria" LOGSTRING="MariaDB build" -CODENAME="$(lsb_release -sc)" EPOCH="1:" dch -b -D ${CODENAME} -v "${EPOCH}${UPSTREAM}${PATCHLEVEL}~${CODENAME}" "Automatic build with ${LOGSTRING}." From 36a19f94ce102be87b22fdc7ad147ab7d5ed4331 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 10 Mar 2022 18:47:54 +1100 Subject: [PATCH 05/12] MDEV-27936 hardware lock elision on ppc64{,le} failing to compile Cannot have a function trx_has_lock_x hot and cold. --- storage/innobase/trx/trx0rec.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 1b70fb41ff0..a78212d3359 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -1951,7 +1951,7 @@ dberr_t trx_undo_report_rename(trx_t* trx, const dict_table_t* table) return err; } -TRANSACTIONAL_TARGET ATTRIBUTE_COLD ATTRIBUTE_NOINLINE +TRANSACTIONAL_TARGET ATTRIBUTE_NOINLINE /** @return whether the transaction holds an exclusive lock on a table */ static bool trx_has_lock_x(const trx_t &trx, dict_table_t& table) { From e7cf871dda59ad39c9125288149a4ec38518d41c Mon Sep 17 00:00:00 2001 From: Andrei Date: Thu, 3 Mar 2022 17:47:54 +0200 Subject: [PATCH 06/12] MDEV-24617 OPTIMIZE on a sequence causes unexpected ER_BINLOG_UNSAFE_STATEMENT The warning out of OPTIMIZE Statement is unsafe because it uses a system function was indeed counterfactual and was resulted by checking an insufficiently strict property of lex' sql_command_flags. Fixed with deploying an additional checking of weather the current sql command that modifes a share->non_determinstic_insert table is capable of generating ROW format events. The extra check rules out the unsafety to OPTIMIZE et al, while the existing check continues to do so to CREATE TABLE (which is perculiarly tagged as ROW-event generative sql command). As a side effect sql_sequence.binlog test gets corrected and binlog_stm_unsafe_warning.test is reinforced to add up an unsafe CREATE..SELECT test. --- .../binlog/r/binlog_stm_unsafe_warning.result | 13 +++++++++- .../binlog/t/binlog_stm_unsafe_warning.test | 14 ++++++++++- mysql-test/suite/sql_sequence/binlog.result | 24 +++++++++++++++++++ mysql-test/suite/sql_sequence/binlog.test | 15 ++++++++++-- sql/sql_class.cc | 3 ++- 5 files changed, 64 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result index 135271d325e..971fae6208f 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result +++ b/mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result @@ -104,6 +104,17 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc SHOW WARNINGS; Level Code Message Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it invokes a trigger or a stored function that inserts into an AUTO_INCREMENT column. Inserted values cannot be logged correctly +CREATE TABLE t3 (a INT(11) DEFAULT NULL); +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 (a INT(11) DEFAULT NULL, b BIGINT(20) DEFAULT uuid_short()) SELECT * FROM t3; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave +SHOW WARNINGS; +Level Code Message +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave +CREATE OR REPLACE TABLE t4 (a INT(11) DEFAULT NULL) SELECT * FROM t3; +SHOW WARNINGS; +Level Code Message DROP FUNCTION sf_bug50192; DROP TRIGGER tr_bug50192; -DROP TABLE t1, t2; +DROP TABLE t1, t2, t3, t4; diff --git a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test index 70566da4cfa..578f0ff5fc8 100644 --- a/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test +++ b/mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test @@ -189,8 +189,20 @@ SHOW WARNINGS; SELECT sf_bug50192(); SHOW WARNINGS; +# The test proves MDEV-24617 fixes leave in force +# unsafe warnings in non-deterministic CREATE..SELECT cases. +# Below an inserted default value to `b` of the target table is replication +# unsafe. A warning must be out. +CREATE TABLE t3 (a INT(11) DEFAULT NULL); +INSERT INTO t3 VALUES (1); +CREATE TABLE t4 (a INT(11) DEFAULT NULL, b BIGINT(20) DEFAULT uuid_short()) SELECT * FROM t3; +SHOW WARNINGS; +# no warning out of a deterministic "rhs" of SELECT +CREATE OR REPLACE TABLE t4 (a INT(11) DEFAULT NULL) SELECT * FROM t3; +SHOW WARNINGS; + # cleanup DROP FUNCTION sf_bug50192; DROP TRIGGER tr_bug50192; -DROP TABLE t1, t2; +DROP TABLE t1, t2, t3, t4; diff --git a/mysql-test/suite/sql_sequence/binlog.result b/mysql-test/suite/sql_sequence/binlog.result index f01b3234e96..32788c988fc 100644 --- a/mysql-test/suite/sql_sequence/binlog.result +++ b/mysql-test/suite/sql_sequence/binlog.result @@ -12,6 +12,20 @@ select next value for s1, minimum_value from s1 where maximum_value> 4; next value for s1 minimum_value 4 1 alter sequence s1 maxvalue 1000; +optimize table s1; +Table Op Msg_type Msg_text +test.s1 optimize note The storage engine for the table doesn't support optimize +analyze table s1; +Table Op Msg_type Msg_text +test.s1 analyze note The storage engine for the table doesn't support analyze +repair table s1; +Table Op Msg_type Msg_text +test.s1 repair status OK +check table s1; +Table Op Msg_type Msg_text +test.s1 check note The storage engine for the table doesn't support check +rename table s1 to tmp_s; +rename table tmp_s to s1; drop sequence s1; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info @@ -30,4 +44,14 @@ master-bin.000001 # Query # # COMMIT master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; alter sequence s1 maxvalue 1000 master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; optimize table s1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; analyze table s1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; repair table s1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; rename table s1 to tmp_s +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; rename table tmp_s to s1 +master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP SEQUENCE `s1` /* generated by server */ diff --git a/mysql-test/suite/sql_sequence/binlog.test b/mysql-test/suite/sql_sequence/binlog.test index 5f2d52d7864..6a12e670a1e 100644 --- a/mysql-test/suite/sql_sequence/binlog.test +++ b/mysql-test/suite/sql_sequence/binlog.test @@ -1,5 +1,5 @@ ---source include/have_udf.inc ---source include/have_log_bin.inc +--source include/have_sequence.inc +--source include/have_binlog_format_mixed_or_row.inc --source include/binlog_start_pos.inc # @@ -21,6 +21,17 @@ select next value for s1, minimum_value from s1 where maximum_value> 4; # alter sequence s1 maxvalue 1000; +# MDEV-24617 OPTIMIZE on a sequence causes unexpected +# ER_BINLOG_UNSAFE_STATEMENT The test below verifies no unsafe +# warnings anymore for any relavant commands that like OPTIMIZE can +# not produce ROW format events therefore the unsafe warning either. +optimize table s1; +analyze table s1; +repair table s1; +check table s1; +rename table s1 to tmp_s; +rename table tmp_s to s1; + drop sequence s1; --let $binlog_file = LAST diff --git a/sql/sql_class.cc b/sql/sql_class.cc index bbc46408c04..7f5a6345770 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6210,7 +6210,8 @@ int THD::decide_logging_format(TABLE_LIST *tables) table->file->ht) multi_write_engine= TRUE; if (share->non_determinstic_insert && - !(sql_command_flags[lex->sql_command] & CF_SCHEMA_CHANGE)) + (sql_command_flags[lex->sql_command] & CF_CAN_GENERATE_ROW_EVENTS + && !(sql_command_flags[lex->sql_command] & CF_SCHEMA_CHANGE))) has_write_tables_with_unsafe_statements= true; trans= table->file->has_transactions(); From 1766a18e06a056155031dabefb88ce7f201ad921 Mon Sep 17 00:00:00 2001 From: Vlad Lesin Date: Wed, 2 Mar 2022 21:29:53 +0300 Subject: [PATCH 07/12] MDEV-19577 Replication does not work with innodb_autoinc_lock_mode=2 The first step for deprecating innodb_autoinc_lock_mode(see MDEV-27844) is: - to switch statement binlog format to ROW if binlog format is MIXED and the statement changes autoincremented fields - issue warnings if innodb_autoinc_lock_mode == 2 and binlog format is STATEMENT --- .../r/innodb_autoinc_lock_mode_binlog.result | 33 +++++++++++++++++++ .../t/innodb_autoinc_lock_mode_binlog.opt | 1 + .../t/innodb_autoinc_lock_mode_binlog.test | 21 ++++++++++++ sql/handler.h | 5 +++ sql/sql_class.cc | 9 +++++ sql/sql_lex.cc | 9 ++++- sql/sql_lex.h | 5 +++ storage/innobase/handler/ha_innodb.cc | 8 +++++ storage/innobase/handler/ha_innodb.h | 4 +++ 9 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/binlog/r/innodb_autoinc_lock_mode_binlog.result create mode 100644 mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.opt create mode 100644 mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.test diff --git a/mysql-test/suite/binlog/r/innodb_autoinc_lock_mode_binlog.result b/mysql-test/suite/binlog/r/innodb_autoinc_lock_mode_binlog.result new file mode 100644 index 00000000000..d0132931968 --- /dev/null +++ b/mysql-test/suite/binlog/r/innodb_autoinc_lock_mode_binlog.result @@ -0,0 +1,33 @@ +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); +select @@innodb_autoinc_lock_mode; +@@innodb_autoinc_lock_mode +2 +select @@binlog_format; +@@binlog_format +MIXED +create table t1 (a int not null auto_increment,b int, primary key (a)) engine=InnoDB; +insert into t1 values (NULL,1); +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `mtr`; INSERT INTO test_suppressions (pattern) VALUES ( NAME_CONST('pattern',_latin1'Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT' COLLATE 'latin1_swedish_ci')) +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t1 (a int not null auto_increment,b int, primary key (a)) engine=InnoDB +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # insert into t1 values (NULL,1) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ +set global binlog_format=STATEMENT; +connect con1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK; +insert into t1 values (NULL,1); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave +insert into t1 values (NULL,1); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave +disconnect con1; +connection default; +set global binlog_format=MIXED; +DROP TABLE t1; diff --git a/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.opt b/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.opt new file mode 100644 index 00000000000..824f656cbd5 --- /dev/null +++ b/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.opt @@ -0,0 +1 @@ +--innodb_autoinc_lock_mode=2 diff --git a/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.test b/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.test new file mode 100644 index 00000000000..a7d43db4c1b --- /dev/null +++ b/mysql-test/suite/binlog/t/innodb_autoinc_lock_mode_binlog.test @@ -0,0 +1,21 @@ +--source include/have_innodb.inc +--source include/have_binlog_format_mixed.inc + +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); + +select @@innodb_autoinc_lock_mode; +select @@binlog_format; + +create table t1 (a int not null auto_increment,b int, primary key (a)) engine=InnoDB; +insert into t1 values (NULL,1); +--source include/show_binlog_events.inc + +set global binlog_format=STATEMENT; +--connect (con1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK) +insert into t1 values (NULL,1); +insert into t1 values (NULL,1); +--disconnect con1 +--connection default + +set global binlog_format=MIXED; +DROP TABLE t1; diff --git a/sql/handler.h b/sql/handler.h index 91225982e9e..c65b7b6a8d5 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -4668,6 +4668,11 @@ public: const uchar *pack_frm_data, size_t pack_frm_len) { return HA_ERR_WRONG_COMMAND; } + /* @return true if it's necessary to switch current statement log format from + STATEMENT to ROW if binary log format is MIXED and autoincrement values + are changed in the statement */ + virtual bool autoinc_lock_mode_stmt_unsafe() const + { return false; } virtual int drop_partitions(const char *path) { return HA_ERR_WRONG_COMMAND; } virtual int rename_partitions(const char *path) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7f5a6345770..c808a2c997c 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6079,6 +6079,10 @@ int THD::decide_logging_format(TABLE_LIST *tables) bool is_write= FALSE; // If any write tables bool has_read_tables= FALSE; // If any read only tables bool has_auto_increment_write_tables= FALSE; // Write with auto-increment + /* true if it's necessary to switch current statement log format from + STATEMENT to ROW if binary log format is MIXED and autoincrement values + are changed in the statement */ + bool has_unsafe_stmt_autoinc_lock_mode= false; /* If a write table that doesn't have auto increment part first */ bool has_write_table_auto_increment_not_first_in_pk= FALSE; bool has_auto_increment_write_tables_not_first= FALSE; @@ -6200,6 +6204,8 @@ int THD::decide_logging_format(TABLE_LIST *tables) has_auto_increment_write_tables_not_first= found_first_not_own_table; if (share->next_number_keypart != 0) has_write_table_auto_increment_not_first_in_pk= true; + has_unsafe_stmt_autoinc_lock_mode= + table->file->autoinc_lock_mode_stmt_unsafe(); } } @@ -6268,6 +6274,9 @@ int THD::decide_logging_format(TABLE_LIST *tables) if (has_write_tables_with_unsafe_statements) lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); + if (has_unsafe_stmt_autoinc_lock_mode) + lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_AUTOINC_LOCK_MODE); + /* A query that modifies autoinc column in sub-statement can make the master and slave inconsistent. diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 228635915a0..d51b9bd5a26 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -75,7 +75,14 @@ Query_tables_list::binlog_stmt_unsafe_errcode[BINLOG_STMT_UNSAFE_COUNT] = ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC, ER_BINLOG_UNSAFE_UPDATE_IGNORE, ER_BINLOG_UNSAFE_INSERT_TWO_KEYS, - ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST + ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST, + /* + There is no need to add new error code as we plan to get rid of auto + increment lock mode variable, so we use existing error code below, add + the correspondent text to the existing error message during merging to + non-GA release. + */ + ER_BINLOG_UNSAFE_SYSTEM_VARIABLE }; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 69dda691e45..e1f34afa350 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1740,6 +1740,11 @@ public: */ BINLOG_STMT_UNSAFE_AUTOINC_NOT_FIRST, + /** + Autoincrement lock mode is incompatible with STATEMENT binlog format. + */ + BINLOG_STMT_UNSAFE_AUTOINC_LOCK_MODE, + /* The last element of this enumeration type. */ BINLOG_STMT_UNSAFE_COUNT }; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 33aafa00113..02ac53e22dd 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -9594,6 +9594,14 @@ ha_innobase::change_active_index( DBUG_RETURN(0); } +/* @return true if it's necessary to switch current statement log format from +STATEMENT to ROW if binary log format is MIXED and autoincrement values +are changed in the statement */ +bool ha_innobase::autoinc_lock_mode_stmt_unsafe() const +{ + return innobase_autoinc_lock_mode == AUTOINC_NO_LOCKING; +} + /***********************************************************************//** Reads the next or previous row from a cursor, which must have previously been positioned using index_read. diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 9468edcf226..9356b269fcc 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -448,6 +448,10 @@ protected: int general_fetch(uchar* buf, uint direction, uint match_mode); int change_active_index(uint keynr); + /* @return true if it's necessary to switch current statement log + format from STATEMENT to ROW if binary log format is MIXED and + autoincrement values are changed in the statement */ + bool autoinc_lock_mode_stmt_unsafe() const; dict_index_t* innobase_get_index(uint keynr); #ifdef WITH_WSREP From 77c184df7c056da7364e606ac977cc2d3cd826ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 10 Mar 2022 15:08:39 +0200 Subject: [PATCH 08/12] Explicitly specify that we use the C99 dialect --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88a0d64e6de..6a135b0f8e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright (c) 2006, 2017, Oracle and/or its affiliates. -# Copyright (c) 2008, 2021, MariaDB Corporation. +# Copyright (c) 2008, 2022, MariaDB Corporation. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -83,9 +83,11 @@ SET(MYSQL_PROJECT_NAME_DOCSTRING "MySQL project name") IF(CMAKE_VERSION VERSION_LESS "3.1") IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") ENDIF() ELSE() + SET(CMAKE_C_STANDARD 99) SET(CMAKE_CXX_STANDARD 11) ENDIF() From 06ec439b8c42b28d623c2067237453e4586894cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 10 Mar 2022 15:23:28 +0200 Subject: [PATCH 09/12] MDEV-27058 fixup: Relax a debug assertion buf_page_get_low(): Assert that the block not be read-fixed. It may be write-fixed while we only hold a shared latch on the page. Page writes are protected by U latches, which are compatible with S. In all other places where we assert that the block not be IO-fixed, we are holding U or X latch, which does prevent concurrent file I/O. --- storage/innobase/buf/buf0buf.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 7b7ab819ff9..e456389149a 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2673,7 +2673,8 @@ ignore_block: after buf_zip_decompress() in this function. */ block->page.lock.s_lock(); state = block->page.state(); - ut_ad(state < buf_page_t::READ_FIX); + ut_ad(state < buf_page_t::READ_FIX + || state >= buf_page_t::WRITE_FIX); const page_id_t id{block->page.id()}; block->page.lock.s_unlock(); From fabaac86a18cfa026ca53b4a62e9edbf0bfd32d4 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 25 Feb 2022 18:24:01 +1100 Subject: [PATCH 10/12] MDEV-27956 hardware lock ellision on s390x/ppc64{,le} Per https://gcc.gnu.org/onlinedocs/gcc/PowerPC-Hardware-Transactional-Memory-Built-in-Functions.html The .. high level HTM interface .. is common between PowerPC and S/390 Reimplemented the transactional_lock_enabled() detection mechanism for s390x and POWER based on SIGILL. This also gives non-Linux based unixes the ability to use HTM. The implementation is based off openssl. (ref: https://github.com/openssl/openssl/blob/1c0eede9827b0962f1d752fa4ab5d436fa039da4/crypto/s390xcap.c#L104) The other ppc64{,le} problems with getauxvec based detection: * Checking PPC_FEATURE2_HTM_NOSC not needed as we do not do syscalls while in a transactional state. * As we don't use, and never should use PPC_FEATURE2_HTM_NO_SUSPEND, or do syscalls while in transactional state, don't test it. From: https://www.kernel.org/doc/html/v5.4/powerpc/syscall64-abi.html#transactional-memory S390x high level __builtin_tbegin functions in the htmxlintrin.h are not inline. This header file can be included once in the entire set of sources for a linked target, otherwise duplicate symbols occur. While we could use inline xabort/xend functions using the low level interface, we keep this the same as ppc64 for simplicity. SLES-15, gcc-7, appeared to want everything that included the htmlxlintrin to be compiled with -mhtm otherwise the __builtin_t{func} where not defined (in addition to a #ifdef __HTM__ #error). Debian sid gcc-11.2 wanted the same on ppc64le/ppc64. In general we want to avoid a wide spread use of architecture cflags as it makes justifications for selective optimizations easier. (ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1006702) --- storage/innobase/CMakeLists.txt | 5 +- .../include/transactional_lock_guard.h | 19 +++++-- storage/innobase/sync/srw_lock.cc | 57 +++++++++++++------ storage/innobase/unittest/CMakeLists.txt | 3 +- 4 files changed, 58 insertions(+), 26 deletions(-) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index acfe91ab8a6..3d4f4d04ae8 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -384,7 +384,10 @@ ENDIF() # Older gcc version insist on -mhtm flag for including the # htmxlintrin.h header. This is also true for new gcc versions # like 11.2.0 in Debian Sid -IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64") +# s390x because of the way it defines the high level intrinsics +# as not-inline in the header file can only be included by one +# source file that has -mhtm enabled. +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64|s390x") ADD_COMPILE_FLAGS( sync/srw_lock.cc COMPILE_FLAGS "-mhtm" diff --git a/storage/innobase/include/transactional_lock_guard.h b/storage/innobase/include/transactional_lock_guard.h index 54ac055430e..168a68977a7 100644 --- a/storage/innobase/include/transactional_lock_guard.h +++ b/storage/innobase/include/transactional_lock_guard.h @@ -18,8 +18,8 @@ this program; if not, write to the Free Software Foundation, Inc., #pragma once -#if defined __powerpc64__ && defined __clang__ && defined __linux__ -#elif defined __powerpc64__&&defined __GNUC__&&defined __linux__&&__GNUC__ > 4 +#if defined __powerpc64__ +#elif defined __s390__ #elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) && !defined(__clang__) #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__) # if __GNUC__ >= 8 @@ -69,7 +69,7 @@ static inline bool xtest() { return have_transactional_memory && _xtest(); } TRANSACTIONAL_INLINE static inline void xabort() { _xabort(0); } TRANSACTIONAL_INLINE static inline void xend() { _xend(); } -# elif defined __powerpc64__ +# elif defined __powerpc64__ || defined __s390__ extern bool have_transactional_memory; bool transactional_lock_enabled(); # define TRANSACTIONAL_TARGET __attribute__((hot)) @@ -77,10 +77,17 @@ bool transactional_lock_enabled(); /** Newer gcc compilers only provide __builtin_{htm} - function when the -mhtm is actually provided. So + functions when the -mhtm CFLAG is actually provided. So we've got the option of including it globally, or - pushing down to one file with that enabled and removing - the inline optimization. + pushing down the inclusion of htmxlintrin.h to one + file with -mhtm enabled and removing the inline + optimization. + + Per FIXME in s390x's htmxlintrin.h, the __TM_simple_begin + isn't always_inline resulting in duplicate definitions if + it where included more than once. While xabort and xend + could be implemented here, we keep the implementation the + same as ppc64. */ TRANSACTIONAL_TARGET bool xbegin(); TRANSACTIONAL_TARGET void xabort(); diff --git a/storage/innobase/sync/srw_lock.cc b/storage/innobase/sync/srw_lock.cc index bedbfee7b1d..339b431522c 100644 --- a/storage/innobase/sync/srw_lock.cc +++ b/storage/innobase/sync/srw_lock.cc @@ -54,8 +54,10 @@ bool transactional_lock_enabled() TRANSACTIONAL_TARGET bool xtest() { return have_transactional_memory && _xtest(); } # endif -#elif defined __powerpc64__ +#elif defined __powerpc64__ || defined __s390__ # include +# include +# include __attribute__((target("htm"),hot)) bool xbegin() @@ -69,27 +71,46 @@ void xabort() { __TM_abort(); } __attribute__((target("htm"),hot)) void xend() { __TM_end(); } -# ifdef __linux__ -# include -# ifndef PPC_FEATURE2_HTM_NOSC -# define PPC_FEATURE2_HTM_NOSC 0x01000000 -# endif -# ifndef PPC_FEATURE2_HTM_NO_SUSPEND -# define PPC_FEATURE2_HTM_NO_SUSPEND 0x00080000 -# endif - -# ifndef AT_HWCAP2 -# define AT_HWCAP2 26 -# endif -# endif bool have_transactional_memory; +static sigjmp_buf ill_jmp; +static void ill_handler(int sig) +{ + siglongjmp(ill_jmp, sig); +} +/** + Here we are testing we can do a transaction without SIGILL + and a 1 instruction store can succeed. +*/ +__attribute__((noinline)) +static void test_tm(bool *r) +{ + if (__TM_simple_begin() == _HTM_TBEGIN_STARTED) + { + *r= true; + __TM_end(); + } +} bool transactional_lock_enabled() { -# ifdef __linux__ - return getauxval(AT_HWCAP2) & - (PPC_FEATURE2_HTM_NOSC | PPC_FEATURE2_HTM_NO_SUSPEND); -# endif + bool r= false; + sigset_t oset; + struct sigaction ill_act, oact_ill; + + memset(&ill_act, 0, sizeof(ill_act)); + ill_act.sa_handler = ill_handler; + sigfillset(&ill_act.sa_mask); + sigdelset(&ill_act.sa_mask, SIGILL); + + sigprocmask(SIG_SETMASK, &ill_act.sa_mask, &oset); + sigaction(SIGILL, &ill_act, &oact_ill); + if (sigsetjmp(ill_jmp, 1) == 0) + { + test_tm(&r); + } + sigaction(SIGILL, &oact_ill, NULL); + sigprocmask(SIG_SETMASK, &oset, NULL); + return r; } # ifdef UNIV_DEBUG diff --git a/storage/innobase/unittest/CMakeLists.txt b/storage/innobase/unittest/CMakeLists.txt index dfd972b6f45..7dd7c111baa 100644 --- a/storage/innobase/unittest/CMakeLists.txt +++ b/storage/innobase/unittest/CMakeLists.txt @@ -21,7 +21,8 @@ ADD_EXECUTABLE(innodb_fts-t innodb_fts-t.cc) TARGET_LINK_LIBRARIES(innodb_fts-t mysys mytap) ADD_DEPENDENCIES(innodb_fts-t GenError) MY_ADD_TEST(innodb_fts) -IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64") +# See explanation in innobase/CmakeLists.txt +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64|powerpc64|s390x") ADD_COMPILE_FLAGS( ../sync/srw_lock.cc COMPILE_FLAGS "-mhtm" From 5503c4046053a2d0b8c4cd2d331d0bfa25b50e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 11 Mar 2022 09:46:50 +0200 Subject: [PATCH 11/12] Stabilize innodb.redo_log_during_checkpoint Externally kill and restart the server, and remove the unreliable crash_after_checkpoint. --- .../innodb/r/redo_log_during_checkpoint.result | 6 ------ .../innodb/t/redo_log_during_checkpoint.test | 15 +++------------ storage/innobase/log/log0log.cc | 4 +--- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/mysql-test/suite/innodb/r/redo_log_during_checkpoint.result b/mysql-test/suite/innodb/r/redo_log_during_checkpoint.result index c7b4bb4403b..a924ff711da 100644 --- a/mysql-test/suite/innodb/r/redo_log_during_checkpoint.result +++ b/mysql-test/suite/innodb/r/redo_log_during_checkpoint.result @@ -5,10 +5,7 @@ SET GLOBAL innodb_log_checkpoint_now = 1; CREATE DATABASE very_long_database_name; USE very_long_database_name; SET debug_dbug = '+d,increase_mtr_checkpoint_size'; -SET debug_dbug = '+d,crash_after_checkpoint'; set global innodb_log_checkpoint_now = 1; -ERROR HY000: Lost connection to MySQL server during query -# Skip MLOG_FILE_NAME redo records during recovery DROP DATABASE very_long_database_name; SET GLOBAL innodb_flush_sync=OFF; SET GLOBAL innodb_page_cleaner_disabled_debug = 1; @@ -19,8 +16,5 @@ SET GLOBAL innodb_log_checkpoint_now = 1; # exceeds LOG_CHECKPOINT_FREE_PER_THREAD size during checkpoint. CREATE DATABASE very_long_database_name; USE very_long_database_name; -SET debug_dbug = '+d,crash_after_checkpoint'; set global innodb_log_checkpoint_now = 1; -ERROR HY000: Lost connection to MySQL server during query -# Skip MLOG_FILE_NAME redo records during recovery DROP DATABASE very_long_database_name; diff --git a/mysql-test/suite/innodb/t/redo_log_during_checkpoint.test b/mysql-test/suite/innodb/t/redo_log_during_checkpoint.test index 40b412ac9bb..0119089f688 100644 --- a/mysql-test/suite/innodb/t/redo_log_during_checkpoint.test +++ b/mysql-test/suite/innodb/t/redo_log_during_checkpoint.test @@ -3,9 +3,6 @@ --source include/big_test.inc # Embedded server tests do not support restarting --source include/not_embedded.inc -# We are crashing the server on purpose ---source include/not_valgrind.inc ---source include/not_crashrep.inc # This often fails under MSAN builder due timing differences --source include/not_msan.inc @@ -37,12 +34,10 @@ while ($i) --exec echo "wait" > $_expect_file_name SET debug_dbug = '+d,increase_mtr_checkpoint_size'; -SET debug_dbug = '+d,crash_after_checkpoint'; ---error 2013 set global innodb_log_checkpoint_now = 1; ---echo # Skip MLOG_FILE_NAME redo records during recovery ---source include/start_mysqld.inc +--let $restart_timeout=0 +--source include/restart_mysqld.inc DROP DATABASE very_long_database_name; @@ -67,13 +62,9 @@ while ($i) } --enable_query_log ---exec echo "wait" > $_expect_file_name -SET debug_dbug = '+d,crash_after_checkpoint'; ---error 2013 set global innodb_log_checkpoint_now = 1; ---echo # Skip MLOG_FILE_NAME redo records during recovery --let $restart_parameters = --debug-dbug=d,reduce_recv_parsing_buf ---source include/start_mysqld.inc +--source include/restart_mysqld.inc DROP DATABASE very_long_database_name; diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index cee2fa978ab..a03e79d27d8 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2009, Google Inc. -Copyright (c) 2014, 2021, MariaDB Corporation. +Copyright (c) 2014, 2022, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -968,8 +968,6 @@ ATTRIBUTE_COLD void log_write_checkpoint_info(lsn_t end_lsn) MONITOR_INC(MONITOR_NUM_CHECKPOINT); - DBUG_EXECUTE_IF("crash_after_checkpoint", DBUG_SUICIDE();); - mysql_mutex_unlock(&log_sys.mutex); } From 9b8d9a1db32e7526e2b290bdb1f232eb444ae259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 11 Mar 2022 10:47:32 +0200 Subject: [PATCH 12/12] Fix main.create_or_replace Ever since commit 9608773f75e2ca21491ef6825c3616cdc96d1ca5 we no longer disable innodb_stats_persistent. Ever since commit 45a05fda27dc7058ce8a89f14b1daa56352adf6b updates of the InnoDB persistent statistics are covered by MDL. --- mysql-test/main/create_or_replace.result | 6 ++++-- mysql-test/main/create_or_replace.test | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index e1670aff9ce..294b0623fc1 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -353,7 +353,8 @@ drop table test.t1; # create table t1 (i int); lock table t1 write; -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME # MDL_BACKUP_DDL NULL Backup lock # MDL_BACKUP_DML NULL Backup lock @@ -364,7 +365,8 @@ ERROR 22001: Data too long for column 'a' at row 1 show tables; Tables_in_test t2 -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME create table t1 (i int); drop table t1; diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test index 4b954263a87..7fa08d13847 100644 --- a/mysql-test/main/create_or_replace.test +++ b/mysql-test/main/create_or_replace.test @@ -285,13 +285,15 @@ create table t1 (i int); lock table t1 write; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; --error ER_DATA_TOO_LONG create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a; show tables; --replace_column 1 # --sorted_result -select * from information_schema.metadata_lock_info; +select * from information_schema.metadata_lock_info +where table_schema!='mysql' or table_name not like 'innodb_%_stats'; create table t1 (i int); drop table t1;