mariadb/mysql-test/suite/binlog_in_engine/xa_restart.test
Kristian Nielsen 7081f2a58e Binlog-in-engine: New binlog implementation integrated in InnoDB
Implement an improved binlog implementation that is integrated into
the storage engine. The new implementation is enabled with the
--binlog-storage-engine option. Initially the InnoDB storage engine
implements the binlog.

Integrating the binlog in the storage engine improves performance,
since it makes the InnoDB redo log the single source of truth and
avoids the need for expensive two-phase commit between binlog and
engine. It also makes it possible to disable durability (set
--innodb-flush-log-at-trx-commit=0) to further improve performance,
while still preserving the ability to recover the binlog and database
into a consistent state after a crash.

The new binlog implementation also greatly improves the internal
design and implementation of the binlog, and enables future
enhancements for replication.

This is a squash of the original 11.4-based patch series.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-01-23 03:21:03 +01:00

78 lines
2.3 KiB
Text

--source include/have_binlog_format_row.inc
--source include/have_innodb_binlog.inc
--let $datadir= `SELECT @@datadir`
--source include/reset_master.inc
--echo *** Test that a prepare record at the end of binlog does not cause server shutdown to hang
CALL mtr.add_suppression('Warning.*Found 1 prepared XA transactions');
CREATE TABLE t1 (a INT PRIMARY KEY, b LONGBLOB) ENGINE=InnoDB;
XA START 'a';
INSERT INTO t1 VALUES (1, REPEAT('<', 50000));
INSERT INTO t1 VALUES (2, REPEAT('|', 50000));
INSERT INTO t1 VALUES (3, REPEAT('>', 50000));
XA END 'a';
XA PREPARE 'a';
# The bug was that the prepare record written at the current end of
# the binlog file was not entered into the pending LSN fifo, so it never
# got marked as having been made durable. Then when the server shuts down
# and closes the binlog tablespace file, it waits indefinitely for the
# file to be marked durable.
--source include/restart_mysqld.inc
XA ROLLBACK 'a';
--echo *** Test server restart when some binlog files are missing.
--source include/reset_master.inc
INSERT INTO t1 VALUES (10, REPEAT('a', 100000));
INSERT INTO t1 VALUES (11, REPEAT('a', 100000));
INSERT INTO t1 VALUES (12, REPEAT('a', 100000));
--connect con1,localhost,root,,
XA START 'b';
INSERT INTO t1 VALUES (20, REPEAT('b', 10000));
XA END 'b';
XA PREPARE 'b';
--connection default
FLUSH BINARY LOGS;
--connect con2,localhost,root,,
BEGIN;
INSERT INTO t1 VALUES (21, REPEAT('d', 100000));
--connect con3,localhost,root,,
XA START 'c';
INSERT INTO t1 VALUES (22, REPEAT('c', 10000));
XA END 'c';
XA PREPARE 'c';
--connection default
FLUSH BINARY LOGS;
INSERT INTO t1 VALUES (30, '');
--echo *** Stop the server, then restart it after deleting some still needed binlog files.
--source include/shutdown_mysqld.inc
# The server should still start, but with errors in the log, suppressed below.
--remove_file $datadir/binlog-000000.ibb
--remove_file $datadir/binlog-000001.ibb
--source include/start_mysqld.inc
--disconnect con1
--disconnect con2
--disconnect con3
--echo *** Should be empty, binlog files needed for XA were deleted.
XA RECOVER;
SELECT a, LENGTH(b) FROM t1 ORDER BY a;
DROP TABLE t1;
CALL mtr.add_suppression('ERROR.*File .* not found');
CALL mtr.add_suppression('ERROR.*InnoDB: Error reading binlog while recovering XIDs of possibly prepared transactions. Recovery will be incomplete');