mariadb/mysql-test/suite/mariabackup
Marko Mäkelä 3cef4f8f0f MDEV-515 Reduce InnoDB undo logging for insert into empty table
We implement an idea that was suggested by Michael 'Monty' Widenius
in October 2017: When InnoDB is inserting into an empty table or partition,
we can write a single undo log record TRX_UNDO_EMPTY, which will cause
ROLLBACK to clear the table.

For this to work, the insert into an empty table or partition must be
covered by an exclusive table lock that will be held until the transaction
has been committed or rolled back, or the INSERT operation has been
rolled back (and the table is empty again), in lock_table_x_unlock().

Clustered index records that are covered by the TRX_UNDO_EMPTY record
will carry DB_TRX_ID=0 and DB_ROLL_PTR=1<<55, and thus they cannot
be distinguished from what MDEV-12288 leaves behind after purging the
history of row-logged operations.

Concurrent non-locking reads must be adjusted: If the read view was
created before the INSERT into an empty table, then we must continue
to imagine that the table is empty, and not try to read any records.
If the read view was created after the INSERT was committed, then
all records must be visible normally. To implement this, we introduce
the field dict_table_t::bulk_trx_id.

This special handling only applies to the very first INSERT statement
of a transaction for the empty table or partition. If a subsequent
statement in the transaction is modifying the initially empty table again,
we must enable row-level undo logging, so that we will be able to
roll back to the start of the statement in case of an error (such as
duplicate key).

INSERT IGNORE will continue to use row-level logging and locking, because
implementing it would require the ability to roll back the latest row.
Since the undo log that we write only allows us to roll back the entire
statement, we cannot support INSERT IGNORE. We will introduce a
handler::extra() parameter HA_EXTRA_IGNORE_INSERT to indicate to storage
engines that INSERT IGNORE is being executed.

In many test cases, we add an extra record to the table, so that during
the 'interesting' part of the test, row-level locking and logging will
be used.

Replicas will continue to use row-level logging and locking until
MDEV-24622 has been addressed. Likewise, this optimization will be
disabled in Galera cluster until MDEV-24623 enables it.

dict_table_t::bulk_trx_id: The latest active or committed transaction
that initiated an insert into an empty table or partition.
Protected by exclusive table lock and a clustered index leaf page latch.

ins_node_t::bulk_insert: Whether bulk insert was initiated.

trx_t::mod_tables: Use C++11 style accessors (emplace instead of insert).
Unlike earlier, this collection will cover also temporary tables.

trx_mod_table_time_t: Add start_bulk_insert(), end_bulk_insert(),
is_bulk_insert(), was_bulk_insert().

trx_undo_report_row_operation(): Before accessing any undo log pages,
invoke trx->mod_tables.emplace() in order to determine whether undo
logging was disabled, or whether this is the first INSERT and we are
supposed to write a TRX_UNDO_EMPTY record.

row_ins_clust_index_entry_low(): If we are inserting into an empty
clustered index leaf page, set the ins_node_t::bulk_insert flag for
the subsequent trx_undo_report_row_operation() call.

lock_rec_insert_check_and_lock(), lock_prdt_insert_check_and_lock():
Remove the redundant parameter 'flags' that can be checked in the caller.

btr_cur_ins_lock_and_undo(): Simplify the logic. Correctly write
DB_TRX_ID,DB_ROLL_PTR after invoking trx_undo_report_row_operation().

trx_mark_sql_stat_end(), ha_innobase::extra(HA_EXTRA_IGNORE_INSERT),
ha_innobase::external_lock(): Invoke trx_t::end_bulk_insert() so that
the next statement will not be covered by table-level undo logging.

ReadView::changes_visible(trx_id_t) const: New accessor for the case
where the trx_id_t is not read from a potentially corrupted index page
but directly from the memory. In this case, we can skip a sanity check.

row_sel(), row_sel_try_search_shortcut(), row_search_mvcc():
row_sel_try_search_shortcut_for_mysql(),
row_merge_read_clustered_index(): Check dict_table_t::bulk_trx_id.

row_sel_clust_sees(): Replaces lock_clust_rec_cons_read_sees().

lock_sec_rec_cons_read_sees(): Replaced with lower-level code.

btr_root_page_init(): Refactored from btr_create().

dict_index_t::clear(), dict_table_t::clear(): Empty an index or table,
for the ROLLBACK of an INSERT operation.

ROW_T_EMPTY, ROW_OP_EMPTY: Note a concurrent ROLLBACK of an INSERT
into an empty table.

This is joint work with Thirunarayanan Balathandayuthapani,
who created a working prototype.
Thanks to Matthias Leich for extensive testing.
2021-01-25 18:41:27 +02:00
..
include Merge 10.3 into 10.4 2020-12-01 19:51:14 +02:00
absolute_ibdata_paths.opt MDEV-19534 Make innodb_checksum_algorithm=full_crc32 by default, and remove innodb_checksums 2019-05-22 08:53:28 +03:00
absolute_ibdata_paths.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
absolute_ibdata_paths.test MDEV-12711 mariabackup --backup is refused for multi-file system tablespace 2019-03-26 13:51:15 +02:00
apply-log-only-incr.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
apply-log-only-incr.test MDEV-18215: mariabackup does not report unknown command line options 2020-06-14 13:23:07 +03:00
apply-log-only.result MDEV-15143 InnoDB: Rollback of trx with id 0 completed 2018-01-31 12:06:46 +02:00
apply-log-only.test MDEV-18215: mariabackup does not report unknown command line options 2020-06-14 13:23:07 +03:00
auth_plugin_win.opt fix auth_plugin_win test 2017-08-22 13:05:56 +00:00
auth_plugin_win.result MDEV-13608 : set client plugin directory with mysql_options() 2017-08-21 17:16:12 +00:00
auth_plugin_win.test MDEV-13608 : set client plugin directory with mysql_options() 2017-08-21 17:16:12 +00:00
backup_grants.result MDEV-18544 "missing required privilege PROCESS on *.*" using mariabackup for SST 2019-05-02 14:25:24 +01:00
backup_grants.test MDEV-18544 "missing required privilege PROCESS on *.*" using mariabackup for SST 2019-05-02 14:25:24 +01:00
backup_lock_wait_timeout.result MDEV-20230: mariabackup --ftwrl-wait-timeout never times out on explicit 2020-04-27 22:10:50 +03:00
backup_lock_wait_timeout.test MDEV-20230: mariabackup --ftwrl-wait-timeout never times out on explicit 2020-04-27 22:10:50 +03:00
backup_ssl.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
backup_ssl.test MDEV-16105: Mariabackup does not support SSL 2018-05-08 19:52:08 +00:00
big_innodb_log.result Merge 10.3 into 10.4 2019-08-14 18:06:51 +03:00
big_innodb_log.test MDEV-20421: big_innodb_log reliably fails on buildbot Windows 2019-09-06 12:05:20 +03:00
binlog.result MDEV-15158 On commit, do not write to the TRX_SYS page 2018-02-20 21:36:36 +02:00
binlog.test MDEV-18215: mariabackup does not report unknown command line options 2020-06-14 13:23:07 +03:00
compress_qpress.result Fix compress_qpress result file, broken in b5615eff0d 2019-08-27 20:46:05 +02:00
compress_qpress.test MDEV-14102 restore --remove-original options for mariabackup 2017-10-23 10:30:17 +00:00
create_during_backup.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
create_during_backup.test MDEV-16791 mariabackup : Support DDL commands during backup 2018-08-14 15:11:13 +01:00
create_with_data_directory_during_backup.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
create_with_data_directory_during_backup.test MDEV-16791 mariabackup : Support DDL commands during backup 2018-08-14 15:11:13 +01:00
data_directory.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
data_directory.test MDEV-12108 Fix backup for Innodb tables with DATA DIRECTORY 2017-11-06 19:21:23 +00:00
drop_table_during_backup.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
drop_table_during_backup.test MDEV-18185 - mariabackup - fix specific case of table rename handing in prepare. 2019-01-09 22:28:31 +01:00
encrypted_page_compressed.opt MDEV-18025 Mariabackup fails to detect corrupted page_compressed=1 tables 2018-12-18 18:07:17 +05:30
encrypted_page_compressed.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
encrypted_page_compressed.test MDEV-18644: Support full_crc32 for page_compressed 2019-03-18 14:08:43 +02:00
encrypted_page_corruption,full_crc32.rdiff MDEV-12112/MDEV-12026: Enable the test for full_crc32 2019-09-10 12:43:48 +03:00
encrypted_page_corruption.combinations MDEV-12112/MDEV-12026: Enable the test for full_crc32 2019-09-10 12:43:48 +03:00
encrypted_page_corruption.opt MDEV-12112/MDEV-12026: Enable the test for full_crc32 2019-09-10 12:43:48 +03:00
encrypted_page_corruption.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
encrypted_page_corruption.test MDEV-12112/MDEV-12026: Enable the test for full_crc32 2019-09-10 12:43:48 +03:00
extra_lsndir.result MDEV-15071 backup does not store xtrabackup_info in the --extra-lsndir directory 2018-02-15 21:08:18 +00:00
extra_lsndir.test MDEV-15071 backup does not store xtrabackup_info in the --extra-lsndir directory 2018-02-15 21:08:18 +00:00
extra_lsndir_stream.result MDEV-18438 Don't stream xtrabackup_info of extra-lsndir 2019-09-19 17:47:54 +03:00
extra_lsndir_stream.test MDEV-18438 Don't stream xtrabackup_info of extra-lsndir 2019-09-19 17:47:54 +03:00
filekeys-data.enc MDEV-9566 MariaBackup test suite 2017-04-27 19:12:40 +02:00
filekeys-data.key MDEV-9566 MariaBackup test suite 2017-04-27 19:12:40 +02:00
full_backup.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
full_backup.test MDEV-12548 Initial implementation of Mariabackup for MariaDB 10.2 2017-07-05 11:43:28 +03:00
huge_lsn.combinations MDEV-12026: Implement innodb_checksum_algorithm=full_crc32 2019-02-19 18:50:19 +02:00
huge_lsn.opt MDEV-18105 Mariabackup fails to copy encrypted InnoDB system tablespace if LSN>4G 2018-12-29 22:59:20 +02:00
huge_lsn.result Merge 10.4 into 10.5 2020-07-15 14:51:22 +03:00
huge_lsn.test Merge 10.4 into 10.5 2020-07-15 14:51:22 +03:00
incremental_backup.result MDEV-515 Reduce InnoDB undo logging for insert into empty table 2021-01-25 18:41:27 +02:00
incremental_backup.test MDEV-515 Reduce InnoDB undo logging for insert into empty table 2021-01-25 18:41:27 +02:00
incremental_ddl_before_backup.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
incremental_ddl_before_backup.test MDEV-18215: mariabackup does not report unknown command line options 2020-06-14 13:23:07 +03:00
incremental_ddl_during_backup.result Merge 10.3 into 10.4 2020-11-03 14:49:17 +02:00
incremental_ddl_during_backup.test Merge 10.3 into 10.4 2020-12-01 19:51:14 +02:00
incremental_encrypted.opt MDEV-9566 MariaBackup test suite 2017-04-27 19:12:40 +02:00
incremental_encrypted.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
incremental_encrypted.test MDEV-14188 mariabackup.incremental_encrypted wrong result 2018-07-06 09:07:52 +03:00
incremental_rocksdb.opt MDEV-18204 Fix rocksdb incremental backup 2019-02-18 18:59:05 +01:00
incremental_rocksdb.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
incremental_rocksdb.test MDEV-18204 Fix rocksdb incremental backup 2019-02-18 18:59:05 +01:00
innodb_redo_log_overwrite.opt MDEV-14425 deprecate and ignore innodb_log_files_in_group 2020-02-19 12:21:59 +03:00
innodb_redo_log_overwrite.result MDEV-21255: Deadlock of parallel slave and mariabackup (with failed log 2019-12-12 13:28:30 +03:00
innodb_redo_log_overwrite.test MDEV-21255: Deadlock of parallel slave and mariabackup (with failed log 2019-12-12 13:28:30 +03:00
innodb_redo_overwrite.opt Merge 10.4 into 10.5 2020-09-23 11:32:43 +03:00
innodb_redo_overwrite.result Merge 10.4 into 10.5 2020-09-23 11:32:43 +03:00
innodb_redo_overwrite.test Merge 10.4 into 10.5 2020-09-23 11:32:43 +03:00
lock_ddl_per_table.opt Allow tests to work with cmake -DPLUGIN_PARTITION=NO 2018-05-29 17:14:34 +03:00
lock_ddl_per_table.result add updated result file for MDEV-13802 test. 2017-09-15 20:44:03 +00:00
lock_ddl_per_table.test Allow tests to work with cmake -DPLUGIN_PARTITION=NO 2018-05-29 17:14:34 +03:00
log_checksum_mismatch.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
log_checksum_mismatch.test MDEV-18663 Tests : use --core-file if mariabackup output is redirected to a file 2019-02-20 13:26:48 +01:00
log_page_corruption.opt MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered 2020-12-01 08:08:57 +03:00
log_page_corruption.result Merge 10.3 into 10.4 2020-12-01 19:51:14 +02:00
log_page_corruption.test MDEV-22929 MariaBackup option to report and/or continue when corruption is encountered 2020-12-01 08:08:57 +03:00
mdev-14447.opt MDEV-14447 mariabackup incremental incorrectly extends system tablespace 2017-11-24 00:01:29 +00:00
mdev-14447.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
mdev-14447.test Fix the test mariabackup.mdev-14447 2020-06-18 12:13:31 +03:00
mdev-18438.result MDEV-18438 Don't stream xtrabackup_info of extra-lsndir 2019-09-19 17:47:54 +03:00
mdev-18438.test MDEV-18438 Don't stream xtrabackup_info of extra-lsndir 2019-09-19 17:47:54 +03:00
missing_ibd.result Merge 10.3 into 10.4 2019-07-02 21:44:58 +03:00
missing_ibd.test MDEV-19886 InnoDB returns misleading ER_NO_SUCH_TABLE_IN_ENGINE 2019-06-27 15:39:04 +03:00
nolock_ddl_during_backup_end.result MDEV-17192 Backup with -no-lock should fail, if DDL is detected at the end of backup 2018-09-14 09:36:02 +01:00
nolock_ddl_during_backup_end.test MDEV-17192 Backup with -no-lock should fail, if DDL is detected at the end of backup 2018-09-14 09:36:02 +01:00
options_check.result MDEV-22983: Mariabackup's --help option disappeared 2020-07-01 23:30:44 +03:00
options_check.test MDEV-22983: Mariabackup's --help option disappeared 2020-07-01 23:30:44 +03:00
page_compression_level.result Merge 10.1 into 10.2 2019-03-08 20:45:45 +02:00
page_compression_level.test MDEV-18855 Mariabackup should fetch innodb_compression_level from running server 2019-03-08 16:00:08 +05:30
partial.result MDEV-13466 Implement --export option for MariaDB Backup 2017-09-07 22:54:06 +00:00
partial.test MDEV-20703: mariabackup creates binlog files in server binlog directory on --prepare --export step 2019-10-01 13:57:24 +03:00
partial_exclude.opt MDEV-19347: Mariabackup does not honor ignore_db_dirs from server 2020-04-21 10:34:37 +03:00
partial_exclude.result MDEV-19347: Mariabackup does not honor ignore_db_dirs from server 2020-04-21 10:34:37 +03:00
partial_exclude.test MDEV-19347: Mariabackup does not honor ignore_db_dirs from server 2020-04-21 10:34:37 +03:00
partition_datadir.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
partition_datadir.test Allow tests to work with cmake -DPLUGIN_PARTITION=NO 2018-05-29 17:14:34 +03:00
partition_partial.opt Add forgotten .opt file. 2018-12-21 19:45:30 +01:00
partition_partial.result Add test for partial backup for partitioned table. 2018-12-21 16:04:16 +01:00
partition_partial.test Add test for partial backup for partitioned table. 2018-12-21 16:04:16 +01:00
recreate_table_during_backup.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
recreate_table_during_backup.test MDEV-16791 mariabackup : Support DDL commands during backup 2018-08-14 15:11:13 +01:00
rename_during_backup.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
rename_during_backup.test MDEV-18201 : mariabackup- fix processing of rename/create sequence in prepare 2019-01-10 19:35:45 +01:00
rename_during_mdl_lock.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
rename_during_mdl_lock.test MDEV-16791 mariabackup : Support DDL commands during backup 2018-08-14 15:11:13 +01:00
rpl_slave_info.result MDEV-19264 Better support MariaDB GTID for Mariabackup's --slave-info option 2020-09-14 11:14:50 +03:00
rpl_slave_info.test MDEV-19264 Better support MariaDB GTID for Mariabackup's --slave-info option 2020-09-14 11:14:50 +03:00
skip_innodb.opt MDEV-17149 mariabackup hangs if innodb is not started 2018-09-06 15:31:29 +01:00
skip_innodb.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
skip_innodb.test MDEV-17149 mariabackup hangs if innodb is not started 2018-09-06 15:31:29 +01:00
small_ibd.result MDEV-9566 MariaBackup test suite 2017-04-27 19:12:40 +02:00
small_ibd.test MDEV-12548 Initial implementation of Mariabackup for MariaDB 10.2 2017-07-05 11:43:28 +03:00
suite.opt MDEV-16791 mariabackup : Support DDL commands during backup 2018-08-14 15:11:13 +01:00
suite.pm MDEV-18565 Galera mtr-suite fails if galera library is not installed 2020-04-27 09:22:36 +02:00
system_versioning.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
system_versioning.test remove "Transaction-based system versioning is EXPERIMENTAL" warning 2018-01-13 02:01:34 +01:00
truncate_during_backup.result MDEV-13564: Refuse MLOG_TRUNCATE in mariabackup 2018-08-16 16:10:18 +03:00
truncate_during_backup.test MDEV-13564 Mariabackup does not work with TRUNCATE 2018-09-07 22:10:02 +03:00
undo_space_id.opt Merge branch '10.2' into 10.3 2018-09-28 16:37:06 +02:00
undo_space_id.result MDEV-21216 InnoDB does dirty read of TRX_SYS page before recovery 2019-12-04 15:34:28 +02:00
undo_space_id.test Merge 10.4 into 10.5 2020-06-18 13:58:54 +03:00
unencrypted_page_compressed.result Merge 10.3 into 10.4 2019-04-05 11:41:03 +03:00
unencrypted_page_compressed.test MDEV-18663 Tests : use --core-file if mariabackup output is redirected to a file 2019-02-20 13:26:48 +01:00
unsupported_redo.result Re-enable the test mariabackup.unsupported_redo 2018-08-16 16:09:51 +03:00
unsupported_redo.test Re-enable the test mariabackup.unsupported_redo 2018-08-16 16:09:51 +03:00
xb_aws_key_management.opt AWS Key Management : Introduce "mock" variable, available in debug build. 2017-08-28 18:28:07 +00:00
xb_aws_key_management.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
xb_aws_key_management.test Tests : Fix result file 2018-02-01 12:50:58 +00:00
xb_compressed_encrypted.opt MDEV-24426 fil_crypt_thread keep spinning even if innodb_encryption_rotate_key_age=0 2020-12-17 13:46:21 +02:00
xb_compressed_encrypted.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
xb_compressed_encrypted.test Reduce a test so that it fails less frequently on buildbot 2017-07-06 23:14:39 +03:00
xb_file_key_management.opt MDEV-9566 MariaBackup test suite 2017-04-27 19:12:40 +02:00
xb_file_key_management.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
xb_file_key_management.test MDEV-13311 Presence of old logs in 10.2.7 will corrupt restored instance (change in behavior) 2017-10-10 15:54:11 +03:00
xb_fulltext_encrypted.opt MDEV-9566 MariaBackup test suite 2017-04-27 19:12:40 +02:00
xb_fulltext_encrypted.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
xb_fulltext_encrypted.test MDEV-18215: mariabackup does not report unknown command line options 2020-06-14 13:23:07 +03:00
xb_history.result MDEV-9566 MariaBackup test suite 2017-04-27 19:12:40 +02:00
xb_history.test MDEV-12548 Initial implementation of Mariabackup for MariaDB 10.2 2017-07-05 11:43:28 +03:00
xb_page_compress.result MDEV-9566 MariaBackup test suite 2017-04-27 19:12:40 +02:00
xb_page_compress.test MDEV-13466 Implement --export option for MariaDB Backup 2017-09-07 22:54:06 +00:00
xb_partition.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
xb_partition.test MDEV-18215: mariabackup does not report unknown command line options 2020-06-14 13:23:07 +03:00
xb_rocksdb.opt MDEV-13122 Backup myrocksdb with mariabackup. 2018-06-07 15:13:54 +01:00
xb_rocksdb.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
xb_rocksdb.test MDEV-13122 Backup myrocksdb with mariabackup. 2018-06-07 15:13:54 +01:00
xb_rocksdb_datadir.opt MDEV-13122 Backup myrocksdb with mariabackup. 2018-06-07 15:13:54 +01:00
xb_rocksdb_datadir.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
xb_rocksdb_datadir.test MDEV-13122 Backup myrocksdb with mariabackup. 2018-06-07 15:13:54 +01:00
xb_rocksdb_datadir_debug.opt MDEV-13122 Backup myrocksdb with mariabackup. 2018-06-07 15:13:54 +01:00
xb_rocksdb_datadir_debug.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
xb_rocksdb_datadir_debug.test MDEV-13122 Backup myrocksdb with mariabackup. 2018-06-07 15:13:54 +01:00
xbstream.result Write information about restart in .result 2019-04-01 19:47:24 +03:00
xbstream.test MDEV-12548 Initial implementation of Mariabackup for MariaDB 10.2 2017-07-05 11:43:28 +03:00