From 8984bef2e431db42761d3f267b950293cfd864de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 18 Aug 2014 10:52:59 +0300 Subject: [PATCH] MDEV-6172: Monitor progress of ALTER TABLE ... ADD INDEX, ALGORITHM=INPLACE for InnoDB Added thd_progress calls to row_merge_sort to give some hint how merge sort progresses. --- storage/innobase/row/row0merge.cc | 13 +++++++++++++ storage/xtradb/row/row0merge.cc | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index ab97b5a9f28..d9e0dc709be 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2100,6 +2100,7 @@ row_merge( /* Copy the last blocks, if there are any. */ while (foffs0 < ihalf) { + if (UNIV_UNLIKELY(trx_is_interrupted(trx))) { return(DB_INTERRUPTED); } @@ -2116,6 +2117,7 @@ row_merge( ut_ad(foffs0 == ihalf); while (foffs1 < file->offset) { + if (trx_is_interrupted(trx)) { return(DB_INTERRUPTED); } @@ -2175,6 +2177,7 @@ row_merge_sort( { const ulint half = file->offset / 2; ulint num_runs; + ulint cur_run = 0; ulint* run_offset; dberr_t error = DB_SUCCESS; DBUG_ENTER("row_merge_sort"); @@ -2198,8 +2201,16 @@ row_merge_sort( of file marker). Thus, it must be at least one block. */ ut_ad(file->offset > 0); + thd_progress_init(trx->mysql_thd, num_runs); + /* Merge the runs until we have one big run */ do { + cur_run++; + + /* Report progress of merge sort to MySQL for + show processlist progress field */ + thd_progress_report(trx->mysql_thd, cur_run, num_runs); + error = row_merge(trx, dup, file, block, tmpfd, &num_runs, run_offset); @@ -2212,6 +2223,8 @@ row_merge_sort( mem_free(run_offset); + thd_progress_end(trx->mysql_thd); + DBUG_RETURN(error); } diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index 0b2e966efe0..4428de30473 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -2106,6 +2106,7 @@ row_merge( /* Copy the last blocks, if there are any. */ while (foffs0 < ihalf) { + if (UNIV_UNLIKELY(trx_is_interrupted(trx))) { return(DB_INTERRUPTED); } @@ -2122,6 +2123,7 @@ row_merge( ut_ad(foffs0 == ihalf); while (foffs1 < file->offset) { + if (trx_is_interrupted(trx)) { return(DB_INTERRUPTED); } @@ -2181,6 +2183,7 @@ row_merge_sort( { const ulint half = file->offset / 2; ulint num_runs; + ulint cur_run = 0; ulint* run_offset; dberr_t error = DB_SUCCESS; DBUG_ENTER("row_merge_sort"); @@ -2204,8 +2207,16 @@ row_merge_sort( of file marker). Thus, it must be at least one block. */ ut_ad(file->offset > 0); + thd_progress_init(trx->mysql_thd, num_runs); + /* Merge the runs until we have one big run */ do { + cur_run++; + + /* Report progress of merge sort to MySQL for + show processlist progress field */ + thd_progress_report(trx->mysql_thd, cur_run, num_runs); + error = row_merge(trx, dup, file, block, tmpfd, &num_runs, run_offset); @@ -2218,6 +2229,8 @@ row_merge_sort( mem_free(run_offset); + thd_progress_end(trx->mysql_thd); + DBUG_RETURN(error); }