Skip to content

Commit

Permalink
MDEV-11705: InnoDB: Failing assertion: (&log_sys->mutex)->is_owned() …
Browse files Browse the repository at this point in the history
…if server started with innodb-scrub-log

Problem was that log_scrub function did not take required log_sys mutex.

Background: Unused space in log blocks are padded with MLOG_DUMMY_RECORD if innodb-scrub-log
is enabled. As log files are written on circular fashion old log blocks can be reused
later for new redo-log entries. Scrubbing pads unused space in log blocks to avoid visibility
of the possible old redo-log contents.

log_scrub(): Take log_sys mutex

log_pad_current_log_block(): Increase srv_stats.n_log_scrubs if padding is done.

srv0srv.cc: Set srv_stats.n_log_scrubs to export vars innodb_scrub_log

ha_innodb.cc: Export innodb_scrub_log to global status.
  • Loading branch information
Jan Lindström committed Jan 3, 2017
1 parent 4c610d1 commit 403f6e9
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions mysql-test/suite/encryption/r/innodb-scrub-log.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
create table t1(a int not null primary key auto_increment,
b varchar(200), c char(100), d varchar(150)) engine=innodb;
DROP TABLE t1;
1 change: 1 addition & 0 deletions mysql-test/suite/encryption/t/innodb-scrub-log.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--loose-innodb-scrub-log=on
13 changes: 13 additions & 0 deletions mysql-test/suite/encryption/t/innodb-scrub-log.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--source include/have_innodb.inc

#
# MDEV-11705: InnoDB: Failing assertion: (&log_sys->mutex)->is_owned() if server started with innodb-scrub-log
#

create table t1(a int not null primary key auto_increment,
b varchar(200), c char(100), d varchar(150)) engine=innodb;

let $wait_condition= SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'innodb_scrub_log';
--source include/wait_condition.inc

DROP TABLE t1;
3 changes: 3 additions & 0 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,9 @@ static SHOW_VAR innodb_status_variables[]= {
{"scrub_background_page_split_failures_unknown",
(char*) &export_vars.innodb_scrub_page_split_failures_unknown,
SHOW_LONG},
{"scrub_log",
(char*) &export_vars.innodb_scrub_log,
SHOW_LONGLONG},
{"encryption_num_key_requests",
(char*) &export_vars.innodb_encryption_key_requests, SHOW_LONGLONG},

Expand Down
6 changes: 5 additions & 1 deletion storage/innobase/include/srv0srv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, 2009, Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2013, 2016, MariaDB Corporation
Copyright (c) 2013, 2017, MariaDB Corporation
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
Expand Down Expand Up @@ -194,6 +194,9 @@ struct srv_stats_t {

/** Number of encryption_get_latest_key_version calls */
ulint_ctr_64_t n_key_requests;

/** Number of log scrub operations */
ulint_ctr_64_t n_log_scrubs;
};

extern const char* srv_main_thread_op_info;
Expand Down Expand Up @@ -1118,6 +1121,7 @@ struct export_var_t{
ulint innodb_scrub_page_split_failures_out_of_filespace;
ulint innodb_scrub_page_split_failures_missing_index;
ulint innodb_scrub_page_split_failures_unknown;
int64_t innodb_scrub_log;
};

/** Thread slot in the thread table. */
Expand Down
8 changes: 7 additions & 1 deletion storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc.
Copyright (C) 2014, 2016, MariaDB Corporation. All Rights Reserved.
Copyright (C) 2014, 2017, MariaDB Corporation. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
Expand Down Expand Up @@ -2552,6 +2552,10 @@ log_pad_current_log_block(void)
pad_length = 0;
}

if (pad_length) {
srv_stats.n_log_scrubs.inc();
}

for (i = 0; i < pad_length; i++) {
log_write_low(&b, 1);
}
Expand All @@ -2571,6 +2575,7 @@ void
log_scrub()
/*=========*/
{
log_mutex_enter();
ulint cur_lbn = log_block_convert_lsn_to_no(log_sys->lsn);

if (next_lbn_to_pad == cur_lbn)
Expand All @@ -2579,6 +2584,7 @@ log_scrub()
}

next_lbn_to_pad = log_block_convert_lsn_to_no(log_sys->lsn);
log_mutex_exit();
}

/* log scrubbing speed, in bytes/sec */
Expand Down
1 change: 1 addition & 0 deletions storage/innobase/srv/srv0srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ srv_export_innodb_status(void)
scrub_stat.page_split_failures_missing_index;
export_vars.innodb_scrub_page_split_failures_unknown =
scrub_stat.page_split_failures_unknown;
export_vars.innodb_scrub_log = srv_stats.n_log_scrubs;

mutex_exit(&srv_innodb_monitor_mutex);
}
Expand Down

0 comments on commit 403f6e9

Please sign in to comment.