Skip to content

Commit

Permalink
MDEV-9129: Server is restarting in the loop after crash
Browse files Browse the repository at this point in the history
Analysis: We have reserved ROW_MERGE_RESERVE_SIZE ( = 4) for
encryption key_version. When calculating is there more
space on sort buffer, this value needs to be substracted
from current available space.
  • Loading branch information
Jan Lindström committed Dec 15, 2015
1 parent 477c84d commit 1ac6640
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
3 changes: 3 additions & 0 deletions storage/innobase/include/row0merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Created 13/06/2005 Jan Lindstrom
#include "lock0types.h"
#include "srv0srv.h"

/* Reserve free space from every block for key_version */
#define ROW_MERGE_RESERVE_SIZE 4

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

Expand Down
6 changes: 4 additions & 2 deletions storage/innobase/row/row0ftsort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,11 @@ row_merge_fts_doc_tokenize(
fts_max_token_size, add one extra size and one extra byte */
cur_len += 2;

/* Reserve one byte for the end marker of row_merge_block_t. */
/* Reserve one byte for the end marker of row_merge_block_t
and we have reserved ROW_MERGE_RESERVE_SIZE (= 4) for
encryption key_version in the beginning of the buffer. */
if (buf->total_size + data_size[idx] + cur_len
>= srv_sort_buf_size - 1) {
>= (srv_sort_buf_size - 1 - ROW_MERGE_RESERVE_SIZE)) {

buf_full = TRUE;
break;
Expand Down
18 changes: 13 additions & 5 deletions storage/innobase/row/row0merge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ UNIV_INTERN char srv_disable_sort_file_cache;
/* Maximum pending doc memory limit in bytes for a fts tokenization thread */
#define FTS_PENDING_DOC_MEMORY_LIMIT 1000000

/* Reserve free space from every block for key_version */
#define ROW_MERGE_RESERVE_SIZE 4

/******************************************************//**
Encrypt a merge block. */
Expand Down Expand Up @@ -2571,7 +2569,11 @@ 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);
/* Progress report only for "normal" indexes. */
if (!(dup->index->type & DICT_FTS)) {
thd_progress_init(trx->mysql_thd, num_runs);
}

sql_print_information("InnoDB: Online DDL : merge-sorting has estimated %lu runs", num_runs);

/* Merge the runs until we have one big run */
Expand All @@ -2580,7 +2582,10 @@ row_merge_sort(

/* Report progress of merge sort to MySQL for
show processlist progress field */
thd_progress_report(trx->mysql_thd, cur_run, num_runs);
/* Progress report only for "normal" indexes. */
if (!(dup->index->type & DICT_FTS)) {
thd_progress_report(trx->mysql_thd, cur_run, num_runs);
}
sql_print_information("InnoDB: Online DDL : merge-sorting current run %lu estimated %lu runs", cur_run, num_runs);

error = row_merge(trx, dup, file, block, tmpfd,
Expand All @@ -2605,7 +2610,10 @@ row_merge_sort(

mem_free(run_offset);

thd_progress_end(trx->mysql_thd);
/* Progress report only for "normal" indexes. */
if (!(dup->index->type & DICT_FTS)) {
thd_progress_end(trx->mysql_thd);
}

DBUG_RETURN(error);
}
Expand Down
3 changes: 3 additions & 0 deletions storage/xtradb/include/row0merge.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Created 13/06/2005 Jan Lindstrom
#include "lock0types.h"
#include "srv0srv.h"

/* Reserve free space from every block for key_version */
#define ROW_MERGE_RESERVE_SIZE 4

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

Expand Down
6 changes: 4 additions & 2 deletions storage/xtradb/row/row0ftsort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,11 @@ row_merge_fts_doc_tokenize(
fts_max_token_size, add one extra size and one extra byte */
cur_len += 2;

/* Reserve one byte for the end marker of row_merge_block_t. */
/* Reserve one byte for the end marker of row_merge_block_t
and we have reserved ROW_MERGE_RESERVE_SIZE (= 4) for
encryption key_version in the beginning of the buffer. */
if (buf->total_size + data_size[idx] + cur_len
>= srv_sort_buf_size - 1) {
>= (srv_sort_buf_size - 1 - ROW_MERGE_RESERVE_SIZE)) {

buf_full = TRUE;
break;
Expand Down
18 changes: 13 additions & 5 deletions storage/xtradb/row/row0merge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ UNIV_INTERN char srv_disable_sort_file_cache;
/* Maximum pending doc memory limit in bytes for a fts tokenization thread */
#define FTS_PENDING_DOC_MEMORY_LIMIT 1000000

/* Reserve free space from every block for key_version */
#define ROW_MERGE_RESERVE_SIZE 4

/******************************************************//**
Encrypt a merge block. */
Expand Down Expand Up @@ -2578,7 +2576,11 @@ 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);
/* Progress report only for "normal" indexes. */
if (!(dup->index->type & DICT_FTS)) {
thd_progress_init(trx->mysql_thd, num_runs);
}

sql_print_information("InnoDB: Online DDL : merge-sorting has estimated %lu runs", num_runs);

/* Merge the runs until we have one big run */
Expand All @@ -2587,7 +2589,10 @@ row_merge_sort(

/* Report progress of merge sort to MySQL for
show processlist progress field */
thd_progress_report(trx->mysql_thd, cur_run, num_runs);
/* Progress report only for "normal" indexes. */
if (!(dup->index->type & DICT_FTS)) {
thd_progress_report(trx->mysql_thd, cur_run, num_runs);
}
sql_print_information("InnoDB: Online DDL : merge-sorting current run %lu estimated %lu runs", cur_run, num_runs);

error = row_merge(trx, dup, file, block, tmpfd,
Expand All @@ -2612,7 +2617,10 @@ row_merge_sort(

mem_free(run_offset);

thd_progress_end(trx->mysql_thd);
/* Progress report only for "normal" indexes. */
if (!(dup->index->type & DICT_FTS)) {
thd_progress_end(trx->mysql_thd);
}

DBUG_RETURN(error);
}
Expand Down

0 comments on commit 1ac6640

Please sign in to comment.