summaryrefslogtreecommitdiff
path: root/storage/innobase/include/fil0fil.h
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/include/fil0fil.h
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/include/fil0fil.h')
-rw-r--r--storage/innobase/include/fil0fil.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index c6b6ad92388..e738931485e 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -955,6 +955,37 @@ fil_space_t* fil_truncate_prepare(ulint space_id);
void fil_truncate_log(fil_space_t* space, ulint size, mtr_t* mtr)
MY_ATTRIBUTE((nonnull));
+/** Truncate the tablespace to needed size.
+@param[in] space_id id of tablespace to truncate
+@param[in] size_in_pages truncate size.
+@return true if truncate was successful. */
+bool
+fil_truncate_tablespace(
+ ulint space_id,
+ ulint size_in_pages);
+
+/*******************************************************************//**
+Prepare for truncating a single-table tablespace. The tablespace
+must be cached in the memory cache.
+1) Check pending operations on a tablespace;
+2) Remove all insert buffer entries for the tablespace;
+@return DB_SUCCESS or error */
+dberr_t
+fil_prepare_for_truncate(
+/*=====================*/
+ ulint id); /*!< in: space id */
+
+/** Reinitialize the original tablespace header with the same space id
+for single tablespace
+@param[in] table table belongs to the tablespace
+@param[in] size size in blocks
+@param[in] trx Transaction covering truncate */
+void
+fil_reinit_space_header_for_table(
+ dict_table_t* table,
+ ulint size,
+ trx_t* trx);
+
/*******************************************************************//**
Closes a single-table tablespace. The tablespace must be cached in the
memory cache. Free all pages used by the tablespace.