Skip to content

Commit

Permalink
MDEV-23076 Misleading "InnoDB: using atomic writes"
Browse files Browse the repository at this point in the history
As suggested by Vladislav Vaintroub, let us remove misleading
and malformatted startup messages.

Even if the global variable srv_use_atomic_writes were set, we would
still invoke my_test_if_atomic_write() to check if writes are atomic
with a particular page size.

When using the default innodb_page_size=16k, page writes should be
atomic on NTFS when using ROW_FORMAT=COMPRESSED and KEY_BLOCK_SIZE<=4.

Disabling srv_use_atomic_writes when innodb_file_per_table=OFF does
not make sense, because that is a dynamic parameter.

We also correct the documentation string of innodb_use_atomic_writes
and remove the duplicate variable innobase_use_atomic_writes.
  • Loading branch information
dr-m committed Mar 22, 2021
1 parent 0f8caad commit 56274bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion mysql-test/suite/sys_vars/r/sysvars_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -2591,7 +2591,7 @@ SESSION_VALUE NULL
DEFAULT_VALUE ON
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Enable atomic writes, instead of using the doublewrite buffer, for files on devices that supports atomic writes. To use this option one must use file_per_table=1, flush_method=O_DIRECT and use_fallocate=1. This option only works on Linux with either FusionIO cards using the directFS filesystem or with Shannon cards using any file system.
VARIABLE_COMMENT Enable atomic writes, instead of using the doublewrite buffer, for files on devices that supports atomic writes. This option only works on Linux with either FusionIO cards using the directFS filesystem or with Shannon cards using any file system.
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
Expand Down
20 changes: 4 additions & 16 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ static char* innobase_server_stopword_table;
values */

static my_bool innobase_file_format_check;
static my_bool innobase_use_atomic_writes;
static my_bool innobase_use_fallocate;
static my_bool innobase_use_doublewrite;
static my_bool innobase_use_checksums;
Expand Down Expand Up @@ -4314,29 +4313,20 @@ innobase_init(
ib::warn() << deprecated_idle_flush_pct;
}

srv_use_atomic_writes
= innobase_use_atomic_writes && my_may_have_atomic_write;
if (srv_use_atomic_writes && !srv_file_per_table)
{
fprintf(stderr, "InnoDB: Disabling atomic_writes as file_per_table is not used.\n");
srv_use_atomic_writes= 0;
}

if (srv_use_atomic_writes) {
fprintf(stderr, "InnoDB: using atomic writes.\n");
#ifndef _WIN32
if (srv_use_atomic_writes && my_may_have_atomic_write) {
/*
Force O_DIRECT on Unixes (on Windows writes are always
unbuffered)
*/
#ifndef _WIN32
if (!innobase_file_flush_method ||
!strstr(innobase_file_flush_method, "O_DIRECT")) {
innobase_file_flush_method =
srv_file_flush_method_str = (char*)"O_DIRECT";
fprintf(stderr, "InnoDB: using O_DIRECT due to atomic writes.\n");
}
#endif
}
#endif

#ifdef HAVE_PSI_INTERFACE
/* Register keys with MySQL performance schema */
Expand Down Expand Up @@ -20016,12 +20006,10 @@ static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
" Disable with --skip-innodb-doublewrite.",
NULL, NULL, TRUE);

static MYSQL_SYSVAR_BOOL(use_atomic_writes, innobase_use_atomic_writes,
static MYSQL_SYSVAR_BOOL(use_atomic_writes, srv_use_atomic_writes,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Enable atomic writes, instead of using the doublewrite buffer, for files "
"on devices that supports atomic writes. "
"To use this option one must use "
"file_per_table=1, flush_method=O_DIRECT and use_fallocate=1. "
"This option only works on Linux with either FusionIO cards using "
"the directFS filesystem or with Shannon cards using any file system.",
NULL, NULL, TRUE);
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/handler/ha_innodb.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2020, MariaDB Corporation.
Copyright (c) 2013, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -46,7 +46,7 @@ struct ha_table_option_struct
uint atomic_writes; /*!< Use atomic writes for this
table if this options is ON or
in DEFAULT if
srv_use_atomic_writes=1.
innodb_use_atomic_writes.
Atomic writes are not used if
value OFF.*/
uint encryption; /*!< DEFAULT, ON, OFF */
Expand Down

0 comments on commit 56274bd

Please sign in to comment.