[MDEV-32798] innodb_fast_shutdown=0 hang after incomplete startup Created: 2023-11-14  Updated: 2023-11-14  Resolved: 2023-11-14

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.5, 10.6, 10.10, 10.11, 11.0, 11.1, 11.2, 11.3
Fix Version/s: 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3, 11.3.2

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: regression


 Description   

The following invocation will hang, because a recovered incomplete transaction exists but was not rolled back due to the fault injection innodb_log_abort_1:

./mtr --mysqld=--innodb-fast-shutdown=0 innodb.log_file_size

The following patch fixes the hang on 10.5:

diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 9b8ce4b2fa8..ca2e4ec1a86 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -1995,7 +1995,7 @@ void innodb_preshutdown()
     better prevent any further changes from being buffered. */
     innodb_change_buffering= 0;
 
-    if (trx_sys.is_initialised())
+    if (srv_was_started)
       while (trx_sys.any_active_transactions())
         os_thread_sleep(1000);
   }

The flag srv_was_started implies trx_sys.is_initialised(), because innodb_init() would only assign that flag after a successful srv_start(), which includes initializing the transaction subsystem.

MariaDB Server 10.4 is not affected by this.



 Comments   
Comment by Marko Mäkelä [ 2023-11-14 ]

The following patch that additionally checks innodb_force_recovery fixes also the tests innodb.read_only_recovery innodb.read_only_recover_committed mariabackup.apply-log-only-incr innodb.innodb_force_recovery:

diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 9b8ce4b2fa8..6f40df82f8f 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -1995,7 +1995,7 @@ void innodb_preshutdown()
     better prevent any further changes from being buffered. */
     innodb_change_buffering= 0;
 
-    if (trx_sys.is_initialised())
+    if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO && srv_was_started)
       while (trx_sys.any_active_transactions())
         os_thread_sleep(1000);
   }

Generated at Thu Feb 08 10:34:06 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.