diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index c4ed434792e..5677eb78466 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -5215,6 +5215,7 @@ xb_process_datadir( path, NULL, fileinfo.name, NULL)) { + os_file_closedir(dbdir); return(FALSE); } } @@ -5276,6 +5277,7 @@ next_file_item_1: dbinfo.name, fileinfo.name, NULL)) { + os_file_closedir(dbdir); return(FALSE); } } @@ -5456,6 +5458,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); @@ -5463,11 +5473,6 @@ 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); - int argc; for (argc = 0; argv[argc]; argc++) {} encryption_plugin_prepare_init(argc, argv); diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 23c9b9d7b55..d601824450a 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 MW-329 : wsrep_local_replays not stable MW-416 : MDEV-13549 Galera test failures @@ -53,3 +50,4 @@ MW-328C : MDEV-17847 Galera test failure on MW-328[A|B|C] galera.galera_encrypt_tmp_files : Get error failed to enable encryption of temporary files galera.galera_var_reject_queries : assertion in inline_mysql_socket_send query_cache : MDEV-18137: Galera test failure on query_cache +galera_gcache_recover_manytrx : MDEV-15740 diff --git a/mysql-test/suite/galera/r/galera_gcache_recover.result b/mysql-test/suite/galera/r/galera_gcache_recover.result index 127bcba39d8..d3ba06c1333 100644 --- a/mysql-test/suite/galera/r/galera_gcache_recover.result +++ b/mysql-test/suite/galera/r/galera_gcache_recover.result @@ -1,18 +1,25 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); SET SESSION wsrep_sync_wait = 0; +connection node_2; SET SESSION wsrep_sync_wait = 0; Killing server ... +connection node_1; INSERT INTO t1 VALUES (2); Killing server ... +connection node_1; Performing --wsrep-recover ... Using --wsrep-start-position when starting mysqld ... INSERT INTO t1 VALUES (3); +connection node_2; Performing --wsrep-recover ... Using --wsrep-start-position when starting mysqld ... +connection node_1; include/diff_servers.inc [servers=1 2] +connection node_1; CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); include/assert_grep.inc [async IST sender starting to serve] +connection node_2; CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); include/assert_grep.inc [Recovering GCache ring buffer: found gapless sequence] DROP TABLE t1; 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..588af5668bb 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,19 +1,26 @@ SET SESSION wsrep_sync_wait = 0; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 LONGBLOB) ENGINE=InnoDB; +connection node_2; SET SESSION wsrep_sync_wait = 0; Killing server ... +connection node_1; INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); INSERT INTO t1 (f2) VALUES (REPEAT('x', 1024 * 1024 * 10)); Killing server ... +connection node_1; Performing --wsrep-recover ... Using --wsrep-start-position when starting mysqld ... +connection node_2; Performing --wsrep-recover ... Using --wsrep-start-position when starting mysqld ... +connection node_1; include/diff_servers.inc [servers=1 2] +connection node_1; DROP TABLE t1; CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); include/assert_grep.inc [IST first seqno 2 not found from cache, falling back to SST] +connection node_2; CALL mtr.add_suppression("Skipped GCache ring buffer recovery"); diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result index 1d451fdc68d..a23d3593dce 100644 --- a/mysql-test/suite/innodb/r/innodb-index.result +++ b/mysql-test/suite/innodb/r/innodb-index.result @@ -1896,3 +1896,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/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; 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; 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 c5229d02d51..b2840c3dccb 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -10495,6 +10495,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; @@ -10518,6 +10519,7 @@ int mysql_alter_user(THD* thd, List &users_list) result= TRUE; continue; } + some_users_altered= true; } /* Unlock ACL data structures. */ @@ -10542,6 +10544,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); } diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index c3a190155c1..09f31259e8e 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -833,6 +833,7 @@ BtrBulk::insert( level, m_flush_observer)); err = new_page_bulk->init(); if (err != DB_SUCCESS) { + UT_DELETE(new_page_bulk); return(err); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 0c8bb36026a..50398328df4 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -9360,7 +9360,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.str); - ut_ad(index); } else { index = dict_table_get_first_index(ib_table); } diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index bce9516b11d..476e14b6c77 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -143,7 +143,6 @@ struct fil_space_t { Protected by fil_system.mutex and std::atomic. */ std::atomic 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; diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 3d28cacbfe0..3f0d149d5f1 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -564,11 +564,6 @@ struct log_t{ /** 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[SRV_N_LOG_FILES_MAX]; - /** used only in recovery: recovery scan succeeded up to this lsn in this log group */ lsn_t scanned_lsn; @@ -603,10 +598,7 @@ struct log_t{ /** Close the redo log buffer. */ void close() { - ut_free(file_header_bufs_ptr); n_files = 0; - file_header_bufs_ptr = NULL; - memset(file_header_bufs, 0, sizeof file_header_bufs); } } log; diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 9e05383bfc6..720bb94f012 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -670,16 +670,6 @@ void log_t::files::create(ulint n_files) file_size= srv_log_file_size; lsn= LOG_START_LSN; lsn_offset= LOG_FILE_HDR_SIZE; - - byte* ptr= static_cast(ut_zalloc_nokey(LOG_FILE_HDR_SIZE * n_files - + OS_FILE_LOG_BLOCK_SIZE)); - file_header_bufs_ptr= ptr; - ptr= static_cast(ut_align(ptr, OS_FILE_LOG_BLOCK_SIZE)); - - memset(file_header_bufs, 0, sizeof file_header_bufs); - - for (ulint i = 0; i < n_files; i++, ptr += LOG_FILE_HDR_SIZE) - file_header_bufs[i] = ptr; } /******************************************************//** @@ -692,7 +682,6 @@ log_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()); @@ -701,9 +690,10 @@ log_file_header_flush( ut_ad(log_sys.log.format == LOG_HEADER_FORMAT_10_4 || log_sys.log.format == LOG_HEADER_FORMAT_ENC_10_4); - buf = log_sys.log.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, log_sys.log.format); mach_write_to_4(buf + LOG_HEADER_SUBFORMAT, log_sys.log.subformat); mach_write_to_8(buf + LOG_HEADER_START_LSN, start_lsn); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index aaf21004568..333c7fe90eb 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -2150,6 +2150,12 @@ static my_bool trx_get_trx_by_xid_callback(rw_trx_hash_element_t *element, if (trx->is_recovered && trx_state_eq(trx, TRX_STATE_PREPARED) && arg->xid->eq(reinterpret_cast(trx->xid))) { +#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)) +#endif /* Invalidate the XID, so that subsequent calls will not find it. */ trx->xid->null(); arg->trx= trx;