summaryrefslogtreecommitdiff
path: root/storage/innobase/handler/ha_innodb.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-10-10 19:19:29 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-10-11 08:17:04 +0300
commit3448ceb02a00f4784d41e3074fb3508d8a79ae48 (patch)
tree2e1bc12961a13bd969c1877f052829fdd9ab1a03 /storage/innobase/handler/ha_innodb.cc
parent07815d9555b099482f8877ec700bbc39d1d553dd (diff)
downloadmariadb-git-3448ceb02a00f4784d41e3074fb3508d8a79ae48.tar.gz
MDEV-13564: Implement innodb_unsafe_truncate=ON for compatibility
While MariaDB Server 10.2 is not really guaranteed to be compatible with Percona XtraBackup 2.4 (for example, the MySQL 5.7 undo log format change that could be present in XtraBackup, but was reverted from MariaDB in MDEV-12289), we do not want to disrupt users who have deployed xtrabackup and MariaDB Server 10.2 in their environments. With this change, MariaDB 10.2 will continue to use the backup-unsafe TRUNCATE TABLE code, so that neither the undo log nor the redo log formats will change in an incompatible way. Undo tablespace truncation will keep using the redo log only. Recovery or backup with old code will fail to shrink the undo tablespace files, but the contents will be recovered just fine. In the MariaDB Server 10.2 series only, we introduce the configuration parameter innodb_unsafe_truncate and make it ON by default. To allow MariaDB Backup (mariabackup) to work properly with TRUNCATE TABLE operations, use loose_innodb_unsafe_truncate=OFF. MariaDB Server 10.3.10 and later releases will always use the backup-safe TRUNCATE TABLE, and this parameter will not be added there. recv_recovery_rollback_active(): Skip row_mysql_drop_garbage_tables() unless innodb_unsafe_truncate=OFF. It is too unsafe to drop orphan tables if RENAME operations are not transactional within InnoDB. LOG_HEADER_FORMAT_10_3: Replaces LOG_HEADER_FORMAT_CURRENT. log_init(), log_group_file_header_flush(), srv_prepare_to_delete_redo_log_files(), innobase_start_or_create_for_mysql(): Choose the redo log format and subformat based on the value of innodb_unsafe_truncate.
Diffstat (limited to 'storage/innobase/handler/ha_innodb.cc')
-rw-r--r--storage/innobase/handler/ha_innodb.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 49f51c78f73..26e169b1ec3 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -13452,6 +13452,37 @@ int ha_innobase::truncate()
update_thd();
+ if (srv_57_truncate) {
+ if (!trx_is_started(m_prebuilt->trx)) {
+ ++m_prebuilt->trx->will_lock;
+ }
+
+ dberr_t err = row_truncate_table_for_mysql(
+ m_prebuilt->table, m_prebuilt->trx);
+
+ int error;
+
+ switch (err) {
+ case DB_TABLESPACE_DELETED:
+ case DB_TABLESPACE_NOT_FOUND:
+ ib_senderrf(
+ m_prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR,
+ err == DB_TABLESPACE_DELETED
+ ? ER_TABLESPACE_DISCARDED
+ : ER_TABLESPACE_MISSING,
+ table->s->table_name.str);
+ error = HA_ERR_TABLESPACE_MISSING;
+ break;
+ default:
+ error = convert_error_code_to_mysql(
+ err, m_prebuilt->table->flags,
+ m_prebuilt->trx->mysql_thd);
+ break;
+ }
+ table->status = STATUS_NOT_FOUND;
+ DBUG_RETURN(error);
+ }
+
HA_CREATE_INFO info;
mem_heap_t* heap = mem_heap_create(1000);
dict_table_t* ib_table = m_prebuilt->table;
@@ -20663,6 +20694,11 @@ 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,
+ PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
+ "Use backup-unsafe TRUNCATE TABLE for compatibility with xtrabackup (on by default)",
+ NULL, NULL, TRUE);
+
static MYSQL_SYSVAR_BOOL(cmp_per_index_enabled, srv_cmp_per_index_enabled,
PLUGIN_VAR_OPCMDARG,
"Enable INFORMATION_SCHEMA.innodb_cmp_per_index,"
@@ -21042,6 +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(io_capacity),
MYSQL_SYSVAR(io_capacity_max),
MYSQL_SYSVAR(page_cleaners),