From 34db9958e28c325b0f708f78b7ff029de810d5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 15 Mar 2019 12:09:46 +0200 Subject: [PATCH] MDEV-18936 Purge thread fails to exit on shutdown When there is a huge transaction in the undo log, the purge threads may get stuck in trx_purge_attach_undo_recs() for a long time, causing the server to hang on a normal shutdown (innodb_fast_shutdown>0). Apparently the innodb_purge_batch_size does not work correctly, or the n_pages_handled is not being incremented correctly. We do not fix that for now, but we will instead check if shutdown has been initiated, allowing the purge threads to shut down without delays. --- storage/innobase/trx/trx0purge.cc | 4 ++-- storage/xtradb/trx/trx0purge.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index b9edac35c4d..5c7146fd730 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, 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 @@ -989,7 +989,7 @@ trx_purge_attach_undo_recs( i = 0; - for (;;) { + while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) { purge_node_t* node; trx_purge_rec_t* purge_rec; diff --git a/storage/xtradb/trx/trx0purge.cc b/storage/xtradb/trx/trx0purge.cc index 11522ea5f9c..a9736e36075 100644 --- a/storage/xtradb/trx/trx0purge.cc +++ b/storage/xtradb/trx/trx0purge.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, 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 @@ -989,7 +989,7 @@ trx_purge_attach_undo_recs( i = 0; - for (;;) { + while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) { purge_node_t* node; trx_purge_rec_t* purge_rec;