Skip to content

Commit

Permalink
MDEV-6812: Merge Kakao: Add global status variables which tell
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jan Lindström committed Sep 30, 2014
1 parent bef30f2 commit fc2df3c
Show file tree
Hide file tree
Showing 18 changed files with 408 additions and 25 deletions.
8 changes: 8 additions & 0 deletions storage/innobase/handler/ha_innodb.cc
Expand Up @@ -801,6 +801,14 @@ static SHOW_VAR innodb_status_variables[]= {
{"defragment_count",
(char*) &export_vars.innodb_defragment_count, SHOW_LONG},

/* Online alter table status variables */
{"onlineddl_rowlog_rows",
(char*) &export_vars.innodb_onlineddl_rowlog_rows, SHOW_LONG},
{"onlineddl_rowlog_pct_used",
(char*) &export_vars.innodb_onlineddl_rowlog_pct_used, SHOW_LONG},
{"onlineddl_pct_progress",
(char*) &export_vars.innodb_onlineddl_pct_progress, SHOW_LONG},

{NullS, NullS, SHOW_LONG}
};

Expand Down
10 changes: 10 additions & 0 deletions storage/innobase/handler/handler0alter.cc
Expand Up @@ -3393,6 +3393,11 @@ ha_innobase::prepare_inplace_alter_table(
DBUG_ASSERT(ha_alter_info->create_info);
DBUG_ASSERT(!srv_read_only_mode);

/* Init online ddl status variables */
onlineddl_rowlog_rows = 0;
onlineddl_rowlog_pct_used = 0;
onlineddl_pct_progress = 0;

MONITOR_ATOMIC_INC(MONITOR_PENDING_ALTER_TABLE);

#ifdef UNIV_DEBUG
Expand Down Expand Up @@ -4043,6 +4048,11 @@ ha_innobase::inplace_alter_table(
ctx->thr, prebuilt->table, altered_table);
}

/* Init online ddl status variables */
onlineddl_rowlog_rows = 0;
onlineddl_rowlog_pct_used = 0;
onlineddl_pct_progress = 0;

DEBUG_SYNC_C("inplace_after_index_build");

DBUG_EXECUTE_IF("create_index_fail",
Expand Down
4 changes: 4 additions & 0 deletions storage/innobase/include/row0log.h
Expand Up @@ -35,6 +35,10 @@ Created 2011-05-26 Marko Makela
#include "trx0types.h"
#include "que0types.h"

extern ulint onlineddl_rowlog_rows;
extern ulint onlineddl_rowlog_pct_used;
extern ulint onlineddl_pct_progress;

/******************************************************//**
Allocate the row log for an index and flag the index
for online creation.
Expand Down
17 changes: 16 additions & 1 deletion storage/innobase/include/row0merge.h
Expand Up @@ -40,6 +40,18 @@ Created 13/06/2005 Jan Lindstrom
#include "lock0types.h"
#include "srv0srv.h"

/* Cluster index read task is mandatory */
#define COST_READ_CLUSTERED_INDEX 1.0

/* Basic fixed cost to build all type of index */
#define COST_BUILD_INDEX_STATIC 0.5
/* Dynamic cost to build all type of index, dynamic cost will be re-distributed based on page count ratio of each index */
#define COST_BUILD_INDEX_DYNAMIC 0.5

/* Sum of below two must be 1.0 */
#define PCT_COST_MERGESORT_INDEX 0.4
#define PCT_COST_INSERT_INDEX 0.6

// Forward declaration
struct ib_sequence_t;

Expand Down Expand Up @@ -370,7 +382,10 @@ row_merge_sort(
merge_file_t* file, /*!< in/out: file containing
index entries */
row_merge_block_t* block, /*!< in/out: 3 buffers */
int* tmpfd) /*!< in/out: temporary file handle */
int* tmpfd, /*!< in/out: temporary file handle */
const bool update_progress, /*!< in: update progress status variable or not */
const float pct_progress, /*!< in: total progress percent until now */
const float pct_cost) /*!< in: current progress percent */
__attribute__((nonnull));
/*********************************************************************//**
Allocate a sort buffer.
Expand Down
18 changes: 14 additions & 4 deletions storage/innobase/include/srv0srv.h
Expand Up @@ -903,9 +903,19 @@ struct export_var_t{
ulint innodb_truncated_status_writes; /*!< srv_truncated_status_writes */
ulint innodb_available_undo_logs; /*!< srv_available_undo_logs
*/
ulint innodb_defragment_compression_failures;
ulint innodb_defragment_failures;
ulint innodb_defragment_count;
ulint innodb_defragment_compression_failures; /*!< Number of
defragment re-compression
failures */

ulint innodb_defragment_failures; /*!< Number of defragment
failures*/
ulint innodb_defragment_count; /*!< Number of defragment
operations*/

ulint innodb_onlineddl_rowlog_rows; /*!< Online alter rows */
ulint innodb_onlineddl_rowlog_pct_used; /*!< Online alter percentage
of used row log buffer */
ulint innodb_onlineddl_pct_progress; /*!< Online alter progress */

#ifdef UNIV_DEBUG
ulint innodb_purge_trx_id_age; /*!< rw_max_trx_id - purged trx_id */
Expand All @@ -917,7 +927,7 @@ struct export_var_t{
by page compression */
ib_int64_t innodb_page_compression_trim_sect512;/*!< Number of 512b TRIM
by page compression */
ib_int64_t innodb_page_compression_trim_sect4096;/*!< Number of 4K byte TRIM
ib_int64_t innodb_page_compression_trim_sect4096;/*!< Number of 4K byte TRIM
by page compression */
ib_int64_t innodb_index_pages_written; /*!< Number of index pages
written */
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/row/row0ftsort.cc
Expand Up @@ -847,7 +847,7 @@ fts_parallel_tokenization(

error = row_merge_sort(psort_info->psort_common->trx,
psort_info->psort_common->dup,
merge_file[i], block[i], &tmpfd[i]);
merge_file[i], block[i], &tmpfd[i], false, 0.0/* pct_progress */, 0.0/* pct_cost */);
if (error != DB_SUCCESS) {
close(tmpfd[i]);
goto func_exit;
Expand Down
8 changes: 8 additions & 0 deletions storage/innobase/row/row0log.cc
Expand Up @@ -40,6 +40,10 @@ Created 2011-05-26 Marko Makela

#include<map>

ulint onlineddl_rowlog_rows;
ulint onlineddl_rowlog_pct_used;
ulint onlineddl_pct_progress;

/** Table row modification operations during online table rebuild.
Delete-marked records are not copied to the rebuilt table. */
enum row_tab_op {
Expand Down Expand Up @@ -470,6 +474,10 @@ row_log_table_close_func(
log->tail.total += size;
UNIV_MEM_INVALID(log->tail.buf, sizeof log->tail.buf);
mutex_exit(&log->mutex);

os_atomic_increment_ulint(&onlineddl_rowlog_rows, 1);
/* 10000 means 100.00%, 4525 means 45.25% */
onlineddl_rowlog_pct_used = (log->tail.total * 10000) / srv_online_max_size;
}

#ifdef UNIV_DEBUG
Expand Down

0 comments on commit fc2df3c

Please sign in to comment.