diff options
-rw-r--r-- | sql/handler.cc | 18 | ||||
-rw-r--r-- | sql/handler.h | 2 | ||||
-rw-r--r-- | sql/sql_repl.cc | 3 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 1 | ||||
-rw-r--r-- | storage/innobase/include/trx0rseg.h | 8 | ||||
-rw-r--r-- | storage/innobase/trx/trx0rseg.cc | 43 |
6 files changed, 71 insertions, 4 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 6bd8938fdca..e6adb4fdd93 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -747,6 +747,22 @@ void ha_drop_database(char* path) } +static my_bool reset_master_handlerton(THD *, plugin_ref plugin, void *) +{ + handlerton *hton= plugin_hton(plugin); + if (hton->reset_master) + hton->reset_master(); + return FALSE; +} + + +void ha_reset_master() +{ + plugin_foreach(NULL, reset_master_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, + NULL); +} + + static my_bool checkpoint_state_handlerton(THD *unused1, plugin_ref plugin, void *disable) { diff --git a/sql/handler.h b/sql/handler.h index 94c652359d2..ea3bd93c039 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1476,6 +1476,7 @@ struct handlerton int (*set_checkpoint)(handlerton *hton, const XID* xid); int (*get_checkpoint)(handlerton *hton, XID* xid); void (*fake_trx_id)(handlerton *hton, THD *thd); + void (*reset_master)(); /* Optional clauses in the CREATE/ALTER TABLE */ @@ -4765,6 +4766,7 @@ void ha_close_connection(THD* thd); void ha_kill_query(THD* thd, enum thd_kill_levels level); bool ha_flush_logs(handlerton *db_type); void ha_drop_database(char* path); +void ha_reset_master(); void ha_checkpoint_state(bool disable); void ha_commit_checkpoint_request(void *cookie, void (*pre_hook)(void *)); int ha_create_table(THD *thd, const char *path, diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index aa81d33f2e7..159c1946839 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation + Copyright (c) 2008, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3879,6 +3879,7 @@ int reset_master(THD* thd, rpl_gtid *init_state, uint32 init_state_len, repl_semisync_master.before_reset_master(); ret= mysql_bin_log.reset_logs(thd, 1, init_state, init_state_len, next_log_number); + ha_reset_master(); repl_semisync_master.after_reset_master(); return ret; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 411399153a7..938d6a79d47 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4165,6 +4165,7 @@ static int innodb_init(void* p) innobase_hton->get_checkpoint=innobase_wsrep_get_checkpoint; innobase_hton->fake_trx_id=wsrep_fake_trx_id; #endif /* WITH_WSREP */ + innobase_hton->reset_master= trx_rseg_reset_binlog_pos; innobase_hton->tablefile_extensions = ha_innobase_exts; innobase_hton->table_options = innodb_table_option_list; diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index d4fdb19a988..89741309445 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -113,6 +113,7 @@ trx_rseg_get_n_undo_tablespaces( /*============================*/ ulint* space_ids); /*!< out: array of space ids of UNDO tablespaces */ + /* Number of undo log slots in a rollback segment file copy */ #define TRX_RSEG_N_SLOTS (srv_page_size / 16) @@ -307,6 +308,11 @@ up to which replication has proceeded. void trx_rseg_update_binlog_offset(byte* rseg_header, const trx_t* trx, mtr_t* mtr); +/** Reset all persistent information for recovering +trx_sys.recovered_binlog_filename and trx_sys.recovered_binlog_offset. +Invoked on RESET MASTER. */ +void trx_rseg_reset_binlog_pos(); + #include "trx0rseg.ic" #endif diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index 46fb2680371..f9e473caf72 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -786,3 +786,44 @@ trx_rseg_update_binlog_offset(byte* rseg_header, const trx_t* trx, mtr_t* mtr) mlog_write_string(p, binlog_name, len, mtr); } } + +/** Reset all persistent information for recovering +trx_sys.recovered_binlog_filename and trx_sys.recovered_binlog_offset. +Invoked on RESET MASTER. */ +void trx_rseg_reset_binlog_pos() +{ + mtr_t mtr; + /* Invalidate the information on the TRX_SYS page. */ + mtr.start(); + if (const buf_block_t* sys= trx_sysf_get(&mtr, true)) + { + byte *magic= TRX_SYS + TRX_SYS_MYSQL_LOG_INFO + + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD + sys->frame; + if (mach_read_from_4(magic)) + mlog_write_ulint(magic, 0, MLOG_4BYTES, &mtr); + } + mtr.commit(); + + /* Invalidate the information on the rollback segment header pages. */ + for (ulint rseg_id= 0; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) + { + mtr.start(); + if (const buf_block_t* sys= trx_sysf_get(&mtr, false)) + { + const uint32_t page_no= trx_sysf_rseg_get_page_no(sys, rseg_id); + if (page_no != FIL_NULL) + { + const uint32_t space_id= trx_sysf_rseg_get_space(sys, rseg_id); + buf_block_t *block= buf_page_get(page_id_t(space_id, page_no), + univ_page_size, RW_X_LATCH, &mtr); + byte *name= TRX_RSEG + TRX_RSEG_BINLOG_NAME + block->frame; + if (*name) + mlog_write_ulint(name, 0, MLOG_1BYTE, &mtr); + } + } + mtr.commit(); + } + + /* Persist the change immediately. */ + log_write_up_to(mtr.commit_lsn(), true); +} |