From 1d56d875fe28f34cefc1bb4e162331ae9f4ce9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 7 Jan 2019 12:12:30 +0200 Subject: [PATCH 01/11] MDEV-15740: InnoDB does not flush redo log when it shoul MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During database recovery, a transaction with wsrep XID is recovered from InnoDB in prepared state. However, when the transaction is looked up with trx_get_trx_by_xid() in innobase_commit_by_xid(), trx->xid gets cleared in trx_get_trx_by_xid_low() and commit time serialization history write does not update the wsrep XID in trx sys header for that recovered trx. As a result the transaction gets committed during recovery but the wsrep position does not get updated appropriately. As a fix, we preserve trx->xid for Galera over transaction commit in recovery phase. Fix authored by: Teemu Ollakka (GaleraCluster) and Marko Mäkelä. modified: mysql-test/suite/galera/disabled.def modified: mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result modified: mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result modified: mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test modified: mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test modified: storage/innobase/trx/trx0trx.cc modified: storage/xtradb/trx/trx0trx.cc --- mysql-test/suite/galera/disabled.def | 3 --- .../suite/galera/r/galera_gcache_recover_full_gcache.result | 4 ++++ .../suite/galera/r/galera_gcache_recover_manytrx.result | 4 ++++ .../suite/galera/t/galera_gcache_recover_full_gcache.test | 5 +++++ .../suite/galera/t/galera_gcache_recover_manytrx.test | 5 +++++ storage/innobase/trx/trx0trx.cc | 6 ++++++ storage/xtradb/trx/trx0trx.cc | 6 ++++++ 7 files changed, 30 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 94256dd88d7..53363f0a2ea 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -20,9 +20,6 @@ galera_as_slave_preordered : wsrep-preordered feature not merged to MariaDB GAL-419 : MDEV-13549 Galera test failures galera_var_notify_cmd : MDEV-13549 Galera test failures galera_as_slave_replication_bundle : MDEV-13549 Galera test failures -galera_gcache_recover : MDEV-13549 Galera test failures -galera_gcache_recover_full_gcache : MDEV-13549 Galera test failures -galera_gcache_recover_manytrx : MDEV-13549 Galera test failures galera_ssl_upgrade : MDEV-13549 Galera test failures galera.MW-329 : wsrep_local_replays not stable MW-416 : MDEV-13549 Galera test failures diff --git a/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result b/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result index 30ee5772411..ca81d7d8164 100644 --- a/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result +++ b/mysql-test/suite/galera/r/galera_gcache_recover_full_gcache.result @@ -1,3 +1,7 @@ +call mtr.add_suppression("InnoDB: Warning: innodb_page_size has been changed from default value *"); +call mtr.add_suppression("InnoDB: Resizing redo log from *"); +call mtr.add_suppression("InnoDB: Starting to delete and rewrite log files."); +call mtr.add_suppression("InnoDB: New log files created, LSN=*"); SET SESSION wsrep_sync_wait = 0; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; SET SESSION wsrep_sync_wait = 0; diff --git a/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result b/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result index 868b39bfbd6..1483c5d1de5 100644 --- a/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result +++ b/mysql-test/suite/galera/r/galera_gcache_recover_manytrx.result @@ -1,3 +1,7 @@ +call mtr.add_suppression("InnoDB: Warning: innodb_page_size has been changed from default value *"); +call mtr.add_suppression("InnoDB: Resizing redo log from *"); +call mtr.add_suppression("InnoDB: Starting to delete and rewrite log files."); +call mtr.add_suppression("InnoDB: New log files created, LSN=*"); SET SESSION wsrep_sync_wait = 0; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test index b7fd9cf3aed..7eb25d001f5 100644 --- a/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test +++ b/mysql-test/suite/galera/t/galera_gcache_recover_full_gcache.test @@ -5,6 +5,11 @@ --source include/galera_cluster.inc --source include/big_test.inc +call mtr.add_suppression("InnoDB: Warning: innodb_page_size has been changed from default value *"); +call mtr.add_suppression("InnoDB: Resizing redo log from *"); +call mtr.add_suppression("InnoDB: Starting to delete and rewrite log files."); +call mtr.add_suppression("InnoDB: New log files created, LSN=*"); + SET SESSION wsrep_sync_wait = 0; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; diff --git a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test index 08165f30f7d..ac28a070cf9 100644 --- a/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test +++ b/mysql-test/suite/galera/t/galera_gcache_recover_manytrx.test @@ -7,6 +7,11 @@ --source include/big_test.inc --source include/have_log_bin.inc +call mtr.add_suppression("InnoDB: Warning: innodb_page_size has been changed from default value *"); +call mtr.add_suppression("InnoDB: Resizing redo log from *"); +call mtr.add_suppression("InnoDB: Starting to delete and rewrite log files."); +call mtr.add_suppression("InnoDB: New log files created, LSN=*"); + SET SESSION wsrep_sync_wait = 0; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 58dc9445546..f36aabba8b4 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -2300,6 +2300,12 @@ trx_get_trx_by_xid_low( && memcmp(xid->data, trx->xid.data, xid->gtrid_length + xid->bqual_length) == 0) { +#ifdef WITH_WSREP + /* The commit of a prepared recovered Galera + transaction needs a valid trx->xid for + invoking trx_sys_update_wsrep_checkpoint(). */ + if (wsrep_is_wsrep_xid(&trx->xid)) break; +#endif /* Invalidate the XID, so that subsequent calls will not find it. */ trx->xid.null(); diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc index 6a033fbeb09..17cba81daf3 100644 --- a/storage/xtradb/trx/trx0trx.cc +++ b/storage/xtradb/trx/trx0trx.cc @@ -2578,6 +2578,12 @@ trx_get_trx_by_xid_low( && memcmp(xid->data, trx->xid.data, xid->gtrid_length + xid->bqual_length) == 0) { +#ifdef WITH_WSREP + /* The commit of a prepared recovered Galera + transaction needs a valid trx->xid for + invoking trx_sys_update_wsrep_checkpoint(). */ + if (wsrep_is_wsrep_xid(&trx->xid)) break; +#endif /* Invalidate the XID, so that subsequent calls will not find it. */ trx->xid.null(); From 4a872ae1e725b8d17f8266a9ca33a2aca4285c00 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 9 Jan 2019 22:28:31 +0100 Subject: [PATCH 02/11] MDEV-18185 - mariabackup - fix specific case of table rename handing in prepare. If, during backup 1) Innodb table is dropped (after being copied to backup) and then 2) Before backup finished, another Innodb table is renamed, and new name is the name of the dropped table in 1) then, --prepare fails with assertion, as DDL fixup code in prepare did not handle this specific case. The fix is to process drops before renames, in prepare DDL-"redo" phase. --- extra/mariabackup/xtrabackup.cc | 4 ++-- .../suite/mariabackup/drop_table_during_backup.result | 5 +++++ .../suite/mariabackup/drop_table_during_backup.test | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 1b5e28bb257..e0013979901 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -5510,10 +5510,10 @@ xtrabackup_prepare_func(char** argv) else { xb_process_datadir(".", ".new", prepare_handle_new_files); } - xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".", - ".ren", prepare_handle_ren_files); xb_process_datadir(xtrabackup_incremental_dir ? xtrabackup_incremental_dir : ".", ".del", prepare_handle_del_files); + xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".", + ".ren", prepare_handle_ren_files); int argc; for (argc = 0; argv[argc]; argc++) {} diff --git a/mysql-test/suite/mariabackup/drop_table_during_backup.result b/mysql-test/suite/mariabackup/drop_table_during_backup.result index 1472ddbddcf..8a77945e586 100644 --- a/mysql-test/suite/mariabackup/drop_table_during_backup.result +++ b/mysql-test/suite/mariabackup/drop_table_during_backup.result @@ -1,6 +1,8 @@ CREATE TABLE t1 (i int) ENGINE=INNODB; CREATE TABLE t2 (i int) ENGINE=INNODB; CREATE TABLE t3 (i int) ENGINE=INNODB; +CREATE TABLE t4 (i int) ENGINE=INNODB; +CREATE TABLE t5 (i int) ENGINE=INNODB; # xtrabackup prepare # shutdown server # remove datadir @@ -11,3 +13,6 @@ DROP TABLE t1; CREATE TABLE t2(i int); DROP TABLE t2; DROP TABLE t3; +CREATE TABLE t4(i int); +DROP TABLE t4; +DROP TABLE t5; diff --git a/mysql-test/suite/mariabackup/drop_table_during_backup.test b/mysql-test/suite/mariabackup/drop_table_during_backup.test index 02c7710145b..e3a81b77b71 100644 --- a/mysql-test/suite/mariabackup/drop_table_during_backup.test +++ b/mysql-test/suite/mariabackup/drop_table_during_backup.test @@ -3,8 +3,14 @@ let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; CREATE TABLE t1 (i int) ENGINE=INNODB; CREATE TABLE t2 (i int) ENGINE=INNODB; CREATE TABLE t3 (i int) ENGINE=INNODB; +CREATE TABLE t4 (i int) ENGINE=INNODB; +CREATE TABLE t5 (i int) ENGINE=INNODB; + --let before_copy_test_t1=DROP TABLE test.t1 --let after_copy_test_t2=DROP TABLE test.t2; +# MDEV-18185, drop + rename combination +--let after_copy_test_t5=BEGIN NOT ATOMIC DROP TABLE test.t5; RENAME TABLE test.t4 TO test.t5; END + --disable_result_log exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; --enable_result_log @@ -21,4 +27,7 @@ DROP TABLE t1; CREATE TABLE t2(i int); DROP TABLE t2; DROP TABLE t3; +CREATE TABLE t4(i int); +DROP TABLE t4; +DROP TABLE t5; rmdir $targetdir; From 7331c661dbb71b0826bfaf28e3fbe34411c6f8e4 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 10 Jan 2019 19:35:45 +0100 Subject: [PATCH 03/11] MDEV-18201 : mariabackup- fix processing of rename/create sequence in prepare Fix one more bug in "DDL redo" phase in prepare If table was renamed, and then new table was created with the old name, prepare can be confused, and .ibd can end up with wrong name. Fix the order of how DDL fixup is applied , once again - ".new" files should be processed after renames. --- extra/mariabackup/xtrabackup.cc | 13 ++++++++----- .../suite/mariabackup/rename_during_backup.result | 9 +++++++++ .../suite/mariabackup/rename_during_backup.test | 7 +++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index e0013979901..4d5fc98fcd6 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -5503,6 +5503,14 @@ xtrabackup_prepare_func(char** argv) fil_path_to_mysql_datadir = "."; + /* Fix DDL for prepare. Process .del,.ren, and .new files. + The order in which files are processed, is important + (see MDEV-18185, MDEV-18201) + */ + xb_process_datadir(xtrabackup_incremental_dir ? xtrabackup_incremental_dir : ".", + ".del", prepare_handle_del_files); + xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".", + ".ren", prepare_handle_ren_files); if (xtrabackup_incremental_dir) { xb_process_datadir(xtrabackup_incremental_dir, ".new.meta", prepare_handle_new_files); xb_process_datadir(xtrabackup_incremental_dir, ".new.delta", prepare_handle_new_files); @@ -5510,11 +5518,6 @@ xtrabackup_prepare_func(char** argv) else { xb_process_datadir(".", ".new", prepare_handle_new_files); } - xb_process_datadir(xtrabackup_incremental_dir ? xtrabackup_incremental_dir : ".", - ".del", prepare_handle_del_files); - xb_process_datadir(xtrabackup_incremental_dir? xtrabackup_incremental_dir:".", - ".ren", prepare_handle_ren_files); - int argc; for (argc = 0; argv[argc]; argc++) {} encryption_plugin_prepare_init(argc, argv); diff --git a/mysql-test/suite/mariabackup/rename_during_backup.result b/mysql-test/suite/mariabackup/rename_during_backup.result index 6e8f365f643..a4cf06b7633 100644 --- a/mysql-test/suite/mariabackup/rename_during_backup.result +++ b/mysql-test/suite/mariabackup/rename_during_backup.result @@ -4,6 +4,8 @@ CREATE TABLE t2(i int) ENGINE INNODB; INSERT INTO t2 values(2); CREATE TABLE t3(i int) ENGINE INNODB; CREATE TABLE t4(i int) ENGINE INNODB; +CREATE TABLE t5(i int) ENGINE INNODB; +INSERT INTO t5 VALUES(5); CREATE TABLE a(a int) ENGINE INNODB; INSERT INTO a values(1); CREATE TABLE b(b CHAR(1)) ENGINE INNODB; @@ -51,3 +53,10 @@ SELECT * FROM b1; a1 1 DROP TABLE a,b,a1,b1; +SELECT * from t5; +i +DROP TABLE t5; +SELECT * from t6; +i +5 +DROP TABLE t6; diff --git a/mysql-test/suite/mariabackup/rename_during_backup.test b/mysql-test/suite/mariabackup/rename_during_backup.test index f176af1451b..238a8b1985c 100644 --- a/mysql-test/suite/mariabackup/rename_during_backup.test +++ b/mysql-test/suite/mariabackup/rename_during_backup.test @@ -10,6 +10,8 @@ INSERT INTO t2 values(2); CREATE TABLE t3(i int) ENGINE INNODB; CREATE TABLE t4(i int) ENGINE INNODB; +CREATE TABLE t5(i int) ENGINE INNODB; +INSERT INTO t5 VALUES(5); CREATE TABLE a(a int) ENGINE INNODB; INSERT INTO a values(1); @@ -28,6 +30,7 @@ INSERT INTO b1 VALUES('b1'); --let after_copy_test_t3=BEGIN NOT ATOMIC RENAME TABLE test.t3 TO test.t3_tmp; INSERT INTO test.t3_tmp VALUES(3); RENAME TABLE test.t3_tmp TO test.t3; END --let before_copy_test_t4=RENAME TABLE test.t4 TO test.t4_tmp --let after_copy_test_t4=RENAME TABLE test.t4_tmp TO test.t4 +--let after_copy_test_t5=BEGIN NOT ATOMIC RENAME TABLE test.t5 TO test.t6; CREATE TABLE test.t5(i int) ENGINE INNODB; END # Test circular renames --let before_copy_test_b=RENAME TABLE test.a to test.tmp, test.b to test.a, test.tmp to test.b @@ -81,6 +84,10 @@ SELECT * FROM a1; SELECT * FROM b1; DROP TABLE a,b,a1,b1; +SELECT * from t5; +DROP TABLE t5; +SELECT * from t6; +DROP TABLE t6; rmdir $targetdir; From 79078167c36c83132413a82bfb4494fd229be810 Mon Sep 17 00:00:00 2001 From: Sachin Date: Wed, 19 Dec 2018 22:30:28 +0530 Subject: [PATCH 04/11] MDEV-17753 ALTER USER fail to replicate Change mysql_alter_user to log alter user command. --- mysql-test/suite/rpl/r/rpl_user.result | 11 +++++++++++ mysql-test/suite/rpl/t/rpl_user.test | 11 +++++++++++ sql/sql_acl.cc | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_user.result b/mysql-test/suite/rpl/r/rpl_user.result index 34f15d41209..2a8bf69501c 100644 --- a/mysql-test/suite/rpl/r/rpl_user.result +++ b/mysql-test/suite/rpl/r/rpl_user.result @@ -31,6 +31,13 @@ Host User fakehost barbar fakehost foofoo connection master; +alter user 'foofoo'@'fakehost' identified by 'foo'; +alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'barbar'@'fakehost' identified by 'bar'; +ERROR HY000: Operation ALTER USER failed for 'non_exist_user1'@'fakehost' +alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'non_exist_user2'@'fakehost' identified by 'bar'; +ERROR HY000: Operation ALTER USER failed for 'non_exist_user1'@'fakehost','non_exist_user2'@'fakehost' +connection slave; +connection master; drop user 'foofoo'@'fakehost'; drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost'; ERROR HY000: Operation DROP USER failed for 'not_exist_user1'@'fakehost' @@ -51,6 +58,10 @@ master-bin.000001 # Query # # use `test`; rename user 'foo'@'fakehost' to 'foofo master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'bar'@'fakehost' to 'barbar'@'fakehost' master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; alter user 'foofoo'@'fakehost' identified by 'foo' +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'barbar'@'fakehost' identified by 'bar' +master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; drop user 'foofoo'@'fakehost' master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; drop user 'not_exist_user1'@'fakehost', 'barbar'@'fakehost' diff --git a/mysql-test/suite/rpl/t/rpl_user.test b/mysql-test/suite/rpl/t/rpl_user.test index caa17b47733..079c2bf27d5 100644 --- a/mysql-test/suite/rpl/t/rpl_user.test +++ b/mysql-test/suite/rpl/t/rpl_user.test @@ -41,6 +41,17 @@ rename user 'not_exist_user1'@'fakehost' to 'foobar'@'fakehost', 'not_exist_user sync_slave_with_master; select Host,User from mysql.user where Host='fakehost'; +# +# Test alter user +# +connection master; +alter user 'foofoo'@'fakehost' identified by 'foo'; +--error ER_CANNOT_USER +alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'barbar'@'fakehost' identified by 'bar'; +--error ER_CANNOT_USER +alter user 'non_exist_user1'@'fakehost' identified by 'foo', 'non_exist_user2'@'fakehost' identified by 'bar'; +sync_slave_with_master; + # # Test drop user # diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b67bdbafa5c..76687dd0021 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -10478,6 +10478,7 @@ int mysql_alter_user(THD* thd, List &users_list) DBUG_ENTER("mysql_alter_user"); int result= 0; String wrong_users; + bool some_users_altered= false; /* The only table we're altering is the user table. */ Grant_tables tables(Table_user, TL_WRITE); @@ -10503,6 +10504,7 @@ int mysql_alter_user(THD* thd, List &users_list) result= TRUE; continue; } + some_users_altered= true; } /* Unlock ACL data structures. */ @@ -10527,6 +10529,10 @@ int mysql_alter_user(THD* thd, List &users_list) wrong_users.c_ptr_safe()); } } + + if (some_users_altered) + result|= write_bin_log(thd, FALSE, thd->query(), + thd->query_length()); DBUG_RETURN(result); } From 7372fe4da195f465a2f13984dcd89325ec361c43 Mon Sep 17 00:00:00 2001 From: FaramosCZ Date: Mon, 3 Dec 2018 12:59:45 +0100 Subject: [PATCH 05/11] xb_process_datadir(): Fix resource leaks Closes #983, #984 --- extra/mariabackup/xtrabackup.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 5edfb8b31f3..ef75797d1a4 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -5266,6 +5266,7 @@ xb_process_datadir( path, NULL, fileinfo.name, data)) { + os_file_closedir(dbdir); return(FALSE); } } @@ -5326,6 +5327,7 @@ next_file_item_1: dbinfo.name, fileinfo.name, data)) { + os_file_closedir(dbdir); return(FALSE); } } From f5ee7fb31f25c88113bdd688d8764a9eaed339bc Mon Sep 17 00:00:00 2001 From: FaramosCZ Date: Thu, 29 Nov 2018 13:38:16 +0100 Subject: [PATCH 06/11] Fix a memory leak in ALTER TABLE Closes #965 --- storage/innobase/btr/btr0bulk.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index bf33745f091..906b42a8e7b 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -836,6 +836,7 @@ BtrBulk::insert( level, m_flush_observer)); err = new_page_bulk->init(); if (err != DB_SUCCESS) { + UT_DELETE(new_page_bulk); return(err); } From 46046f2e59d053c75433c9e5fdf4fbf487965593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Jan 2019 13:20:59 +0200 Subject: [PATCH 07/11] After-merge fix: Disable a failing test --- mysql-test/suite/galera/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index e4c27fcb5c2..ec0ed01b408 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -45,3 +45,4 @@ galera.MW-328C : MDEV-17847 Galera test failure on MW-328[A|B|C] galera.galera_sst_xtrabackup-v2 : MDEV-17848 Galera test failure on galera_sst_xtrabackup-v2[_data_dir] galera.galera_sst_xtrabackup-v2_data_dir : MDEV-17848 Galera test failure on galera_sst_xtrabackup-v2[_data_dir] query_cache : MDEV-18137: Galera test failure on query_cache +galera_gcache_recover_manytrx : MDEV-15740 From cbdc2d9489b2e37c4e5e7e64b77e27e1dd44146b Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 27 Dec 2018 21:14:07 +0300 Subject: [PATCH 08/11] Replace log_group_t::file_header_bufs with local array log_group_file_header_flush(): Use a stack-local variable instead of the heap-allocated buffers. Closes #1060 --- storage/innobase/include/log0log.h | 4 ---- storage/innobase/log/log0log.cc | 33 +++--------------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 336e33fccad..745714e791b 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -571,10 +571,6 @@ struct log_group_t{ lsn_t lsn; /** the byte offset of the above lsn */ lsn_t lsn_offset; - /** unaligned buffers */ - byte** file_header_bufs_ptr; - /** buffers for each file header in the group */ - byte** file_header_bufs; /** used only in recovery: recovery scan succeeded up to this lsn in this log group */ diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 4a789382004..13b98cda34a 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -786,7 +786,6 @@ log_sys_init() void log_init(ulint n_files) { - ulint i; log_group_t* group = &log_sys->log; group->n_files = n_files; @@ -805,22 +804,6 @@ log_init(ulint n_files) group->lsn = LOG_START_LSN; group->lsn_offset = LOG_FILE_HDR_SIZE; - group->file_header_bufs_ptr = static_cast( - ut_zalloc_nokey(sizeof(byte*) * n_files)); - - group->file_header_bufs = static_cast( - ut_zalloc_nokey(sizeof(byte**) * n_files)); - - for (i = 0; i < n_files; i++) { - group->file_header_bufs_ptr[i] = static_cast( - ut_zalloc_nokey(LOG_FILE_HDR_SIZE - + OS_FILE_LOG_BLOCK_SIZE)); - - group->file_header_bufs[i] = static_cast( - ut_align(group->file_header_bufs_ptr[i], - OS_FILE_LOG_BLOCK_SIZE)); - } - group->checkpoint_buf_ptr = static_cast( ut_zalloc_nokey(2 * OS_FILE_LOG_BLOCK_SIZE)); @@ -874,7 +857,6 @@ log_group_file_header_flush( lsn_t start_lsn) /*!< in: log file data starts at this lsn */ { - byte* buf; lsn_t dest_offset; ut_ad(log_write_mutex_own()); @@ -885,9 +867,10 @@ log_group_file_header_flush( ? LOG_HEADER_FORMAT_10_3 : LOG_HEADER_FORMAT_10_2)); - buf = *(group->file_header_bufs + nth_file); + // man 2 open suggests this buffer to be aligned by 512 for O_DIRECT + MY_ALIGNED(OS_FILE_LOG_BLOCK_SIZE) + byte buf[OS_FILE_LOG_BLOCK_SIZE] = {0}; - memset(buf, 0, OS_FILE_LOG_BLOCK_SIZE); mach_write_to_4(buf + LOG_HEADER_FORMAT, group->format); mach_write_to_4(buf + LOG_HEADER_SUBFORMAT, srv_safe_truncate); mach_write_to_8(buf + LOG_HEADER_START_LSN, start_lsn); @@ -2247,18 +2230,8 @@ static void log_group_close(log_group_t* group) { - ulint i; - - for (i = 0; i < group->n_files; i++) { - ut_free(group->file_header_bufs_ptr[i]); - } - - ut_free(group->file_header_bufs_ptr); - ut_free(group->file_header_bufs); ut_free(group->checkpoint_buf_ptr); group->n_files = 0; - group->file_header_bufs_ptr = NULL; - group->file_header_bufs = NULL; group->checkpoint_buf_ptr = NULL; } From a75dbfd7183cc96680f3e3e684fd36500dac8158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Jan 2019 14:37:34 +0200 Subject: [PATCH 09/11] MDEV-12266: Remove fil_space_t::name_hash The fil_system_t::name_hash was removed already earlier, in commit 05863142ad0db0cb49f675b2a527a953d187a565. The fil_space_t::name_hash was thus made an orphan data field. --- storage/innobase/include/fil0fil.h | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 91f50d70e5d..a961c94c0f0 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -146,7 +146,6 @@ struct fil_space_t { Protected by fil_system.mutex and my_atomic_loadlint() and friends. */ ulint n_pending_ios; hash_node_t hash; /*!< hash chain node */ - hash_node_t name_hash;/*!< hash chain the name_hash table */ rw_lock_t latch; /*!< latch protecting the file space storage allocation */ UT_LIST_NODE_T(fil_space_t) unflushed_spaces; From 662217a592af4fef8a635bbd56544b5d56e5dcd6 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 9 Jan 2019 16:36:41 +0300 Subject: [PATCH 10/11] MDEV-18186 assertion failure on missing InnoDB index This was introduced in 1a7a018939e19a0037808489be0fd1680581aec3 MDEV-16557 Remove INNOBASE_SHARE::idx_trans_tbl ha_innobase::innobase_get_index: remove incorrect assertion. Index nullability is checked in subsequent ifs. Closes #1079 --- mysql-test/suite/innodb/r/innodb-index.result | 16 ++++++++++++++ mysql-test/suite/innodb/t/innodb-index.test | 22 +++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 1 - 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result index 8d7dcb84486..734cc41a8ea 100644 --- a/mysql-test/suite/innodb/r/innodb-index.result +++ b/mysql-test/suite/innodb/r/innodb-index.result @@ -1892,3 +1892,19 @@ f1 SELECT * FROM t2; f1 DROP TABLE t1, t2; +# +# MDEV-18186 assertion failure on missing InnoDB index +# +CREATE TABLE t (a INT, INDEX i1 (a)) ENGINE=INNODB; +DROP TABLE t; +CREATE TABLE t (a INT) ENGINE=INNODB; +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + KEY `i1` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +Warnings: +Warning 1082 InnoDB: Table test/t contains 0 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB +Warning 1082 InnoDB: Table test/t contains 0 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB +DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test index f199da54031..53f87cb78d5 100644 --- a/mysql-test/suite/innodb/t/innodb-index.test +++ b/mysql-test/suite/innodb/t/innodb-index.test @@ -1151,6 +1151,28 @@ SELECT * FROM t2; DROP TABLE t1, t2; +--echo # +--echo # MDEV-18186 assertion failure on missing InnoDB index +--echo # + +--disable_query_log +call mtr.add_suppression("Cannot find index i1 in InnoDB index dictionary"); +call mtr.add_suppression("InnoDB indexes are inconsistent with what defined"); +call mtr.add_suppression("Table test/t contains 0 indexes"); +call mtr.add_suppression("InnoDB could not find key no"); +--enable_query_log + +# Test an attempt to rename a nonexistent index inside InnoDB +-- let $MYSQL_DATA_DIR = `SELECT @@datadir` +CREATE TABLE t (a INT, INDEX i1 (a)) ENGINE=INNODB; +-- copy_file $MYSQL_DATA_DIR/test/t.frm $MYSQL_DATA_DIR/test/t.fr_ +DROP TABLE t; +CREATE TABLE t (a INT) ENGINE=INNODB; +-- remove_file $MYSQL_DATA_DIR/test/t.frm +-- move_file $MYSQL_DATA_DIR/test/t.fr_ $MYSQL_DATA_DIR/test/t.frm +SHOW CREATE TABLE t; +DROP TABLE t; + --disable_query_log call mtr.add_suppression("InnoDB: Tablespace .* was not found at .*t[12].ibd."); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 611387d749b..195712a5e54 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -9534,7 +9534,6 @@ ha_innobase::innobase_get_index( if (keynr != MAX_KEY && table->s->keys > 0) { key = &table->key_info[keynr]; index = dict_table_get_index_on_name(ib_table, key->name); - ut_ad(index); } else { index = dict_table_get_first_index(ib_table); } From 8655592ae544dc52b658b41ec85f9d552ec53258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 15 Jan 2019 08:52:26 +0200 Subject: [PATCH 11/11] recv_log_recover_10_4(): Fix a trivial bug --- storage/innobase/log/log0recv.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index afcd9079480..d5f6a6d0408 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -1037,9 +1037,7 @@ static dberr_t recv_log_recover_10_4() { ut_ad(!log_sys.is_encrypted()); const lsn_t lsn = log_sys.log.lsn; - log_mutex_enter(); const lsn_t source_offset = log_sys.log.calc_lsn_offset(lsn); - log_mutex_exit(); const ulint page_no = (ulint) (source_offset / univ_page_size.physical()); byte* buf = log_sys.buf;