Browse files



The purge thread takes too much long time during
shutdown. This is because we call trx_purge()
three times during shutdown,each time it is
called 300 undo log pages are being processed.
so even though you set batch size as 300,
900 undo pages are processed during shutdown,
whereas in 5.5 it is only called once
during shutdown.  This is the reason we are
seeing a 10 minute delay in shutdown time.

Instead of calling a separate trx_purge()
for truncating the history log, do it
with the trx_purge() in work loop once every
128 (TRX_SYS_N_RSEGS) times. Also reduce the
batch size to 20 for trx_purge() which is
called after detecting shutdown.

[#rb 9359 Approved by jimmy]
  • Loading branch information...
Aditya A
Aditya A committed Jul 14, 2015
1 parent c86abd1 commit 3e8202ff443909e93231d453a3f1560b5a5ce3cb
Showing with 13 additions and 9 deletions.
  1. +13 −9 storage/innobase/srv/
@@ -2585,13 +2585,8 @@ srv_do_purge(
n_pages_purged = trx_purge(
n_use_threads, srv_purge_batch_size, false);
if (!(count++ % TRX_SYS_N_RSEGS)) {
/* Force a truncate of the history list. */
n_pages_purged += trx_purge(
1, srv_purge_batch_size, true);
n_use_threads, srv_purge_batch_size,
(++count % TRX_SYS_N_RSEGS) == 0);
*n_total_purged += n_pages_purged;
@@ -2784,8 +2779,17 @@ DECLARE_THREAD(srv_purge_coordinator_thread)(
n_pages_purged = trx_purge(1, srv_purge_batch_size, false);
/* Force a truncate of the history list. */
n_pages_purged = trx_purge(1, srv_purge_batch_size, true);
/* This trx_purge is called to remove any undo records (added by
background threads) after completion of the above loop. When
srv_fast_shutdown != 0, a large batch size can cause significant
delay in shutdown ,so reducing the batch size to magic number 20
(which was default in 5.5), which we hope will be sufficient to
remove all the undo records */
const uint temp_batch_size = 20;
n_pages_purged = trx_purge(1, srv_purge_batch_size <= temp_batch_size
? srv_purge_batch_size : temp_batch_size,
ut_a(n_pages_purged == 0 || srv_fast_shutdown != 0);
/* The task queue should always be empty, independent of fast

0 comments on commit 3e8202f

Please sign in to comment.