Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ static my_bool opt_check_privileges;

extern const char *innodb_checksum_algorithm_names[];
extern TYPELIB innodb_checksum_algorithm_typelib;
extern const char *innodb_flush_method_names[];
extern TYPELIB innodb_flush_method_typelib;
extern TYPELIB innodb_doublewrite_typelib;
/** Ignored option */
static ulong innodb_flush_method;

Expand Down Expand Up @@ -1859,8 +1859,8 @@ struct my_option xb_server_options[] =
&innobase_data_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE,
"Enable InnoDB doublewrite buffer during --prepare.",
(G_PTR*) &srv_use_doublewrite_buf,
(G_PTR*) &srv_use_doublewrite_buf, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
(G_PTR*) &buf_dblwr.use, (G_PTR*) &buf_dblwr.use,
&innodb_doublewrite_typelib, GET_ENUM, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"innodb_io_capacity", OPT_INNODB_IO_CAPACITY,
"Number of IOPs the server can do. Tunes the background IO rate",
(G_PTR*) &srv_io_capacity, (G_PTR*) &srv_io_capacity,
Expand Down
9 changes: 8 additions & 1 deletion mysql-test/suite/innodb/r/alter_kill.result
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
SELECT @@innodb_doublewrite;
@@innodb_doublewrite
OFF
SET GLOBAL innodb_doublewrite=fast;
#
# Bug#16720368 INNODB CRASHES ON BROKEN #SQL*.IBD FILE AT STARTUP
#
Expand All @@ -12,7 +16,10 @@ connection default;
disconnect con1;
# Corrupt FIL_PAGE_TYPE in bug16720368.ibd,
# and recompute innodb_checksum_algorithm=crc32
# restart
# restart: --innodb-flush-method=O_DIRECT
SELECT @@innodb_doublewrite;
@@innodb_doublewrite
OFF
SELECT COUNT(*) FROM bug16720368;
ERROR HY000: Table `test`.`bug16720368` is corrupted. Please drop the table and recreate.
INSERT INTO bug16720368 VALUES(1);
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/innodb/t/alter_kill-master.opt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--innodb-doublewrite=false
--innodb-flush-method=O_DIRECT_NO_FSYNC --skip-innodb-doublewrite
6 changes: 6 additions & 0 deletions mysql-test/suite/innodb/t/alter_kill.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
let MYSQLD_DATADIR=`select @@datadir`;
let PAGE_SIZE=`select @@innodb_page_size`;

SELECT @@innodb_doublewrite;
SET GLOBAL innodb_doublewrite=fast;

-- disable_query_log
call mtr.add_suppression("InnoDB: innodb_force_recovery is on.");
call mtr.add_suppression("InnoDB: Ignoring tablespace for.*bug16720368");
Expand Down Expand Up @@ -73,8 +76,11 @@ syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
close(FILE) || die "Unable to close $file";
EOF

-- let $restart_parameters=--innodb-flush-method=O_DIRECT
-- source include/start_mysqld.inc
-- let $restart_parameters=

SELECT @@innodb_doublewrite;
--error ER_TABLE_CORRUPT
SELECT COUNT(*) FROM bug16720368;
--error ER_TABLE_CORRUPT
Expand Down
47 changes: 19 additions & 28 deletions mysql-test/suite/sys_vars/r/innodb_doublewrite_basic.result
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
'#---------------------BS_STVARS_026_01----------------------#'
SELECT COUNT(@@GLOBAL.innodb_doublewrite);
COUNT(@@GLOBAL.innodb_doublewrite)
1
1 Expected
'#---------------------BS_STVARS_026_02----------------------#'
SELECT @@GLOBAL.innodb_doublewrite;
@@GLOBAL.innodb_doublewrite
ON
SET @@GLOBAL.innodb_doublewrite=0;
SELECT @@GLOBAL.innodb_doublewrite;
@@GLOBAL.innodb_doublewrite
OFF
SET @@GLOBAL.innodb_doublewrite=2;
SET @@GLOBAL.innodb_doublewrite=3;
ERROR 42000: Variable 'innodb_doublewrite' can't be set to the value of '3'
SELECT @@GLOBAL.innodb_doublewrite;
@@GLOBAL.innodb_doublewrite
fast
SET @@GLOBAL.innodb_doublewrite=1;
ERROR HY000: Variable 'innodb_doublewrite' is a read only variable
Expected error 'Read only variable'
SELECT COUNT(@@GLOBAL.innodb_doublewrite);
COUNT(@@GLOBAL.innodb_doublewrite)
1
1 Expected
'#---------------------BS_STVARS_026_03----------------------#'
SELECT IF(@@GLOBAL.innodb_doublewrite, "ON", "OFF") = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_doublewrite';
IF(@@GLOBAL.innodb_doublewrite, "ON", "OFF") = VARIABLE_VALUE
1
1 Expected
SELECT COUNT(@@GLOBAL.innodb_doublewrite);
COUNT(@@GLOBAL.innodb_doublewrite)
1
1 Expected
SELECT @@GLOBAL.innodb_doublewrite;
@@GLOBAL.innodb_doublewrite
ON
SELECT COUNT(VARIABLE_VALUE)
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_doublewrite';
COUNT(VARIABLE_VALUE)
1
1 Expected
'#---------------------BS_STVARS_026_04----------------------#'
SELECT @@innodb_doublewrite = @@GLOBAL.innodb_doublewrite;
@@innodb_doublewrite = @@GLOBAL.innodb_doublewrite
Expand All @@ -48,6 +40,5 @@ SELECT COUNT(@@GLOBAL.innodb_doublewrite);
COUNT(@@GLOBAL.innodb_doublewrite)
1
1 Expected
SELECT innodb_doublewrite = @@SESSION.innodb_doublewrite;
ERROR 42S22: Unknown column 'innodb_doublewrite' in 'field list'
Expected error 'Readonly variable'
SELECT @@innodb_doublewrite = @@SESSION.innodb_doublewrite;
ERROR HY000: Variable 'innodb_doublewrite' is a GLOBAL variable
10 changes: 5 additions & 5 deletions mysql-test/suite/sys_vars/r/sysvars_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,14 @@ VARIABLE_NAME INNODB_DOUBLEWRITE
SESSION_VALUE NULL
DEFAULT_VALUE ON
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Enable InnoDB doublewrite buffer (enabled by default). Disable with --skip-innodb-doublewrite.
VARIABLE_TYPE ENUM
VARIABLE_COMMENT Whether and how to use the doublewrite buffer. OFF=Assume that writes of innodb_page_size are atomic; ON=Prevent torn writes (the default); fast=Like ON, but do not synchronize writes to data files
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT NONE
ENUM_VALUE_LIST OFF,ON,fast
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_ENCRYPTION_ROTATE_KEY_AGE
SESSION_VALUE NULL
DEFAULT_VALUE 1
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/sys_vars/t/innodb_doublewrite_basic.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--innodb-doublewrite
82 changes: 11 additions & 71 deletions mysql-test/suite/sys_vars/t/innodb_doublewrite_basic.test
Original file line number Diff line number Diff line change
@@ -1,75 +1,20 @@


################## mysql-test\t\innodb_doublewrite_basic.test #################
# #
# Variable Name: innodb_doublewrite #
# Scope: Global #
# Access Type: Static #
# Data Type: boolean #
# #
# #
# Creation Date: 2008-02-07 #
# Author : Sharique Abdullah #
# #
# #
# Description:Test Cases of Dynamic System Variable innodb_doublewrite #
# that checks the behavior of this variable in the following ways #
# * Value Check #
# * Scope Check #
# #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
# server-system-variables.html #
# #
###############################################################################

--source include/have_innodb.inc

--echo '#---------------------BS_STVARS_026_01----------------------#'
####################################################################
# Displaying default value #
####################################################################
SELECT COUNT(@@GLOBAL.innodb_doublewrite);
--echo 1 Expected

SELECT @@GLOBAL.innodb_doublewrite;

--echo '#---------------------BS_STVARS_026_02----------------------#'
####################################################################
# Check if Value can set #
####################################################################
SET @@GLOBAL.innodb_doublewrite=0;
SELECT @@GLOBAL.innodb_doublewrite;

--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET @@GLOBAL.innodb_doublewrite=2;
--error ER_WRONG_VALUE_FOR_VAR
SET @@GLOBAL.innodb_doublewrite=3;
SELECT @@GLOBAL.innodb_doublewrite;
SET @@GLOBAL.innodb_doublewrite=1;
--echo Expected error 'Read only variable'

SELECT COUNT(@@GLOBAL.innodb_doublewrite);
--echo 1 Expected




--echo '#---------------------BS_STVARS_026_03----------------------#'
#################################################################
# Check if the value in GLOBAL Table matches value in variable #
#################################################################

--disable_warnings
SELECT IF(@@GLOBAL.innodb_doublewrite, "ON", "OFF") = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_doublewrite';
--enable_warnings
--echo 1 Expected

SELECT COUNT(@@GLOBAL.innodb_doublewrite);
--echo 1 Expected
SELECT @@GLOBAL.innodb_doublewrite;

--disable_warnings
SELECT COUNT(VARIABLE_VALUE)
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_doublewrite';
--enable_warnings
--echo 1 Expected



--echo '#---------------------BS_STVARS_026_04----------------------#'
################################################################################
Expand All @@ -78,8 +23,6 @@ WHERE VARIABLE_NAME='innodb_doublewrite';
SELECT @@innodb_doublewrite = @@GLOBAL.innodb_doublewrite;
--echo 1 Expected



--echo '#---------------------BS_STVARS_026_05----------------------#'
################################################################################
# Check if innodb_doublewrite can be accessed with and without @@ sign #
Expand All @@ -99,8 +42,5 @@ SELECT COUNT(@@SESSION.innodb_doublewrite);
SELECT COUNT(@@GLOBAL.innodb_doublewrite);
--echo 1 Expected

--Error ER_BAD_FIELD_ERROR
SELECT innodb_doublewrite = @@SESSION.innodb_doublewrite;
--echo Expected error 'Readonly variable'


--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@innodb_doublewrite = @@SESSION.innodb_doublewrite;
36 changes: 20 additions & 16 deletions storage/innobase/buf/buf0dblwr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void buf_dblwr_t::init()
active_slot= &slots[0];
mysql_mutex_init(buf_dblwr_mutex_key, &mutex, nullptr);
pthread_cond_init(&cond, nullptr);
block_size= FSP_EXTENT_SIZE;
}
}

Expand All @@ -67,7 +68,7 @@ inline void buf_dblwr_t::init(const byte *header)
block1= page_id_t(0, mach_read_from_4(header + TRX_SYS_DOUBLEWRITE_BLOCK1));
block2= page_id_t(0, mach_read_from_4(header + TRX_SYS_DOUBLEWRITE_BLOCK2));

const uint32_t buf_size= 2 * block_size();
const uint32_t buf_size= 2 * block_size;
for (int i= 0; i < 2; i++)
{
slots[i].write_buf= static_cast<byte*>
Expand All @@ -86,7 +87,7 @@ bool buf_dblwr_t::create()
return true;

mtr_t mtr;
const ulint size= block_size();
const ulint size= block_size;

start_again:
mtr.start();
Expand Down Expand Up @@ -251,7 +252,7 @@ loads the pages from double write buffer into memory.
dberr_t buf_dblwr_t::init_or_load_pages(pfs_os_file_t file, const char *path)
{
ut_ad(this == &buf_dblwr);
const uint32_t size= block_size();
const uint32_t size= block_size;

/* We do the file i/o past the buffer pool */
byte *read_buf= static_cast<byte*>(aligned_malloc(srv_page_size,
Expand Down Expand Up @@ -488,7 +489,6 @@ void buf_dblwr_t::write_completed()
mysql_mutex_lock(&mutex);

ut_ad(is_created());
ut_ad(srv_use_doublewrite_buf);
ut_ad(batch_running);
slot *flush_slot= active_slot == &slots[0] ? &slots[1] : &slots[0];
ut_ad(flush_slot->reserved);
Expand Down Expand Up @@ -574,7 +574,7 @@ static void buf_dblwr_check_block(const buf_page_t *bpage)
bool buf_dblwr_t::flush_buffered_writes(const ulint size)
{
mysql_mutex_assert_owner(&mutex);
ut_ad(size == block_size());
ut_ad(size == block_size);

for (;;)
{
Expand Down Expand Up @@ -647,7 +647,6 @@ static void *get_frame(const IORequest &request)
void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request)
{
ut_ad(this == &buf_dblwr);
ut_ad(srv_use_doublewrite_buf);
ut_ad(is_created());
ut_ad(!srv_read_only_mode);
ut_ad(!request.bpage);
Expand All @@ -670,8 +669,14 @@ void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request)
pages_written+= flush_slot->first_free;
mysql_mutex_unlock(&mutex);

/* Now flush the doublewrite buffer data to disk */
fil_system.sys_space->flush<false>();
/* Make the doublewrite durable. Note: The doublewrite buffer is
always in the first file of the system tablespace. We will not
bother about fil_system.unflushed_spaces, which can result in a
redundant call during fil_flush_file_spaces() in
log_checkpoint(). Writes to the system tablespace should be rare,
except when executing DDL or using the non-default settings
innodb_file_per_table=OFF or innodb_undo_tablespaces=0. */
os_file_flush(request.node->handle);

/* The writes have been flushed to disk now and in recovery we will
find them in the doublewrite buffer blocks. Next, write the data pages. */
Expand Down Expand Up @@ -714,17 +719,18 @@ posted, and also when we may have to wait for a page latch!
Otherwise a deadlock of threads can occur. */
void buf_dblwr_t::flush_buffered_writes()
{
if (!is_created() || !srv_use_doublewrite_buf)
mysql_mutex_lock(&mutex);

if (!in_use() && active_slot->first_free == 0)
{
mysql_mutex_unlock(&mutex);
fil_flush_file_spaces();
return;
}

ut_ad(!srv_read_only_mode);
const ulint size= block_size();

mysql_mutex_lock(&mutex);
if (!flush_buffered_writes(size))
if (!flush_buffered_writes(block_size))
mysql_mutex_unlock(&mutex);
}

Expand All @@ -734,8 +740,6 @@ flush_buffered_writes() will be invoked to make space.
@param size payload size in bytes */
void buf_dblwr_t::add_to_batch(const IORequest &request, size_t size)
{
ut_ad(request.is_async());
ut_ad(request.is_write());
ut_ad(request.bpage);
ut_ad(request.bpage->in_file());
ut_ad(request.node);
Expand All @@ -744,7 +748,7 @@ void buf_dblwr_t::add_to_batch(const IORequest &request, size_t size)
ut_ad(request.node->space->referenced());
ut_ad(!srv_read_only_mode);

const ulint buf_size= 2 * block_size();
const ulint buf_size= 2 * block_size;

mysql_mutex_lock(&mutex);

Expand Down Expand Up @@ -773,7 +777,7 @@ void buf_dblwr_t::add_to_batch(const IORequest &request, size_t size)
ut_ad(active_slot->reserved == active_slot->first_free);
ut_ad(active_slot->reserved < buf_size);
new (active_slot->buf_block_arr + active_slot->first_free++)
element{request, size};
element{request.doublewritten(), size};
active_slot->reserved= active_slot->first_free;

if (active_slot->first_free != buf_size ||
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ void buf_page_write_complete(const IORequest &request, bool error)
else
{
bpage->write_complete(persistent, error, state);
if (state < buf_page_t::WRITE_FIX_REINIT &&
request.node->space->use_doublewrite())
if (request.is_doublewritten())
{
ut_ad(state < buf_page_t::WRITE_FIX_REINIT);
ut_ad(persistent);
buf_dblwr.write_completed();
}
Expand Down
Loading