Skip to content

Commit fc2df3c

Browse files
author
Jan Lindström
committed
MDEV-6812: Merge Kakao: Add global status variables which tell
you the progress of inplace alter table and row log buffer usage - (x 100%, it's 4-digit. 10000 means 100.00%) - Innodb_onlineddl_rowlog_rows Shows how many rows are stored in row log buffer. - Innodb_onlineddl_rowlog_pct_used Shows row log buffer usage in percent ( *100%, it's 4-digit. 10000 means 100.00% ). - Innodb_onlineddl_pct_progress Shows the progress of inplace alter table. It might be not so accurate because inplace alter is highly depend on disk and buffer pool status. But still it is useful and better than nothing. - Add some log for inplace alter table XtraDB/InnoDB will print some message before and after doing some task.
1 parent bef30f2 commit fc2df3c

File tree

18 files changed

+408
-25
lines changed

18 files changed

+408
-25
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,14 @@ static SHOW_VAR innodb_status_variables[]= {
801801
{"defragment_count",
802802
(char*) &export_vars.innodb_defragment_count, SHOW_LONG},
803803

804+
/* Online alter table status variables */
805+
{"onlineddl_rowlog_rows",
806+
(char*) &export_vars.innodb_onlineddl_rowlog_rows, SHOW_LONG},
807+
{"onlineddl_rowlog_pct_used",
808+
(char*) &export_vars.innodb_onlineddl_rowlog_pct_used, SHOW_LONG},
809+
{"onlineddl_pct_progress",
810+
(char*) &export_vars.innodb_onlineddl_pct_progress, SHOW_LONG},
811+
804812
{NullS, NullS, SHOW_LONG}
805813
};
806814

storage/innobase/handler/handler0alter.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,6 +3393,11 @@ ha_innobase::prepare_inplace_alter_table(
33933393
DBUG_ASSERT(ha_alter_info->create_info);
33943394
DBUG_ASSERT(!srv_read_only_mode);
33953395

3396+
/* Init online ddl status variables */
3397+
onlineddl_rowlog_rows = 0;
3398+
onlineddl_rowlog_pct_used = 0;
3399+
onlineddl_pct_progress = 0;
3400+
33963401
MONITOR_ATOMIC_INC(MONITOR_PENDING_ALTER_TABLE);
33973402

33983403
#ifdef UNIV_DEBUG
@@ -4043,6 +4048,11 @@ ha_innobase::inplace_alter_table(
40434048
ctx->thr, prebuilt->table, altered_table);
40444049
}
40454050

4051+
/* Init online ddl status variables */
4052+
onlineddl_rowlog_rows = 0;
4053+
onlineddl_rowlog_pct_used = 0;
4054+
onlineddl_pct_progress = 0;
4055+
40464056
DEBUG_SYNC_C("inplace_after_index_build");
40474057

40484058
DBUG_EXECUTE_IF("create_index_fail",

storage/innobase/include/row0log.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Created 2011-05-26 Marko Makela
3535
#include "trx0types.h"
3636
#include "que0types.h"
3737

38+
extern ulint onlineddl_rowlog_rows;
39+
extern ulint onlineddl_rowlog_pct_used;
40+
extern ulint onlineddl_pct_progress;
41+
3842
/******************************************************//**
3943
Allocate the row log for an index and flag the index
4044
for online creation.

storage/innobase/include/row0merge.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ Created 13/06/2005 Jan Lindstrom
4040
#include "lock0types.h"
4141
#include "srv0srv.h"
4242

43+
/* Cluster index read task is mandatory */
44+
#define COST_READ_CLUSTERED_INDEX 1.0
45+
46+
/* Basic fixed cost to build all type of index */
47+
#define COST_BUILD_INDEX_STATIC 0.5
48+
/* Dynamic cost to build all type of index, dynamic cost will be re-distributed based on page count ratio of each index */
49+
#define COST_BUILD_INDEX_DYNAMIC 0.5
50+
51+
/* Sum of below two must be 1.0 */
52+
#define PCT_COST_MERGESORT_INDEX 0.4
53+
#define PCT_COST_INSERT_INDEX 0.6
54+
4355
// Forward declaration
4456
struct ib_sequence_t;
4557

@@ -370,7 +382,10 @@ row_merge_sort(
370382
merge_file_t* file, /*!< in/out: file containing
371383
index entries */
372384
row_merge_block_t* block, /*!< in/out: 3 buffers */
373-
int* tmpfd) /*!< in/out: temporary file handle */
385+
int* tmpfd, /*!< in/out: temporary file handle */
386+
const bool update_progress, /*!< in: update progress status variable or not */
387+
const float pct_progress, /*!< in: total progress percent until now */
388+
const float pct_cost) /*!< in: current progress percent */
374389
__attribute__((nonnull));
375390
/*********************************************************************//**
376391
Allocate a sort buffer.

storage/innobase/include/srv0srv.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,19 @@ struct export_var_t{
903903
ulint innodb_truncated_status_writes; /*!< srv_truncated_status_writes */
904904
ulint innodb_available_undo_logs; /*!< srv_available_undo_logs
905905
*/
906-
ulint innodb_defragment_compression_failures;
907-
ulint innodb_defragment_failures;
908-
ulint innodb_defragment_count;
906+
ulint innodb_defragment_compression_failures; /*!< Number of
907+
defragment re-compression
908+
failures */
909+
910+
ulint innodb_defragment_failures; /*!< Number of defragment
911+
failures*/
912+
ulint innodb_defragment_count; /*!< Number of defragment
913+
operations*/
914+
915+
ulint innodb_onlineddl_rowlog_rows; /*!< Online alter rows */
916+
ulint innodb_onlineddl_rowlog_pct_used; /*!< Online alter percentage
917+
of used row log buffer */
918+
ulint innodb_onlineddl_pct_progress; /*!< Online alter progress */
909919

910920
#ifdef UNIV_DEBUG
911921
ulint innodb_purge_trx_id_age; /*!< rw_max_trx_id - purged trx_id */
@@ -917,7 +927,7 @@ struct export_var_t{
917927
by page compression */
918928
ib_int64_t innodb_page_compression_trim_sect512;/*!< Number of 512b TRIM
919929
by page compression */
920-
ib_int64_t innodb_page_compression_trim_sect4096;/*!< Number of 4K byte TRIM
930+
ib_int64_t innodb_page_compression_trim_sect4096;/*!< Number of 4K byte TRIM
921931
by page compression */
922932
ib_int64_t innodb_index_pages_written; /*!< Number of index pages
923933
written */

storage/innobase/row/row0ftsort.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ fts_parallel_tokenization(
847847

848848
error = row_merge_sort(psort_info->psort_common->trx,
849849
psort_info->psort_common->dup,
850-
merge_file[i], block[i], &tmpfd[i]);
850+
merge_file[i], block[i], &tmpfd[i], false, 0.0/* pct_progress */, 0.0/* pct_cost */);
851851
if (error != DB_SUCCESS) {
852852
close(tmpfd[i]);
853853
goto func_exit;

storage/innobase/row/row0log.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Created 2011-05-26 Marko Makela
4040

4141
#include<map>
4242

43+
ulint onlineddl_rowlog_rows;
44+
ulint onlineddl_rowlog_pct_used;
45+
ulint onlineddl_pct_progress;
46+
4347
/** Table row modification operations during online table rebuild.
4448
Delete-marked records are not copied to the rebuilt table. */
4549
enum row_tab_op {
@@ -470,6 +474,10 @@ row_log_table_close_func(
470474
log->tail.total += size;
471475
UNIV_MEM_INVALID(log->tail.buf, sizeof log->tail.buf);
472476
mutex_exit(&log->mutex);
477+
478+
os_atomic_increment_ulint(&onlineddl_rowlog_rows, 1);
479+
/* 10000 means 100.00%, 4525 means 45.25% */
480+
onlineddl_rowlog_pct_used = (log->tail.total * 10000) / srv_online_max_size;
473481
}
474482

475483
#ifdef UNIV_DEBUG

0 commit comments

Comments
 (0)