Commit 8984bef2 authored by Jan Lindström's avatar Jan Lindström

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.
parent 2062c9a6
...@@ -2100,6 +2100,7 @@ row_merge( ...@@ -2100,6 +2100,7 @@ row_merge(
/* Copy the last blocks, if there are any. */ /* Copy the last blocks, if there are any. */
while (foffs0 < ihalf) { while (foffs0 < ihalf) {
if (UNIV_UNLIKELY(trx_is_interrupted(trx))) { if (UNIV_UNLIKELY(trx_is_interrupted(trx))) {
return(DB_INTERRUPTED); return(DB_INTERRUPTED);
} }
...@@ -2116,6 +2117,7 @@ row_merge( ...@@ -2116,6 +2117,7 @@ row_merge(
ut_ad(foffs0 == ihalf); ut_ad(foffs0 == ihalf);
while (foffs1 < file->offset) { while (foffs1 < file->offset) {
if (trx_is_interrupted(trx)) { if (trx_is_interrupted(trx)) {
return(DB_INTERRUPTED); return(DB_INTERRUPTED);
} }
...@@ -2175,6 +2177,7 @@ row_merge_sort( ...@@ -2175,6 +2177,7 @@ row_merge_sort(
{ {
const ulint half = file->offset / 2; const ulint half = file->offset / 2;
ulint num_runs; ulint num_runs;
ulint cur_run = 0;
ulint* run_offset; ulint* run_offset;
dberr_t error = DB_SUCCESS; dberr_t error = DB_SUCCESS;
DBUG_ENTER("row_merge_sort"); DBUG_ENTER("row_merge_sort");
...@@ -2198,8 +2201,16 @@ row_merge_sort( ...@@ -2198,8 +2201,16 @@ row_merge_sort(
of file marker). Thus, it must be at least one block. */ of file marker). Thus, it must be at least one block. */
ut_ad(file->offset > 0); ut_ad(file->offset > 0);
thd_progress_init(trx->mysql_thd, num_runs);
/* Merge the runs until we have one big run */ /* Merge the runs until we have one big run */
do { 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, error = row_merge(trx, dup, file, block, tmpfd,
&num_runs, run_offset); &num_runs, run_offset);
...@@ -2212,6 +2223,8 @@ row_merge_sort( ...@@ -2212,6 +2223,8 @@ row_merge_sort(
mem_free(run_offset); mem_free(run_offset);
thd_progress_end(trx->mysql_thd);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
...@@ -2106,6 +2106,7 @@ row_merge( ...@@ -2106,6 +2106,7 @@ row_merge(
/* Copy the last blocks, if there are any. */ /* Copy the last blocks, if there are any. */
while (foffs0 < ihalf) { while (foffs0 < ihalf) {
if (UNIV_UNLIKELY(trx_is_interrupted(trx))) { if (UNIV_UNLIKELY(trx_is_interrupted(trx))) {
return(DB_INTERRUPTED); return(DB_INTERRUPTED);
} }
...@@ -2122,6 +2123,7 @@ row_merge( ...@@ -2122,6 +2123,7 @@ row_merge(
ut_ad(foffs0 == ihalf); ut_ad(foffs0 == ihalf);
while (foffs1 < file->offset) { while (foffs1 < file->offset) {
if (trx_is_interrupted(trx)) { if (trx_is_interrupted(trx)) {
return(DB_INTERRUPTED); return(DB_INTERRUPTED);
} }
...@@ -2181,6 +2183,7 @@ row_merge_sort( ...@@ -2181,6 +2183,7 @@ row_merge_sort(
{ {
const ulint half = file->offset / 2; const ulint half = file->offset / 2;
ulint num_runs; ulint num_runs;
ulint cur_run = 0;
ulint* run_offset; ulint* run_offset;
dberr_t error = DB_SUCCESS; dberr_t error = DB_SUCCESS;
DBUG_ENTER("row_merge_sort"); DBUG_ENTER("row_merge_sort");
...@@ -2204,8 +2207,16 @@ row_merge_sort( ...@@ -2204,8 +2207,16 @@ row_merge_sort(
of file marker). Thus, it must be at least one block. */ of file marker). Thus, it must be at least one block. */
ut_ad(file->offset > 0); ut_ad(file->offset > 0);
thd_progress_init(trx->mysql_thd, num_runs);
/* Merge the runs until we have one big run */ /* Merge the runs until we have one big run */
do { 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, error = row_merge(trx, dup, file, block, tmpfd,
&num_runs, run_offset); &num_runs, run_offset);
...@@ -2218,6 +2229,8 @@ row_merge_sort( ...@@ -2218,6 +2229,8 @@ row_merge_sort(
mem_free(run_offset); mem_free(run_offset);
thd_progress_end(trx->mysql_thd);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment