Commit 6319c0b5 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-13564: Replace innodb_unsafe_truncate with innodb_safe_truncate

Rename the 10.2-specific configuration option innodb_unsafe_truncate
to innodb_safe_truncate, and invert its value.

The default (for now) is innodb_safe_truncate=OFF, to avoid
disrupting users with an undo and redo log format change within
a Generally Available (GA) release series.
parent 3448ceb0
--skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-innodb-sys-tables
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-innodb-sys-tables
--loose-innodb-sys-tablespaces
--loose-innodb-sys-datafiles
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
--loose-skip-innodb-unsafe-truncate
--loose-innodb-safe-truncate=1
......@@ -2400,6 +2400,20 @@ NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_SAFE_TRUNCATE
SESSION_VALUE NULL
GLOBAL_VALUE OFF
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE OFF
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Use backup-safe TRUNCATE TABLE and crash-safe RENAME (incompatible with older MariaDB 10.2; OFF by default)
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_SAVED_PAGE_NUMBER_DEBUG
SESSION_VALUE NULL
GLOBAL_VALUE 0
......@@ -2974,20 +2988,6 @@ NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INNODB_UNSAFE_TRUNCATE
SESSION_VALUE NULL
GLOBAL_VALUE ON
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE ON
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT Use backup-unsafe TRUNCATE TABLE for compatibility with xtrabackup (on by default)
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_USE_ATOMIC_WRITES
SESSION_VALUE NULL
GLOBAL_VALUE ON
......
......@@ -13452,7 +13452,7 @@ int ha_innobase::truncate()
update_thd();
if (srv_57_truncate) {
if (!srv_safe_truncate) {
if (!trx_is_started(m_prebuilt->trx)) {
++m_prebuilt->trx->will_lock;
}
......@@ -20694,10 +20694,10 @@ static MYSQL_SYSVAR_BOOL(read_only, srv_read_only_mode,
"Start InnoDB in read only mode (off by default)",
NULL, NULL, FALSE);
static MYSQL_SYSVAR_BOOL(unsafe_truncate, srv_57_truncate,
static MYSQL_SYSVAR_BOOL(safe_truncate, srv_safe_truncate,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
"Use backup-unsafe TRUNCATE TABLE for compatibility with xtrabackup (on by default)",
NULL, NULL, TRUE);
"Use backup-safe TRUNCATE TABLE and crash-safe RENAME (incompatible with older MariaDB 10.2; OFF by default)",
NULL, NULL, FALSE);
static MYSQL_SYSVAR_BOOL(cmp_per_index_enabled, srv_cmp_per_index_enabled,
PLUGIN_VAR_OPCMDARG,
......@@ -21078,7 +21078,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(random_read_ahead),
MYSQL_SYSVAR(read_ahead_threshold),
MYSQL_SYSVAR(read_only),
MYSQL_SYSVAR(unsafe_truncate),
MYSQL_SYSVAR(safe_truncate),
MYSQL_SYSVAR(io_capacity),
MYSQL_SYSVAR(io_capacity_max),
MYSQL_SYSVAR(page_cleaners),
......
......@@ -256,9 +256,9 @@ extern my_bool high_level_read_only;
/** store to its own file each table created by an user; data
dictionary tables are in the system tablespace 0 */
extern my_bool srv_file_per_table;
/** whether to use the MySQL 5.7 WL#6501 TRUNCATE TABLE implementation
that does not work with backup */
extern my_bool srv_57_truncate;
/** whether to use backup-safe TRUNCATE and crash-safe RENAME
instead of the MySQL 5.7 WL#6501 TRUNCATE TABLE implementation */
extern my_bool srv_safe_truncate;
/** Sleep delay for threads waiting to enter InnoDB. In micro-seconds. */
extern ulong srv_thread_sleep_delay;
/** Maximum sleep delay (in micro-seconds), value of 0 disables it.*/
......
......@@ -790,15 +790,15 @@ log_init(ulint n_files)
log_group_t* group = &log_sys->log;
group->n_files = n_files;
group->subformat = !srv_57_truncate;
if (srv_57_truncate) {
group->format = srv_encrypt_log
? LOG_HEADER_FORMAT_10_2 | LOG_HEADER_FORMAT_ENCRYPTED
: LOG_HEADER_FORMAT_10_2;
} else {
group->subformat = srv_safe_truncate;
if (srv_safe_truncate) {
group->format = srv_encrypt_log
? LOG_HEADER_FORMAT_10_3 | LOG_HEADER_FORMAT_ENCRYPTED
: LOG_HEADER_FORMAT_10_3;
} else {
group->format = srv_encrypt_log
? LOG_HEADER_FORMAT_10_2 | LOG_HEADER_FORMAT_ENCRYPTED
: LOG_HEADER_FORMAT_10_2;
}
group->file_size = srv_log_file_size;
group->state = LOG_GROUP_OK;
......@@ -881,15 +881,15 @@ log_group_file_header_flush(
ut_ad(!recv_no_log_write);
ut_a(nth_file < group->n_files);
ut_ad((group->format & ~LOG_HEADER_FORMAT_ENCRYPTED)
== (srv_57_truncate
? LOG_HEADER_FORMAT_10_2
: LOG_HEADER_FORMAT_10_3));
== (srv_safe_truncate
? LOG_HEADER_FORMAT_10_3
: LOG_HEADER_FORMAT_10_2));
buf = *(group->file_header_bufs + nth_file);
memset(buf, 0, OS_FILE_LOG_BLOCK_SIZE);
mach_write_to_4(buf + LOG_HEADER_FORMAT, group->format);
mach_write_to_4(buf + LOG_HEADER_SUBFORMAT, !srv_57_truncate);
mach_write_to_4(buf + LOG_HEADER_SUBFORMAT, srv_safe_truncate);
mach_write_to_8(buf + LOG_HEADER_START_LSN, start_lsn);
strcpy(reinterpret_cast<char*>(buf) + LOG_HEADER_CREATOR,
LOG_HEADER_CREATOR_CURRENT);
......
......@@ -3769,7 +3769,7 @@ recv_recovery_rollback_active(void)
/* Drop partially created indexes. */
row_merge_drop_temp_indexes();
/* Drop garbage tables. */
if (!srv_57_truncate)
if (srv_safe_truncate)
row_mysql_drop_garbage_tables();
/* Drop any auxiliary tables that were not dropped when the
......
......@@ -4403,7 +4403,7 @@ row_rename_table_for_mysql(
goto funct_exit;
}
if (!table->is_temporary() && !srv_57_truncate) {
if (!table->is_temporary() && srv_safe_truncate) {
err = trx_undo_report_rename(trx, table);
if (err != DB_SUCCESS) {
......
......@@ -152,9 +152,9 @@ my_bool srv_read_only_mode;
/** store to its own file each table created by an user; data
dictionary tables are in the system tablespace 0 */
my_bool srv_file_per_table;
/** whether to use the MySQL 5.7 WL#6501 TRUNCATE TABLE implementation
that does not work with backup */
my_bool srv_57_truncate;
/** whether to use backup-safe TRUNCATE and crash-safe RENAME
instead of the MySQL 5.7 WL#6501 TRUNCATE TABLE implementation */
my_bool srv_safe_truncate;
/** The file format to use on new *.ibd files. */
ulint srv_file_format;
/** Whether to check file format during startup. A value of
......
......@@ -1393,15 +1393,15 @@ srv_prepare_to_delete_redo_log_files(
ulint pending_io = 0;
ulint count = 0;
if (srv_57_truncate) {
if (srv_safe_truncate) {
if ((log_sys->log.format & ~LOG_HEADER_FORMAT_ENCRYPTED)
!= LOG_HEADER_FORMAT_10_2) {
!= LOG_HEADER_FORMAT_10_3
|| log_sys->log.subformat != 1) {
srv_log_file_size = 0;
}
} else {
if ((log_sys->log.format & ~LOG_HEADER_FORMAT_ENCRYPTED)
!= LOG_HEADER_FORMAT_10_3
|| log_sys->log.subformat != 1) {
!= LOG_HEADER_FORMAT_10_2) {
srv_log_file_size = 0;
}
}
......@@ -2399,16 +2399,16 @@ innobase_start_or_create_for_mysql()
} else if (srv_log_file_size_requested == srv_log_file_size
&& srv_n_log_files_found == srv_n_log_files
&& log_sys->log.format
== (srv_57_truncate
== (srv_safe_truncate
? (srv_encrypt_log
? LOG_HEADER_FORMAT_10_2
? LOG_HEADER_FORMAT_10_3
| LOG_HEADER_FORMAT_ENCRYPTED
: LOG_HEADER_FORMAT_10_2)
: LOG_HEADER_FORMAT_10_3)
: (srv_encrypt_log
? LOG_HEADER_FORMAT_10_3
? LOG_HEADER_FORMAT_10_2
| LOG_HEADER_FORMAT_ENCRYPTED
: LOG_HEADER_FORMAT_10_3))
&& log_sys->log.subformat == !srv_57_truncate) {
: LOG_HEADER_FORMAT_10_2))
&& log_sys->log.subformat == srv_safe_truncate) {
/* No need to add or remove encryption,
upgrade, downgrade, or resize. */
} else {
......
......@@ -1938,7 +1938,7 @@ trx_undo_report_rename(trx_t* trx, const dict_table_t* table)
ut_ad(!trx->read_only);
ut_ad(trx->id);
ut_ad(!table->is_temporary());
ut_ad(!srv_57_truncate);
ut_ad(srv_safe_truncate);
trx_rseg_t* rseg = trx->rsegs.m_redo.rseg;
trx_undo_t** pundo = &trx->rsegs.m_redo.insert_undo;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment