1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-34705: Binlog-in-engine: Integration with server-layer code

Mostly various fixes to avoid initializing or creating any data or files for
the legacy binlog.

A possible later refinement could be to sub-class the binlog class
differently for legacy and in-engine binlogs, writing separate virtual
functions for behaviour that differ, extracting common functionality into
sub-methods. This could remove some if (opt_binlog_engine_hton)
conditionals.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
Kristian Nielsen
2025-04-10 14:54:37 +02:00
parent 0327708ed6
commit d496e5278d
19 changed files with 595 additions and 165 deletions

View File

@@ -0,0 +1,54 @@
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 0);
connect con1,localhost,root,,;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connect con2,localhost,root,,;
*** Connection sees current position by default.
connection default;
INSERT INTO t1 VALUES (2, 0);
FLUSH BINARY LOGS;
INSERT INTO t1 VALUES (3, 0);
INSERT INTO t1 VALUES (4, 0);
SELECT * FROM t1 ORDER BY a;
a b
1 0
2 0
3 0
4 0
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog-000001.ibb # Gtid # # BEGIN GTID #-#-#
binlog-000001.ibb # Query # # use `test`; INSERT INTO t1 VALUES (4, 0)
binlog-000001.ibb # Xid # # COMMIT /* XID */
*** START TRANSACTION WITH CONSISTENT SNAPSHOT sees position consistent with read view.
connection con1;
SELECT * FROM t1 ORDER BY a;
a b
1 0
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog-000000.ibb # Gtid # # BEGIN GTID #-#-#
binlog-000000.ibb # Query # # use `test`; INSERT INTO t1 VALUES (2, 0)
binlog-000000.ibb # Xid # # COMMIT /* XID */
*** Connection with no active transaction sees the current position.
connection con2;
connection default;
INSERT INTO t1 VALUES (5, 0);
connection con2;
SELECT * FROM t1 ORDER BY a;
a b
1 0
2 0
3 0
4 0
5 0
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
binlog-000001.ibb # Gtid # # BEGIN GTID #-#-#
binlog-000001.ibb # Query # # use `test`; INSERT INTO t1 VALUES (5, 0)
binlog-000001.ibb # Xid # # COMMIT /* XID */
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t1;

View File

@@ -0,0 +1,45 @@
--source include/have_binlog_format_mixed.inc
--source include/have_innodb_binlog.inc
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 0);
--connect(con1,localhost,root,,)
START TRANSACTION WITH CONSISTENT SNAPSHOT;
--connect(con2,localhost,root,,)
--echo *** Connection sees current position by default.
--connection default
INSERT INTO t1 VALUES (2, 0);
FLUSH BINARY LOGS;
INSERT INTO t1 VALUES (3, 0);
--let $binlog_file= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_file', Value, 1)
--let $binlog_start= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1)
--let $binlog_limit= 0, 3
INSERT INTO t1 VALUES (4, 0);
SELECT * FROM t1 ORDER BY a;
--source include/show_binlog_events.inc
--echo *** START TRANSACTION WITH CONSISTENT SNAPSHOT sees position consistent with read view.
--connection con1
--let $binlog_file= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_file', Value, 1)
--let $binlog_start= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1)
SELECT * FROM t1 ORDER BY a;
--source include/show_binlog_events.inc
--echo *** Connection with no active transaction sees the current position.
--connection con2
--let $binlog_file= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_file', Value, 1)
--let $binlog_start= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1)
--connection default
INSERT INTO t1 VALUES (5, 0);
--connection con2
SELECT * FROM t1 ORDER BY a;
--source include/show_binlog_events.inc
--connection default
--disconnect con1
--disconnect con2
DROP TABLE t1;

View File

@@ -0,0 +1,13 @@
SET GLOBAL rpl_semi_sync_master_enabled= 1;
ERROR HY000: Semi-synchronous replication is not yet supported with --binlog-storage-engine
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
XA START 'a';
ERROR HY000: Explicit XA transactions are not yet supported with --binlog-storage-engine
INSERT INTO t1 VALUES (0, 0);
XA END 'a';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the NON-EXISTING state
XA PREPARE 'a';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the NON-EXISTING state
XA COMMIT 'a';
ERROR XAE04: XAER_NOTA: Unknown XID
DROP TABLE t1;

View File

@@ -0,0 +1,17 @@
--source include/have_binlog_format_mixed.inc
--source include/have_innodb_binlog.inc
--error ER_ENGINE_BINLOG_NO_SEMISYNC
SET GLOBAL rpl_semi_sync_master_enabled= 1;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
--error ER_ENGINE_BINLOG_NO_USER_XA
XA START 'a';
INSERT INTO t1 VALUES (0, 0);
--error ER_XAER_RMFAIL
XA END 'a';
--error ER_XAER_RMFAIL
XA PREPARE 'a';
--error ER_XAER_NOTA
XA COMMIT 'a';
DROP TABLE t1;