[MDEV-18936] Purge thread fails to exit on shutdown Created: 2019-03-15  Updated: 2019-07-24  Resolved: 2019-03-15

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB, Storage Engine - XtraDB
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.2.23, 10.1.39, 10.3.14, 10.4.4

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: purge, shutdown, upstream-5.5

Issue Links:
Relates
relates to MDEV-20158 innodb_zip.innochecksum failed in bui... Closed
relates to MDEV-18867 Long Time to Stop and Start Closed
relates to MDEV-18952 CHECK TABLE should use READ UNCOMMITE... Closed

 Description   

When there is a huge transaction in the undo log, the purge subsystem may get stuck and fail to shut down. This was reproduced with the following on MariaDB 10.4:

diff --git a/mysql-test/suite/innodb/include/innodb-page-compression.inc b/mysql-test/suite/innodb/include/innodb-page-compression.inc
index 0e7ae8cf029..83e5387cdf4 100644
--- a/mysql-test/suite/innodb/include/innodb-page-compression.inc
+++ b/mysql-test/suite/innodb/include/innodb-page-compression.inc
@@ -11,7 +11,7 @@ create table innodb_page_compressed9 (c1 int not null auto_increment primary key
 
 --disable_query_log
 begin;
-let $i = 2000;
+let $i = 5000;
 while ($i)
 {
     insert into innodb_normal(b) values(REPEAT('Aa',50));

With this change, the attempt to restart the server would actually time out in the shutdown, like this:

10.4

innodb.innodb-page_compression_snappy 'innodb' [ fail ]  Found warnings/errors in server log file!
        Test ended at 2019-03-15 11:15:05
line
2019-03-15 11:14:48 0 [Warning] /dev/shm/10.4/sql/mysqld: Thread 5 (user : '') did not exit
2019-03-15 11:14:48 0 [Warning] /dev/shm/10.4/sql/mysqld: Thread 4 (user : '') did not exit
2019-03-15 11:14:48 0 [Warning] /dev/shm/10.4/sql/mysqld: Thread 3 (user : '') did not exit
2019-03-15 11:14:48 0 [Warning] /dev/shm/10.4/sql/mysqld: Thread 2 (user : '') did not exit
2019-03-15 11:14:48 0 [Warning] /dev/shm/10.4/sql/mysqld: Thread 1 (user : '') did not exit
^ Found warnings in /dev/shm/10.4/mysql-test/var/log/mysqld.1.err
ok

The cause is that a purge thread would remain stuck in trx_purge_attach_undo_recs(). Apparently the innodb_purge_batch_size does not work correctly, or the n_pages_handled is not being incremented correctly. In any case, we should exit the loop on non-slow shutdown even before reaching the batch size.


Generated at Thu Feb 08 08:47:51 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.