From e9735a81859f172b73f75eccc043540a58d91cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 6 Apr 2022 08:06:49 +0300 Subject: MDEV-25975 innodb_disallow_writes causes shutdown to hang MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We will remove the parameter innodb_disallow_writes because it is badly designed and implemented. The parameter was never allowed at startup. It was only internally used by Galera snapshot transfer. If a user executed SET GLOBAL innodb_disallow_writes=ON; the server could hang even on subsequent read operations. During Galera snapshot transfer, we will block writes to implement an rsync friendly snapshot, as follows: sst_flush_tables() will acquire a global lock by executing FLUSH TABLES WITH READ LOCK, which will block any writes at the high level. sst_disable_innodb_writes(), invoked via ha_disable_internal_writes(true), will suspend or disable InnoDB background tasks or threads that could initiate writes. As part of this, log_make_checkpoint() will be invoked to ensure that anything in the InnoDB buf_pool.flush_list will be written to the data files. This has the nice side effect that the Galera joiner will avoid crash recovery. The changes to sql/wsrep.cc and to the tests are based on a prototype that was developed by Jan Lindström. Reviewed by: Jan Lindström --- sql/handler.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sql/handler.cc') diff --git a/sql/handler.cc b/sql/handler.cc index cad9019c969..e4c377451c6 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -849,6 +849,22 @@ void ha_kill_query(THD* thd, enum thd_kill_levels level) } +static my_bool plugin_disable_internal_writes(THD *, plugin_ref plugin, + void *disable) +{ + if (void(*diw)(bool)= plugin_hton(plugin)->disable_internal_writes) + diw(*static_cast(disable)); + return FALSE; +} + + +void ha_disable_internal_writes(bool disable) +{ + plugin_foreach(NULL, plugin_disable_internal_writes, + MYSQL_STORAGE_ENGINE_PLUGIN, &disable); +} + + /* ======================================================================== ======================= TRANSACTIONS ===================================*/ -- cgit v1.2.1