diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-21 20:32:04 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-21 20:32:04 +0300 |
commit | 0b4ed0b7fbc8d61441718e05d95897c1bae430c4 (patch) | |
tree | b554868ace6265c4a9186f8822246daca345d498 | |
parent | d98ccbe1e1a8190d295fe91942ba739a12d9e245 (diff) | |
parent | aa6cb7ed03bb41b7ba59b6d7c9197cf24d65a36d (diff) | |
download | mariadb-git-0b4ed0b7fbc8d61441718e05d95897c1bae430c4.tar.gz |
Merge 10.4 into 10.5
56 files changed, 263 insertions, 334 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index bc174226281..417d3615995 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -185,7 +185,7 @@ static uint opt_tail_lines= 0; static uint opt_connect_timeout= 0; static uint opt_wait_for_pos_timeout= 0; - +static const uint default_wait_for_pos_timeout= 300; static char delimiter[MAX_DELIMITER_LENGTH]= ";"; static size_t delimiter_length= 1; @@ -5080,6 +5080,8 @@ void do_shutdown_server(struct st_command *command) }; DBUG_ENTER("do_shutdown_server"); + /* the wait-for-pos' default based value of 'timeout' must fit to MDEV-23511 */ + compile_time_assert(default_wait_for_pos_timeout / 5 >= 60); check_command_args(command, command->first_argument, shutdown_args, sizeof(shutdown_args)/sizeof(struct command_arg), ' '); @@ -7061,7 +7063,7 @@ static struct my_option my_long_options[] = {"wait_for_pos_timeout", 0, "Number of seconds to wait for master_pos_wait", &opt_wait_for_pos_timeout, &opt_wait_for_pos_timeout, 0, GET_UINT, - REQUIRED_ARG, 300, 0, 3600 * 12, 0, 0, 0}, + REQUIRED_ARG, default_wait_for_pos_timeout, 0, 3600 * 12, 0, 0, 0}, {"plugin_dir", 0, "Directory for client-side plugins.", &opt_plugin_dir, &opt_plugin_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc index 3d3e55db4ac..689f3b8cc1f 100644 --- a/mysql-test/include/restart_mysqld.inc +++ b/mysql-test/include/restart_mysqld.inc @@ -1,6 +1,6 @@ # ==== Usage ==== # -# [--let $shutdown_timeout= 30] +# [--let $shutdown_timeout= 60] # [--let $allow_rpl_inited= 1] # --source include/restart_mysqld.inc diff --git a/mysql-test/include/rpl_stop_server.inc b/mysql-test/include/rpl_stop_server.inc index 978cfec1885..049c3d5bbd2 100644 --- a/mysql-test/include/rpl_stop_server.inc +++ b/mysql-test/include/rpl_stop_server.inc @@ -47,8 +47,8 @@ if ($rpl_debug) --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect # Send shutdown to the connected server and give -# it 60 seconds to die before zapping it -shutdown_server 60; +# it 60 seconds (of mysqltest's default) to die before zapping it +shutdown_server; --source include/wait_until_disconnected.inc diff --git a/mysql-test/include/search_pattern_in_file.inc b/mysql-test/include/search_pattern_in_file.inc index 6cd725c3698..a899a9294cc 100644 --- a/mysql-test/include/search_pattern_in_file.inc +++ b/mysql-test/include/search_pattern_in_file.inc @@ -39,7 +39,7 @@ # # Stop the server # let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; # --exec echo "wait" > $restart_file -# --shutdown_server 10 +# --shutdown_server # --source include/wait_until_disconnected.inc # # --error 1 diff --git a/mysql-test/include/shutdown_mysqld.inc b/mysql-test/include/shutdown_mysqld.inc index c787c2b8c3f..db0cfb82c68 100644 --- a/mysql-test/include/shutdown_mysqld.inc +++ b/mysql-test/include/shutdown_mysqld.inc @@ -1,6 +1,6 @@ # ==== Usage ==== # -# [--let $shutdown_timeout= 30] +# [--let $shutdown_timeout= 60] # [--let $allow_rpl_inited= 1] # --source include/shutdown_mysqld.inc diff --git a/mysql-test/main/empty_server_name-8224.test b/mysql-test/main/empty_server_name-8224.test index b15e9d82eb8..5c5140be2e0 100644 --- a/mysql-test/main/empty_server_name-8224.test +++ b/mysql-test/main/empty_server_name-8224.test @@ -4,7 +4,7 @@ --source include/not_embedded.inc create server '' foreign data wrapper w2 options (host '127.0.0.1'); --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---shutdown_server 10 +--shutdown_server --source include/wait_until_disconnected.inc --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect diff --git a/mysql-test/main/host_cache_size_functionality.test b/mysql-test/main/host_cache_size_functionality.test index db4f64fd493..9ec26010ab6 100644 --- a/mysql-test/main/host_cache_size_functionality.test +++ b/mysql-test/main/host_cache_size_functionality.test @@ -44,7 +44,7 @@ select @@global.Host_Cache_Size > 0; let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; --exec echo "wait" > $restart_file ---shutdown_server 10 +--shutdown_server --source include/wait_until_disconnected.inc -- exec echo "restart:--host_cache_size=1 " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -- enable_reconnect @@ -143,7 +143,7 @@ SELECT Host_Cache_Size = @@SESSION.Host_Cache_Size; #let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; #--exec echo "wait" > $restart_file -#--shutdown_server 10 +#--shutdown_server #--source include/wait_until_disconnected.inc #-- exec echo "restart:--bind-address=$bind_ip " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect #-- enable_reconnect diff --git a/mysql-test/main/init_file_set_password-7656.test b/mysql-test/main/init_file_set_password-7656.test index c695d01b675..5e7a24fcf7f 100644 --- a/mysql-test/main/init_file_set_password-7656.test +++ b/mysql-test/main/init_file_set_password-7656.test @@ -15,7 +15,7 @@ EOF --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---shutdown_server 10 +--shutdown_server --source include/wait_until_disconnected.inc --exec echo "restart:--init-file=$MYSQLTEST_VARDIR/init.file " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect diff --git a/mysql-test/main/log_errchk.test b/mysql-test/main/log_errchk.test index 2808458e9f1..1afc0e29f3a 100644 --- a/mysql-test/main/log_errchk.test +++ b/mysql-test/main/log_errchk.test @@ -31,7 +31,7 @@ --echo # and slow query log file. # Restart server with fifo file as general log file. --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---shutdown_server 60 +--shutdown_server --source include/wait_until_disconnected.inc --enable_reconnect # Write file to make mysql-test-run.pl start up the server again diff --git a/mysql-test/suite/binlog/t/binlog_max_extension.test b/mysql-test/suite/binlog/t/binlog_max_extension.test index 199a31ea05c..81e357448f6 100644 --- a/mysql-test/suite/binlog/t/binlog_max_extension.test +++ b/mysql-test/suite/binlog/t/binlog_max_extension.test @@ -41,7 +41,7 @@ RESET MASTER; # 1. Stop master server -- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- shutdown_server 10 +-- shutdown_server -- source include/wait_until_disconnected.inc # 2. Prepare log and index file @@ -70,7 +70,7 @@ FLUSH LOGS; # 1. Stop the server -- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --- shutdown_server 10 +-- shutdown_server -- source include/wait_until_disconnected.inc # 2. Undo changes to index and log files diff --git a/mysql-test/suite/binlog_encryption/restart_server.inc b/mysql-test/suite/binlog_encryption/restart_server.inc index 6cd0788cf43..8f0fe7d8970 100644 --- a/mysql-test/suite/binlog_encryption/restart_server.inc +++ b/mysql-test/suite/binlog_encryption/restart_server.inc @@ -22,7 +22,7 @@ --enable_reconnect --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect -shutdown_server 10; +shutdown_server; --source include/wait_until_disconnected.inc diff --git a/mysql-test/suite/innodb/t/innodb-corrupted-table.test b/mysql-test/suite/innodb/t/innodb-corrupted-table.test index d1384d20c7b..a064f08d677 100644 --- a/mysql-test/suite/innodb/t/innodb-corrupted-table.test +++ b/mysql-test/suite/innodb/t/innodb-corrupted-table.test @@ -24,7 +24,7 @@ alter table t1 add primary key (pk); --echo # Stop the server, replace the frm with the old one and restart the server --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---shutdown_server 10 +--shutdown_server --source include/wait_until_disconnected.inc --remove_file $datadir/test/t1.frm diff --git a/mysql-test/suite/innodb/t/innodb_bug60196.test b/mysql-test/suite/innodb/t/innodb_bug60196.test index e479b8d6b82..7f1f5c40585 100644 --- a/mysql-test/suite/innodb/t/innodb_bug60196.test +++ b/mysql-test/suite/innodb/t/innodb_bug60196.test @@ -50,7 +50,7 @@ SELECT * FROM bug_60196; -- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Send a shutdown request to the server --- shutdown_server 10 +-- shutdown_server # Call script that will poll the server waiting for it to disapear -- source include/wait_until_disconnected.inc @@ -124,7 +124,7 @@ SELECT * FROM Bug_60309; -- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect # Send a shutdown request to the server --- shutdown_server 10 +-- shutdown_server # Call script that will poll the server waiting for it to disapear -- source include/wait_until_disconnected.inc diff --git a/mysql-test/suite/multi_source/info_logs.test b/mysql-test/suite/multi_source/info_logs.test index ef504e06a2f..234e317e5ce 100644 --- a/mysql-test/suite/multi_source/info_logs.test +++ b/mysql-test/suite/multi_source/info_logs.test @@ -150,7 +150,7 @@ show all slaves status; --append_file $MYSQLTEST_VARDIR/tmp/mysqld.3.expect restart EOF ---shutdown_server 60 +--shutdown_server --source include/wait_until_connected_again.inc --source include/wait_for_slave_to_start.inc set default_master_connection = 'MASTER 2.2'; diff --git a/mysql-test/suite/roles/acl_load_mutex-5170.test b/mysql-test/suite/roles/acl_load_mutex-5170.test index 22b9dffb5fd..76d817be055 100644 --- a/mysql-test/suite/roles/acl_load_mutex-5170.test +++ b/mysql-test/suite/roles/acl_load_mutex-5170.test @@ -10,7 +10,7 @@ flush tables; --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect wait EOF ---shutdown_server 60 +--shutdown_server --source include/wait_until_disconnected.inc --enable_reconnect --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect diff --git a/mysql-test/suite/rpl/include/rpl_shutdown_wait_slaves.inc b/mysql-test/suite/rpl/include/rpl_shutdown_wait_slaves.inc index 17720e94dc8..4726bbe1889 100644 --- a/mysql-test/suite/rpl/include/rpl_shutdown_wait_slaves.inc +++ b/mysql-test/suite/rpl/include/rpl_shutdown_wait_slaves.inc @@ -40,7 +40,7 @@ SET @@GLOBAL.debug_dbug="+d,simulate_delay_at_shutdown"; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect wait EOF -# --shutdown_server 60 +# --shutdown_server --send SHUTDOWN WAIT FOR ALL SLAVES --reap --source include/wait_until_disconnected.inc diff --git a/mysql-test/suite/rpl/t/rpl_gtid_crash.test b/mysql-test/suite/rpl/t/rpl_gtid_crash.test index 3c5542f4b2f..e72d1c3ef47 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_crash.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_crash.test @@ -626,7 +626,7 @@ SELECT * FROM t1 WHERE a >= 30 ORDER BY a; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect wait EOF -shutdown_server 10; +shutdown_server; --source include/wait_until_disconnected.inc --remove_file $datadir/master-bin.state diff --git a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test index 53d62805c58..fd4cdf71f6f 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test @@ -29,7 +29,7 @@ CHANGE MASTER TO master_use_gtid=current_pos; wait EOF FLUSH LOGS; ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --connection server_1 @@ -70,7 +70,7 @@ SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect @@ -103,7 +103,7 @@ SELECT * FROM t1 ORDER BY a; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect @@ -148,7 +148,7 @@ SELECT * FROM t1 ORDER BY a; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect @@ -191,7 +191,7 @@ SET sql_log_bin= 1; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect @@ -221,7 +221,7 @@ SELECT * FROM t1 ORDER BY a; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect @@ -237,7 +237,7 @@ SET sql_log_bin= 1; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect @@ -273,7 +273,7 @@ SELECT domain_id, COUNT(*) FROM mysql.gtid_slave_pos GROUP BY domain_id; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect @@ -305,7 +305,7 @@ SET sql_log_bin=1; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc # Let the slave mysqld server start again. diff --git a/mysql-test/suite/rpl/t/rpl_mdev12179.test b/mysql-test/suite/rpl/t/rpl_mdev12179.test index db1ec3d4d22..e3caccde6b4 100644 --- a/mysql-test/suite/rpl/t/rpl_mdev12179.test +++ b/mysql-test/suite/rpl/t/rpl_mdev12179.test @@ -57,7 +57,7 @@ SET sql_log_bin=1; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --connection server_1 @@ -96,7 +96,7 @@ SET sql_log_bin=1; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --connection server_1 @@ -134,7 +134,7 @@ SET sql_log_bin=1; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --connection server_1 @@ -178,7 +178,7 @@ SET sql_log_bin=1; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --connection server_1 @@ -275,7 +275,7 @@ while (!$done) wait EOF --connection server_2 ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --echo *** Restart the slave server to prove 'gtid_slave_pos_innodb' autodiscovery *** diff --git a/mysql-test/suite/rpl/t/rpl_mdev382.test b/mysql-test/suite/rpl/t/rpl_mdev382.test index 1d951cc7456..093b7b92413 100644 --- a/mysql-test/suite/rpl/t/rpl_mdev382.test +++ b/mysql-test/suite/rpl/t/rpl_mdev382.test @@ -208,7 +208,7 @@ SELECT * FROM `db1``; select 'oops!'`.`t``1` ORDER BY 1; wait-rpl_mdev382.test EOF ---shutdown_server 30 +--shutdown_server --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart-rpl_mdev382.test diff --git a/mysql-test/suite/rpl/t/rpl_parallel_partition.test b/mysql-test/suite/rpl/t/rpl_parallel_partition.test index 37dce9fef80..ea6c5dca6be 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_partition.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_partition.test @@ -42,7 +42,7 @@ ALTER TABLE `E` REMOVE PARTITIONING; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc --connection default --source include/wait_until_disconnected.inc diff --git a/mysql-test/suite/storage_engine/alter_tablespace.test b/mysql-test/suite/storage_engine/alter_tablespace.test index 3c4910069a0..1899da28320 100644 --- a/mysql-test/suite/storage_engine/alter_tablespace.test +++ b/mysql-test/suite/storage_engine/alter_tablespace.test @@ -46,7 +46,7 @@ wait EOF --enable_reconnect - --shutdown_server 60 + --shutdown_server --source include/wait_until_disconnected.inc diff --git a/mysql-test/suite/storage_engine/trx/xa_recovery.test b/mysql-test/suite/storage_engine/trx/xa_recovery.test index e17bb9d2ea4..f53640578cd 100644 --- a/mysql-test/suite/storage_engine/trx/xa_recovery.test +++ b/mysql-test/suite/storage_engine/trx/xa_recovery.test @@ -12,7 +12,7 @@ --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect restart EOF ---shutdown_server 60 +--shutdown_server --source include/wait_until_connected_again.inc diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index e00e59f79c4..7a27160ccd5 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -1511,7 +1511,7 @@ dict_create_or_check_foreign_constraint_tables(void) row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); srv_file_per_table = srv_file_per_table_backup; @@ -1612,7 +1612,7 @@ dict_create_or_check_sys_virtual() row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); srv_file_per_table = srv_file_per_table_backup; @@ -2146,7 +2146,7 @@ dict_create_or_check_sys_tablespace(void) row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); srv_file_per_table = srv_file_per_table_backup; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 0f1b3b461a8..097c907a826 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -262,7 +262,7 @@ dict_table_try_drop_aborted( } row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); } /**********************************************************************//** @@ -1975,7 +1975,7 @@ void dict_sys_t::remove(dict_table_t* table, bool lru, bool keep) row_merge_drop_indexes_dict(trx, table->id); trx_commit_for_mysql(trx); trx->dict_operation_lock_mode = 0; - trx_free(trx); + trx->free(); } /* Free virtual column template if any */ diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index b8fdff89545..b135e042dc7 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -897,7 +897,7 @@ dict_update_filepath( trx_commit_for_mysql(trx); trx->dict_operation_lock_mode = 0; - trx_free(trx); + trx->free(); if (UNIV_LIKELY(err == DB_SUCCESS)) { /* We just updated SYS_DATAFILES due to the contents in @@ -958,7 +958,7 @@ dict_replace_tablespace_and_filepath( trx_commit_for_mysql(trx); trx->dict_operation_lock_mode = 0; - trx_free(trx); + trx->free(); return(err); } diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 797f76862fa..03330664264 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -326,7 +326,7 @@ dict_stats_exec_sql( } if (trx_started) { - trx_free(trx); + trx->free(); } return(err); @@ -2569,7 +2569,7 @@ func_exit: trx_commit_for_mysql(trx); end: - trx_free(trx); + trx->free(); goto func_exit; } @@ -3039,7 +3039,7 @@ dict_stats_fetch_from_ps( trx_commit_for_mysql(trx); - trx_free(trx); + trx->free(); if (!index_fetch_arg.stats_were_modified) { return(DB_STATS_DO_NOT_EXIST); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index b5083b51061..cc69863f54b 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -532,7 +532,7 @@ cleanup: } que_graph_free(graph); - trx_free(trx); + trx->free(); ret = true; goto cleanup; } @@ -2711,7 +2711,7 @@ func_exit: } } - trx_free(trx); + trx->free(); return(error); } @@ -2786,7 +2786,7 @@ fts_update_sync_doc_id( fts_sql_rollback(trx); } - trx_free(trx); + trx->free(); } return(error); @@ -3016,7 +3016,7 @@ fts_commit_table( fts_sql_commit(trx); - trx_free(trx); + trx->free(); return(error); } @@ -3781,7 +3781,7 @@ fts_doc_fetch_by_doc_id( error = fts_eval_sql(trx, graph); fts_sql_commit(trx); - trx_free(trx); + trx->free(); if (!get_doc) { fts_que_graph_free(graph); @@ -4175,9 +4175,9 @@ fts_sync_commit( << " ins/sec"; } - /* Avoid assertion in trx_free(). */ + /* Avoid assertion in trx_t::free(). */ trx->dict_operation_lock_mode = 0; - trx_free(trx); + trx->free(); return(error); } @@ -4229,9 +4229,9 @@ fts_sync_rollback( fts_sql_rollback(trx); - /* Avoid assertion in trx_free(). */ + /* Avoid assertion in trx_t::free(). */ trx->dict_operation_lock_mode = 0; - trx_free(trx); + trx->free(); } /** Run SYNC on the table, i.e., write out data from the cache to the @@ -4934,7 +4934,7 @@ fts_get_rows_count( fts_que_graph_free(graph); - trx_free(trx); + trx->free(); return(count); } @@ -4960,7 +4960,7 @@ fts_update_max_cache_size( fts_sql_commit(trx); - trx_free(trx); + trx->free(); } #endif /* FTS_CACHE_SIZE_DEBUG */ @@ -6150,14 +6150,12 @@ fts_rename_aux_tables_to_hex_format_low( << table->name << ". Please revert" " manually."; fts_sql_rollback(trx_bg); - trx_free(trx_bg); /* Continue to clear aux tables' flags2 */ not_rename = true; - continue; + } else { + fts_sql_commit(trx_bg); } - - fts_sql_commit(trx_bg); - trx_free(trx_bg); + trx_bg->free(); } DICT_TF2_FLAG_UNSET(parent_table, DICT_TF2_FTS_AUX_HEX_NAME); @@ -6400,7 +6398,7 @@ fts_rename_aux_tables_to_hex_format( } fts_sql_commit(trx_rename); - trx_free(trx_rename); + trx_rename->free(); ib_vector_reset(aux_tables); } @@ -6479,7 +6477,7 @@ fts_drop_obsolete_aux_table_from_vector( fts_sql_commit(trx_drop); } - trx_free(trx_drop); + trx_drop->free(); } } @@ -6973,7 +6971,7 @@ fts_drop_orphaned_tables(void) row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); if (heap != NULL) { mem_heap_free(heap); @@ -7146,7 +7144,7 @@ cleanup: fts_sql_rollback(trx); } - trx_free(trx); + trx->free(); } if (!cache->stopword_info.cached_stopword) { diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index 490cbcd4546..419fc6e0011 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -1014,7 +1014,7 @@ fts_table_fetch_doc_ids( } if (alloc_bk_trx) { - trx_free(trx); + trx->free(); } return(error); @@ -1716,7 +1716,8 @@ fts_optimize_free( mem_heap_t* heap = static_cast<mem_heap_t*>(optim->self_heap->arg); trx_commit_for_mysql(optim->trx); - trx_free(optim->trx); + optim->trx->free(); + optim->trx = NULL; fts_doc_ids_free(optim->to_delete); fts_optimize_graph_free(&optim->graph); diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index 2f6cd1a51a3..4baba419ff7 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -4123,7 +4123,7 @@ fts_query( func_exit: fts_query_free(&query); - trx_free(query_trx); + query_trx->free(); return(error); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a43293991ac..22e77764f91 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2373,18 +2373,6 @@ trx_is_registered_for_2pc( } /*********************************************************************//** -Note that innobase_commit_ordered() was run. */ -static inline -void -trx_set_active_commit_ordered( -/*==========================*/ - trx_t* trx) /* in: transaction */ -{ - ut_a(trx_is_registered_for_2pc(trx)); - trx->active_commit_ordered = 1; -} - -/*********************************************************************//** Note that a transaction has been registered with MySQL 2PC coordinator. */ static inline void @@ -2393,7 +2381,7 @@ trx_register_for_2pc( trx_t* trx) /* in: transaction */ { trx->is_registered = 1; - ut_ad(trx->active_commit_ordered == 0); + ut_ad(!trx->active_commit_ordered); } /*********************************************************************//** @@ -2404,19 +2392,8 @@ trx_deregister_from_2pc( /*====================*/ trx_t* trx) /* in: transaction */ { - trx->is_registered = 0; - trx->active_commit_ordered = 0; -} - -/*********************************************************************//** -Check whether a transaction has active_commit_ordered set */ -static inline -bool -trx_is_active_commit_ordered( -/*=========================*/ - const trx_t* trx) /* in: transaction */ -{ - return(trx->active_commit_ordered == 1); + trx->is_registered= false; + trx->active_commit_ordered= false; } /*********************************************************************//** @@ -4001,9 +3978,8 @@ innobase_end(handlerton*, ha_panic_function) if (srv_was_started) { THD *thd= current_thd; if (thd) { // may be UNINSTALL PLUGIN statement - trx_t* trx = thd_to_trx(thd); - if (trx) { - trx_free(trx); + if (trx_t* trx = thd_to_trx(thd)) { + trx->free(); } } @@ -4189,8 +4165,7 @@ innobase_commit_ordered( (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))); innobase_commit_ordered_2(trx, thd); - - trx_set_active_commit_ordered(trx); + trx->active_commit_ordered = true; DBUG_VOID_RETURN; } @@ -4243,7 +4218,7 @@ innobase_commit( DBUG_SUICIDE();); /* Run the fast part of commit if we did not already. */ - if (!trx_is_active_commit_ordered(trx)) { + if (!trx->active_commit_ordered) { innobase_commit_ordered_2(trx, thd); } @@ -4672,7 +4647,7 @@ static int innobase_close_connection(handlerton *hton, THD *thd) return 0; } innobase_rollback_trx(trx); - trx_free(trx); + trx->free(); } return 0; } @@ -12838,7 +12813,7 @@ create_table_info_t::create_table_update_dict() if (m_flags2 & DICT_TF2_FTS) { if (!innobase_fts_load_stopword(innobase_table, NULL, m_thd)) { dict_table_close(innobase_table, FALSE, FALSE); - trx_free(m_trx); + m_trx->free(); DBUG_RETURN(-1); } @@ -12969,7 +12944,7 @@ ha_innobase::create( trx_rollback_for_mysql(trx); row_mysql_unlock_data_dictionary(trx); if (own_trx) { - trx_free(trx); + trx->free(); } DBUG_RETURN(error); } @@ -12978,7 +12953,7 @@ ha_innobase::create( row_mysql_unlock_data_dictionary(trx); if (own_trx) { - trx_free(trx); + trx->free(); } /* Flush the log to reduce probability that the .frm files and @@ -13331,7 +13306,7 @@ inline int ha_innobase::delete_table(const char* name, enum_sql_command sqlcom) innobase_commit_low(trx); - trx_free(trx); + trx->free(); DBUG_RETURN(convert_error_code_to_mysql(err, 0, NULL)); } @@ -13431,7 +13406,7 @@ innobase_drop_database( innobase_commit_low(trx); - trx_free(trx); + trx->free(); } /** Rename an InnoDB table. @@ -13608,7 +13583,7 @@ int ha_innobase::truncate() || dict_table_is_file_per_table(ib_table), trx); } - trx_free(trx); + trx->free(); if (!err) { /* Reopen the newly created table, and drop the @@ -13671,7 +13646,7 @@ ha_innobase::rename_table( innobase_commit_low(trx); - trx_free(trx); + trx->free(); if (error == DB_SUCCESS) { char norm_from[MAX_FULL_NAME_LEN]; @@ -17090,7 +17065,7 @@ innobase_commit_by_xid( ut_ad(trx->mysql_thd == NULL); trx_deregister_from_2pc(trx); ut_ad(!trx->will_lock); /* trx cache requirement */ - trx_free(trx); + trx->free(); return(XA_OK); } else { @@ -17127,7 +17102,7 @@ int innobase_rollback_by_xid(handlerton* hton, XID* xid) #endif /* WITH_WSREP */ int ret = innobase_rollback_trx(trx); ut_ad(!trx->will_lock); - trx_free(trx); + trx->free(); return(ret); } else { diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 9dd680aa188..ceda6187374 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4054,7 +4054,7 @@ online_retry_drop_indexes( online_retry_drop_indexes_low(table, trx); trx_commit_for_mysql(trx); row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); } ut_d(mutex_enter(&dict_sys.mutex)); @@ -7163,7 +7163,7 @@ err_exit: if (ctx->trx) { row_mysql_unlock_data_dictionary(ctx->trx); - trx_free(ctx->trx); + ctx->trx->free(); } trx_commit_for_mysql(ctx->prebuilt->trx); @@ -8730,7 +8730,8 @@ rollback_inplace_alter_table( trx_commit_for_mysql(ctx->trx); row_mysql_unlock_data_dictionary(ctx->trx); - trx_free(ctx->trx); + ctx->trx->free(); + ctx->trx = NULL; func_exit: #ifndef DBUG_OFF @@ -11101,7 +11102,7 @@ foreign_fail: row_mysql_unlock_data_dictionary(trx); if (trx != ctx0->trx) { - trx_free(trx); + trx->free(); } DBUG_RETURN(true); } @@ -11120,7 +11121,8 @@ foreign_fail: = static_cast<ha_innobase_inplace_ctx*>(*pctx); if (ctx->trx) { - trx_free(ctx->trx); + ctx->trx->free(); + ctx->trx = NULL; } } @@ -11168,7 +11170,7 @@ foreign_fail: } row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); MONITOR_ATOMIC_DEC(MONITOR_PENDING_ALTER_TABLE); DBUG_RETURN(false); } @@ -11289,7 +11291,7 @@ foreign_fail: } row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); /* TODO: The following code could be executed while allowing concurrent access to the table diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 897bda85d9b..125456c1ad4 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -2446,7 +2446,7 @@ i_s_fts_deleted_generic_fill( rw_lock_s_unlock(&dict_sys.latch); - trx_free(trx); + trx->free(); fields = table->field; @@ -2992,7 +2992,7 @@ i_s_fts_index_table_fill_selected( que_graph_free(graph); mutex_exit(&dict_sys.mutex); - trx_free(trx); + trx->free(); if (fetch.total_memory >= fts_result_cache_limit) { error = DB_FTS_EXCEED_RESULT_CACHE_LIMIT; @@ -3470,7 +3470,7 @@ no_fts: rw_lock_s_unlock(&dict_sys.latch); - trx_free(trx); + trx->free(); DBUG_RETURN(ret); } diff --git a/storage/innobase/include/fts0ast.h b/storage/innobase/include/fts0ast.h index bad040fdcda..3dca92235c7 100644 --- a/storage/innobase/include/fts0ast.h +++ b/storage/innobase/include/fts0ast.h @@ -29,14 +29,6 @@ Created 2007/03/16/03 Sunny Bains #include "mem0mem.h" -#ifdef UNIV_PFS_MEMORY - -#define malloc(A) ut_malloc_nokey(A) -#define free(A) ut_free(A) -#define realloc(P, A) ut_realloc(P, A) - -#endif /* UNIV_PFS_MEMORY */ - /* The type of AST Node */ enum fts_ast_type_t { FTS_AST_OPER, /*!< Operator */ diff --git a/storage/innobase/include/read0types.h b/storage/innobase/include/read0types.h index de3ff927520..21143ab609d 100644 --- a/storage/innobase/include/read0types.h +++ b/storage/innobase/include/read0types.h @@ -279,22 +279,15 @@ public: /** - Make the memory accessible by innodb_monitor_set_option; - It is operating also on freed transaction objects. + Declare the object mostly unaccessible. + innodb_monitor_set_option is operating also on freed transaction objects. */ - void mem_valid() const + void mem_noaccess() const { - /* Cancel the effect of MEM_NOACCESS(). */ -#ifdef __SANITIZE_ADDRESS__ - MEM_MAKE_ADDRESSABLE(&m_mutex, sizeof m_mutex); -#endif -#if defined HAVE_valgrind && !__has_feature(memory_sanitizer) - /* In Valgrind, we cannot cancel MEM_NOACCESS() without changing - the state of the V bits (indicating which bits are initialized). - We will declare the contents as initialized. - We did invoke MEM_CHECK_DEFINED() in trx_pools->mem_free(). */ - MEM_MAKE_DEFINED(&m_mutex, sizeof m_mutex); -#endif + MEM_NOACCESS(&m_open, sizeof m_open); + /* m_mutex is accessed by innodb_show_mutex_status() + and innodb_monitor_update() even after trx_t::free() */ + MEM_NOACCESS(&m_creator_trx_id, sizeof m_creator_trx_id); } }; #endif diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index d91e77f9a52..acb10428108 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -572,7 +572,7 @@ public: Releases LF_HASH pins. Must be called by thread that owns trx_t object when the latter is being - "detached" from thread (e.g. released to the pool by trx_free()). Can be + "detached" from thread (e.g. released to the pool by trx_t::free()). Can be called earlier if thread is expected not to use rw_trx_hash. Since pins are not allowed to be transferred to another thread, diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 20043a6c4a4..2294025a1aa 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -68,27 +68,18 @@ trx_get_error_info( /*===============*/ const trx_t* trx); /*!< in: trx object */ -/** @return a trx_t instance from trx_pools. */ +/** @return an allocated transaction */ trx_t *trx_create(); -/** - Release a trx_t instance back to the pool. - @param trx the instance to release. -*/ -void trx_free(trx_t*& trx); - /** At shutdown, frees a transaction object. */ -void -trx_free_at_shutdown(trx_t *trx); +void trx_free_at_shutdown(trx_t *trx); /** Disconnect a prepared transaction from MySQL. @param[in,out] trx transaction */ -void -trx_disconnect_prepared(trx_t* trx); +void trx_disconnect_prepared(trx_t *trx); /** Initialize (resurrect) transactions at startup. */ -void -trx_lists_init_at_db_start(); +void trx_lists_init_at_db_start(); /*************************************************************//** Starts the transaction if it is not yet started. */ @@ -840,7 +831,8 @@ public: the coordinator using the XA API, and is set to false after commit or rollback. */ - unsigned active_commit_ordered:1;/* 1 if owns prepare mutex */ + /** whether this is holding the prepare mutex */ + bool active_commit_ordered; /*------------------------------*/ bool check_unique_secondary; /*!< normally TRUE, but if the user @@ -1095,6 +1087,9 @@ public: ut_ad(old_n_ref > 0); } + /** Free the memory to trx_pools */ + void free(); + void assert_freed() const { diff --git a/storage/innobase/include/ut0pool.h b/storage/innobase/include/ut0pool.h index c31633e7f4c..e0a1f7c04ca 100644 --- a/storage/innobase/include/ut0pool.h +++ b/storage/innobase/include/ut0pool.h @@ -87,19 +87,6 @@ struct Pool { for (Element* elem = m_start; elem != m_last; ++elem) { ut_ad(elem->m_pool == this); -#ifdef __SANITIZE_ADDRESS__ - /* Unpoison the memory for AddressSanitizer */ - MEM_MAKE_ADDRESSABLE(&elem->m_type, - sizeof elem->m_type); -#endif -#if defined HAVE_valgrind && !__has_feature(memory_sanitizer) - /* In Valgrind, we cannot cancel MEM_NOACCESS() without - changing the state of the V bits (which indicate - which bits are initialized). - We will declare the contents as initialized. - We did invoke MEM_CHECK_DEFINED() in mem_free(). */ - MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type); -#endif Factory::destroy(&elem->m_type); } @@ -134,24 +121,6 @@ struct Pool { elem = NULL; } -#if defined HAVE_valgrind || defined __SANITIZE_ADDRESS__ - if (elem) { -# ifdef __SANITIZE_ADDRESS__ - /* Unpoison the memory for AddressSanitizer */ - MEM_MAKE_ADDRESSABLE(&elem->m_type, - sizeof elem->m_type); -# endif -# if defined HAVE_valgrind && !__has_feature(memory_sanitizer) - /* In Valgrind, we cannot cancel MEM_NOACCESS() without - changing the state of the V bits (which indicate - which bits are initialized). - We will declare the contents as initialized. - We did invoke MEM_CHECK_DEFINED() in mem_free(). */ - MEM_MAKE_DEFINED(&elem->m_type, sizeof elem->m_type); -# endif - } -#endif - m_lock_strategy.exit(); return elem ? &elem->m_type : NULL; } @@ -164,12 +133,10 @@ struct Pool { byte* p = reinterpret_cast<byte*>(ptr + 1); elem = reinterpret_cast<Element*>(p - sizeof(*elem)); - MEM_CHECK_DEFINED(&elem->m_type, sizeof elem->m_type); elem->m_pool->m_lock_strategy.enter(); elem->m_pool->putl(elem); - MEM_NOACCESS(&elem->m_type, sizeof elem->m_type); elem->m_pool->m_lock_strategy.exit(); } @@ -192,9 +159,6 @@ private: void putl(Element* elem) { ut_ad(elem >= m_start && elem < m_last); - - ut_ad(Factory::debug(&elem->m_type)); - m_pqueue.push(elem); } diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 29197fde46b..baf63650347 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1769,7 +1769,7 @@ exit: error = ins_ctx.btr_bulk->finish(error); UT_DELETE(ins_ctx.btr_bulk); - trx_free(trx); + trx->free(); mem_heap_free(heap); diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 9fc7425957a..2ec0a06709e 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -2200,7 +2200,7 @@ row_import_cleanup( row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); prebuilt->trx->op_info = ""; diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 3e0ffcf28b9..4f4329082fe 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -4030,7 +4030,7 @@ row_merge_drop_temp_indexes(void) trx_commit_for_mysql(trx); row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index ee98c327055..42ed2aaf415 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -2568,7 +2568,7 @@ row_drop_table_for_mysql_in_background( trx_commit_for_mysql(trx); - trx_free(trx); + trx->free(); return(error); } @@ -2752,7 +2752,7 @@ row_mysql_drop_garbage_tables() btr_pcur_close(&pcur); mtr.commit(); row_mysql_unlock_data_dictionary(trx); - trx_free(trx); + trx->free(); mem_heap_free(heap); } @@ -4602,7 +4602,7 @@ funct_exit: trx_bg->dict_operation_lock_mode = 0; trx_commit_for_mysql(trx_bg); - trx_free(trx_bg); + trx_bg->free(); } if (table != NULL) { diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 6747ada6de4..3f1d4258484 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -192,7 +192,7 @@ void purge_sys_t::close() ut_ad(!trx->id); ut_ad(trx->state == TRX_STATE_ACTIVE); trx->state= TRX_STATE_NOT_STARTED; - trx_free(trx); + trx->free(); rw_lock_free(&latch); mutex_free(&pq_mutex); mem_heap_free(heap); diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index a16ee95dc83..dc3dd51bb89 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -807,7 +807,7 @@ discard: trx_free_at_shutdown(trx); } else - trx_free(trx); + trx->free(); } } } diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 812e4861a4e..d1f6a66f09b 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -110,7 +110,7 @@ trx_init( trx->op_info = ""; - trx->active_commit_ordered = 0; + trx->active_commit_ordered = false; trx->isolation_level = TRX_ISO_REPEATABLE_READ; @@ -210,6 +210,18 @@ struct TrxFactory { @param trx the transaction for which to release resources */ static void destroy(trx_t* trx) { +#ifdef __SANITIZE_ADDRESS__ + /* Unpoison the memory for AddressSanitizer */ + MEM_MAKE_ADDRESSABLE(trx, sizeof *trx); +#elif !__has_feature(memory_sanitizer) + /* In Valgrind, we cannot cancel MEM_NOACCESS() without + changing the state of the V bits (which indicate + which bits are initialized). + We will declare the contents as initialized. + We did invoke MEM_CHECK_DEFINED() in trx_t::free(). */ + MEM_MAKE_DEFINED(trx, sizeof *trx); +#endif + ut_a(trx->magic_n == TRX_MAGIC_N); ut_ad(!trx->mysql_thd); @@ -238,36 +250,6 @@ struct TrxFactory { trx->read_view.~ReadView(); } - - /** Enforce any invariants here, this is called before the transaction - is added to the pool. - @return true if all OK */ - static bool debug(const trx_t* trx) - { - ut_a(trx->error_state == DB_SUCCESS); - - ut_a(trx->magic_n == TRX_MAGIC_N); - - ut_ad(!trx->read_only); - - ut_ad(trx->state == TRX_STATE_NOT_STARTED); - - ut_ad(trx->dict_operation == TRX_DICT_OP_NONE); - - ut_ad(trx->mysql_thd == 0); - - ut_a(trx->lock.wait_thr == NULL); - ut_a(trx->lock.wait_lock == NULL); - ut_a(trx->dict_operation_lock_mode == 0); - - ut_a(UT_LIST_GET_LEN(trx->lock.trx_locks) == 0); - - ut_ad(trx->autoinc_locks == NULL); - - ut_ad(trx->lock.table_locks.empty()); - - return(true); - } }; /** The lock strategy for TrxPool */ @@ -344,11 +326,24 @@ trx_pool_close() trx_pools = 0; } -/** @return a trx_t instance from trx_pools. */ +/** @return an allocated transaction */ trx_t *trx_create() { trx_t* trx = trx_pools->get(); +#ifdef __SANITIZE_ADDRESS__ + /* Unpoison the memory for AddressSanitizer. + It may have been poisoned in trx_t::free().*/ + MEM_MAKE_ADDRESSABLE(trx, sizeof *trx); +#elif !__has_feature(memory_sanitizer) + /* In Valgrind, we cannot cancel MEM_NOACCESS() without + changing the state of the V bits (which indicate + which bits are initialized). + We will declare the contents as initialized. + We did invoke MEM_CHECK_DEFINED() in trx_t::free(). */ + MEM_MAKE_DEFINED(trx, sizeof *trx); +#endif + trx->assert_freed(); mem_heap_t* heap; @@ -364,14 +359,9 @@ trx_t *trx_create() alloc = ib_heap_allocator_create(heap); - /* Remember to free the vector explicitly in trx_free(). */ trx->autoinc_locks = ib_vector_create(alloc, sizeof(void**), 4); - /* Should have been either just initialized or .clear()ed by - trx_free(). */ ut_ad(trx->mod_tables.empty()); - ut_ad(trx->lock.table_locks.empty()); - ut_ad(UT_LIST_GET_LEN(trx->lock.trx_locks) == 0); ut_ad(trx->lock.n_rec_locks == 0); ut_ad(trx->lock.table_cached == 0); ut_ad(trx->lock.rec_cached == 0); @@ -382,83 +372,101 @@ trx_t *trx_create() return(trx); } -/** - Release a trx_t instance back to the pool. - @param trx the instance to release. -*/ -void trx_free(trx_t*& trx) +/** Free the memory to trx_pools */ +void trx_t::free() { - ut_ad(!trx->n_mysql_tables_in_use); - ut_ad(!trx->mysql_n_tables_locked); - ut_ad(!trx->internal); - ut_ad(!trx->mysql_log_file_name); - - if (trx->n_mysql_tables_in_use != 0 - || trx->mysql_n_tables_locked != 0) { - - ib::error() << "MySQL is freeing a thd though" - " trx->n_mysql_tables_in_use is " - << trx->n_mysql_tables_in_use - << " and trx->mysql_n_tables_locked is " - << trx->mysql_n_tables_locked << "."; - - trx_print(stderr, trx, 600); - ut_print_buf(stderr, trx, sizeof(trx_t)); - putc('\n', stderr); - } - - trx->dict_operation = TRX_DICT_OP_NONE; - ut_ad(!trx->dict_operation_lock_mode); - - trx_sys.deregister_trx(trx); - - trx->assert_freed(); + MEM_CHECK_DEFINED(this, sizeof *this); + + ut_ad(!n_mysql_tables_in_use); + ut_ad(!mysql_log_file_name); + ut_ad(!mysql_n_tables_locked); + ut_ad(!internal); + ut_ad(!will_lock); + ut_ad(error_state == DB_SUCCESS); + ut_ad(magic_n == TRX_MAGIC_N); + ut_ad(!read_only); + ut_ad(!lock.wait_lock); - trx_sys.rw_trx_hash.put_pins(trx); - trx->mysql_thd = 0; - - // FIXME: We need to avoid this heap free/alloc for each commit. - if (trx->autoinc_locks != NULL) { - ut_ad(ib_vector_is_empty(trx->autoinc_locks)); - /* We allocated a dedicated heap for the vector. */ - ib_vector_free(trx->autoinc_locks); - trx->autoinc_locks = NULL; - } + dict_operation= TRX_DICT_OP_NONE; + trx_sys.deregister_trx(this); + assert_freed(); + trx_sys.rw_trx_hash.put_pins(this); - trx->mod_tables.clear(); + mysql_thd= nullptr; - /* trx locking state should have been reset before returning trx - to pool */ - ut_ad(trx->will_lock == 0); - - trx_pools->mem_free(trx); - trx->read_view.mem_valid(); -#ifdef __SANITIZE_ADDRESS__ - /* Unpoison the memory for innodb_monitor_set_option; - it is operating also on the freed transaction objects. */ - MEM_MAKE_ADDRESSABLE(&trx->mutex, sizeof trx->mutex); -# ifdef WITH_WSREP - MEM_MAKE_ADDRESSABLE(&trx->wsrep, sizeof trx->wsrep); -# endif - /* For innobase_kill_connection() */ - MEM_MAKE_ADDRESSABLE(&trx->state, sizeof trx->state); - MEM_MAKE_ADDRESSABLE(&trx->mysql_thd, sizeof trx->mysql_thd); -#endif -#if defined HAVE_valgrind && !__has_feature(memory_sanitizer) - /* In Valgrind, we cannot cancel the effect of MEM_NOACCESS() - without changing the state of the V bits (indicating which - bits are initialized). We did invoke MEM_CHECK_DEFINED() in - trx_pools->mem_free(). */ - MEM_MAKE_DEFINED(&trx->mutex, sizeof trx->mutex); - /* For innobase_kill_connection() */ -# ifdef WITH_WSREP - MEM_MAKE_DEFINED(&trx->wsrep, sizeof trx->wsrep); -# endif - MEM_MAKE_DEFINED(&trx->state, sizeof trx->state); - MEM_MAKE_DEFINED(&trx->mysql_thd, sizeof trx->mysql_thd); -#endif + // FIXME: We need to avoid this heap free/alloc for each commit. + if (autoinc_locks) + { + ut_ad(ib_vector_is_empty(autoinc_locks)); + /* We allocated a dedicated heap for the vector. */ + ib_vector_free(autoinc_locks); + autoinc_locks= NULL; + } - trx = NULL; + mod_tables.clear(); + + MEM_NOACCESS(&n_ref, sizeof n_ref); + /* do not poison mutex */ + MEM_NOACCESS(&id, sizeof id); + /* state is accessed by innobase_kill_connection() */ + MEM_NOACCESS(&is_recovered, sizeof is_recovered); + /* wsrep is accessed by innobase_kill_connection() */ + read_view.mem_noaccess(); + MEM_NOACCESS(&lock, sizeof lock); + MEM_NOACCESS(&op_info, sizeof op_info); + MEM_NOACCESS(&isolation_level, sizeof isolation_level); + MEM_NOACCESS(&check_foreigns, sizeof check_foreigns); + MEM_NOACCESS(&is_registered, sizeof is_registered); + MEM_NOACCESS(&active_commit_ordered, sizeof active_commit_ordered); + MEM_NOACCESS(&check_unique_secondary, sizeof check_unique_secondary); + MEM_NOACCESS(&flush_log_later, sizeof flush_log_later); + MEM_NOACCESS(&must_flush_log_later, sizeof must_flush_log_later); + MEM_NOACCESS(&duplicates, sizeof duplicates); + MEM_NOACCESS(&dict_operation, sizeof dict_operation); + MEM_NOACCESS(&dict_operation_lock_mode, sizeof dict_operation_lock_mode); + MEM_NOACCESS(&start_time, sizeof start_time); + MEM_NOACCESS(&start_time_micro, sizeof start_time_micro); + MEM_NOACCESS(&commit_lsn, sizeof commit_lsn); + MEM_NOACCESS(&table_id, sizeof table_id); + /* mysql_thd is accessed by innobase_kill_connection() */ + MEM_NOACCESS(&mysql_log_file_name, sizeof mysql_log_file_name); + MEM_NOACCESS(&mysql_log_offset, sizeof mysql_log_offset); + MEM_NOACCESS(&n_mysql_tables_in_use, sizeof n_mysql_tables_in_use); + MEM_NOACCESS(&mysql_n_tables_locked, sizeof mysql_n_tables_locked); + MEM_NOACCESS(&error_state, sizeof error_state); + MEM_NOACCESS(&error_info, sizeof error_info); + MEM_NOACCESS(&error_key_num, sizeof error_key_num); + MEM_NOACCESS(&graph, sizeof graph); + MEM_NOACCESS(&trx_savepoints, sizeof trx_savepoints); + MEM_NOACCESS(&undo_no, sizeof undo_no); + MEM_NOACCESS(&last_sql_stat_start, sizeof last_sql_stat_start); + MEM_NOACCESS(&rsegs, sizeof rsegs); + MEM_NOACCESS(&roll_limit, sizeof roll_limit); + MEM_NOACCESS(&in_rollback, sizeof in_rollback); + MEM_NOACCESS(&pages_undone, sizeof pages_undone); + MEM_NOACCESS(&n_autoinc_rows, sizeof n_autoinc_rows); + MEM_NOACCESS(&autoinc_locks, sizeof autoinc_locks); + MEM_NOACCESS(&read_only, sizeof read_only); + MEM_NOACCESS(&auto_commit, sizeof auto_commit); + MEM_NOACCESS(&will_lock, sizeof will_lock); + MEM_NOACCESS(&fts_trx, sizeof fts_trx); + MEM_NOACCESS(&fts_next_doc_id, sizeof fts_next_doc_id); + MEM_NOACCESS(&flush_tables, sizeof flush_tables); + MEM_NOACCESS(&ddl, sizeof ddl); + MEM_NOACCESS(&internal, sizeof internal); +#ifdef UNIV_DEBUG + MEM_NOACCESS(&start_line, sizeof start_line); + MEM_NOACCESS(&start_file, sizeof start_file); +#endif /* UNIV_DEBUG */ + MEM_NOACCESS(&xid, sizeof xid); + MEM_NOACCESS(&mod_tables, sizeof mod_tables); + MEM_NOACCESS(&detailed_error, sizeof detailed_error); + MEM_NOACCESS(&n_rec_lock_waits, sizeof n_rec_lock_waits); + MEM_NOACCESS(&n_table_lock_waits, sizeof n_table_lock_waits); + MEM_NOACCESS(&total_rec_lock_wait_time, sizeof total_rec_lock_wait_time); + MEM_NOACCESS(&total_table_lock_wait_time, sizeof total_table_lock_wait_time); + MEM_NOACCESS(&magic_n, sizeof magic_n); + trx_pools->mem_free(this); } /** Transition to committed state, to release implicit locks. */ @@ -530,8 +538,7 @@ trx_free_at_shutdown(trx_t *trx) trx->state = TRX_STATE_NOT_STARTED; ut_ad(!UT_LIST_GET_LEN(trx->lock.trx_locks)); trx->id = 0; - - trx_free(trx); + trx->free(); } diff --git a/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc b/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc index 4250b368b1a..81cd2200ae0 100644 --- a/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc +++ b/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc @@ -15,7 +15,7 @@ if ($rpl_inited) # Send shutdown to the connected server and give # it 10 seconds to die before zapping it -shutdown_server 10; +shutdown_server; # Write file to make mysql-test-run.pl start up the server again --exec echo "restart:$_mysqld_option" > $_expect_file_name diff --git a/storage/rocksdb/mysql-test/rocksdb/t/check_ignore_unknown_options.test b/storage/rocksdb/mysql-test/rocksdb/t/check_ignore_unknown_options.test index c8c12626139..15a7d319c04 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/check_ignore_unknown_options.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/check_ignore_unknown_options.test @@ -41,7 +41,7 @@ perl; EOF --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect ---shutdown_server 10 +--shutdown_server --error 1 --exec $MYSQLD_CMD --plugin_load=$HA_ROCKSDB_SO --rocksdb_ignore_unknown_options=0 --log-error=$error_log diff --git a/storage/rocksdb/mysql-test/rocksdb/t/insert_optimized_config.test b/storage/rocksdb/mysql-test/rocksdb/t/insert_optimized_config.test index 46ea7f0eb0a..a24851d9d8c 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/insert_optimized_config.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/insert_optimized_config.test @@ -8,7 +8,7 @@ DROP TABLE IF EXISTS t1; # reload with load optimized config let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; --exec echo "wait" > $restart_file ---shutdown_server 10 +--shutdown_server --source include/wait_until_disconnected.inc -- exec echo "restart:--rocksdb_write_disable_wal=1 --rocksdb_flush_log_at_trx_commit=0 --rocksdb_default_cf_options=write_buffer_size=16k;target_file_size_base=16k;level0_file_num_compaction_trigger=4;level0_slowdown_writes_trigger=256;level0_stop_writes_trigger=256;max_write_buffer_number=16;compression_per_level=kNoCompression;memtable=vector:1024 --rocksdb_override_cf_options=__system__={memtable=skip_list:16} --rocksdb_compaction_sequential_deletes=0 --rocksdb_compaction_sequential_deletes_window=0 --rocksdb_allow_concurrent_memtable_write=0" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -- enable_reconnect @@ -39,7 +39,7 @@ select count(*), sum(id), sum(i1), sum(i2) from t1; # reload without load optimized config let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; --exec echo "wait" > $restart_file ---shutdown_server 10 +--shutdown_server --source include/wait_until_disconnected.inc -- exec echo "restart:--rocksdb_write_disable_wal=0 --rocksdb_default_cf_options=write_buffer_size=64k;target_file_size_base=64k;max_bytes_for_level_base=1m;compression_per_level=kNoCompression;" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -- enable_reconnect diff --git a/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2.test b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2.test index ca9eb5d2ecf..4f4f5ed092b 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/mysqldump2.test @@ -21,7 +21,7 @@ optimize table t1; #wiping block cache let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; --exec echo "wait" > $restart_file ---shutdown_server 10 +--shutdown_server --source include/wait_until_disconnected.inc -- exec echo "restart:--rocksdb_default_cf_options=write_buffer_size=64k;target_file_size_base=64k;max_bytes_for_level_base=1m;compression_per_level=kNoCompression;disable_auto_compactions=true;level0_stop_writes_trigger=1000 " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -- enable_reconnect diff --git a/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.test b/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.test index 7a8f4fc7085..50df3f9c102 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/optimize_table.test @@ -32,7 +32,7 @@ while ($t <= 6) { # Disable auto compaction so that effects of optimize table are stable let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; --exec echo "wait" > $restart_file ---shutdown_server 10 +--shutdown_server --source include/wait_until_disconnected.inc -- exec echo "restart:--rocksdb_default_cf_options=write_buffer_size=64k;target_file_size_base=64k;max_bytes_for_level_base=1m;compression_per_level=kNoCompression;disable_auto_compactions=true;level0_stop_writes_trigger=1000 " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -- enable_reconnect diff --git a/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test b/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test index 03d1d0a60bc..49e5e5c1172 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test @@ -10,7 +10,7 @@ DROP TABLE IF EXISTS t1; --exec echo "wait" >$_expect_file_name # restart server with correct parameters -shutdown_server 10; +shutdown_server; --exec echo "restart:--rocksdb_persistent_cache_path=$_cache_file_name --rocksdb_persistent_cache_size_mb=100" >$_expect_file_name --sleep 5 --enable_reconnect @@ -28,7 +28,7 @@ select * from t1 where a = 1; # restart server to re-read cache --exec echo "wait" >$_expect_file_name -shutdown_server 10; +shutdown_server; --exec echo "restart:--rocksdb_persistent_cache_path=$_cache_file_name --rocksdb_persistent_cache_size_mb=100" >$_expect_file_name --sleep 5 --enable_reconnect diff --git a/storage/rocksdb/mysql-test/rocksdb/t/shutdown.test b/storage/rocksdb/mysql-test/rocksdb/t/shutdown.test index ba625deb514..f76bc9f6153 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/shutdown.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/shutdown.test @@ -23,7 +23,7 @@ while ($i <= $max) { # Restart the server let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; --exec echo "wait" > $restart_file ---shutdown_server 10 +--shutdown_server --source include/wait_until_disconnected.inc -- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -- enable_reconnect diff --git a/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test b/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test index ec48dc03ec8..e7ab37d2658 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test @@ -25,7 +25,7 @@ CREATE TABLE t2 (pk int primary key) ENGINE=ROCKSDB PARTITION BY KEY(pk) PARTITI # Send shutdown to the connected server and give it 10 seconds to die before # zapping it -shutdown_server 10; +shutdown_server; # Write file to make mysql-test-run.pl start up the server again --exec echo "restart" >$_expect_file_name @@ -42,7 +42,7 @@ shutdown_server 10; # Now shut down again and rename one of the .frm files --exec echo "wait" >$_expect_file_name -shutdown_server 10; +shutdown_server; # Rename the file --move_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t1.frm $MYSQLTEST_VARDIR/mysqld.1/data/test/t1.frm.tmp @@ -70,7 +70,7 @@ shutdown_server 10; # Now shut down again and rename one the .frm file back and make a copy of it --exec echo "wait" >$_expect_file_name -shutdown_server 10; +shutdown_server; --remove_file $LOG # Rename the file --move_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t1.frm.tmp $MYSQLTEST_VARDIR/mysqld.1/data/test/t1.frm @@ -92,7 +92,7 @@ shutdown_server 10; # Shut down an clean up --exec echo "wait" >$_expect_file_name -shutdown_server 10; +shutdown_server; --remove_file $MYSQLTEST_VARDIR/mysqld.1/data/test/t1_dummy.frm --exec echo "restart" >$_expect_file_name --enable_reconnect diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/mdev12179.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/mdev12179.test index 631d9ca533f..845f155877a 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/mdev12179.test +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/mdev12179.test @@ -237,7 +237,7 @@ SHOW STATUS LIKE "%transactions%engine"; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc # Restart without binary log. diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test index 8277011831a..743f942af9c 100644 --- a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test +++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test @@ -13,7 +13,7 @@ SET @@global.rocksdb_rate_limiter_bytes_per_sec = 10000; # Send shutdown to the connected server and give it 10 seconds to die before # zapping it -shutdown_server 10; +shutdown_server; # Attempt to restart the server with the rate limiter on --exec echo "restart:--rocksdb_rate_limiter_bytes_per_sec=10000" >$_expect_file_name @@ -53,7 +53,7 @@ SET @@global.rocksdb_rate_limiter_bytes_per_sec = -1; # Restart the server without the rate limiter --exec echo "wait" >$_expect_file_name -shutdown_server 10; +shutdown_server; --exec echo "restart" >$_expect_file_name --sleep 5 diff --git a/storage/tokudb/mysql-test/tokudb_rpl/t/mdev12179.test b/storage/tokudb/mysql-test/tokudb_rpl/t/mdev12179.test index 1d19a25889e..a87da95a220 100644 --- a/storage/tokudb/mysql-test/tokudb_rpl/t/mdev12179.test +++ b/storage/tokudb/mysql-test/tokudb_rpl/t/mdev12179.test @@ -237,7 +237,7 @@ SHOW STATUS LIKE "%transactions%engine"; --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect wait EOF ---shutdown_server 30 +--shutdown_server --source include/wait_until_disconnected.inc # Restart without binary log. |