mirror of
https://github.com/MariaDB/server.git
synced 2025-05-28 13:01:41 +03:00
This patch augments Gtid_log_event with the user thread-id. In particular that compensates for the loss of this info in Rows_log_events. Gtid_log_event::thread_id gets visible in mysqlbinlog output like #231025 16:21:45 server id 1 end_log_pos 537 CRC32 0x1cf1d963 GTID 0-1-2 ddl thread_id=10 as a 32 bit unsigned integer. Note this is a 32-bit value, as the connection id can only be 32 bits (see MDEV-15089 for details). While the size of Gtid event has grown by 4 bytes replication from OLD <-> NEW is not affected by it. This patch also slightly changes the logic to convert Gtid events to Query events for older replicas which don't support Gtid. Instead of hard-coding the padding of the sys var section of the generated Query event, the length to pad is dynamically calculated based on the length of the Gtid event. This work was started by the late Sujatha Sivakumar. Brandon Nesterenko took it over, reviewed initial patches and extended the work. Also thanks to Andrei for his help in finalizing the fixes for MDEV-33924, which were squashed into this patch. Reviewed-by: ============= Andrei Elkin <andrei.elkin@mariadb.com> Kristian Nielsen <knielsen@knielsen-hq.org>
109 lines
5.3 KiB
Plaintext
109 lines
5.3 KiB
Plaintext
RESET MASTER;
|
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
|
|
/* GTID */ INSERT INTO t1 VALUES (1,0);
|
|
/* GTID */ BEGIN;
|
|
/* GTID */ INSERT INTO t1 VALUES (2,0);
|
|
/* GTID */ ALTER TABLE t1 ADD c INT;
|
|
/* GTID */ INSERT INTO t1 VALUES (3,0,0);
|
|
/* GTID */ COMMIT;
|
|
/* GTID */ BEGIN;
|
|
/* GTID */ UPDATE t1 SET b=1, c=1 WHERE a=2;
|
|
/* GTID */ CREATE TEMPORARY TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
|
|
/* GTID */ INSERT INTO t2 VALUES (4,10), (5,20);
|
|
/* GTID */ INSERT INTO t1 SELECT a, 2, b FROM t2;
|
|
/* GTID */ DROP TEMPORARY TABLE t2;
|
|
/* GTID */ INSERT INTO t1 VALUES (6, 3, 0);
|
|
/* GTID */ COMMIT;
|
|
/* GTID */ CREATE TEMPORARY TABLE t3 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
|
/* GTID */ BEGIN;
|
|
/* GTID */ DELETE FROM t1 WHERE a=5;
|
|
/* GTID */ INSERT INTO t3 VALUES (7);
|
|
/* GTID */ INSERT INTO t1 SELECT a, 4, 0 FROM t3;
|
|
/* GTID */ UPDATE t1 SET c=1 WHERE a=7;
|
|
/* GTID */ DROP TEMPORARY TABLE t3;
|
|
/* GTID */ COMMIT;
|
|
/* GTID */ CREATE TEMPORARY TABLE t4 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
|
/* GTID */ BEGIN;
|
|
/* GTID */ INSERT INTO t1 VALUES (8, 5, 0);
|
|
/* GTID */ ALTER TABLE t4 ADD b INT;
|
|
/* GTID */ INSERT INTO t1 VALUES (9, 5, 1);
|
|
/* GTID */ COMMIT;
|
|
connect tmp_con,localhost,root,,;
|
|
/* GTID */ INSERT INTO t1 VALUES (10, 6, 0);
|
|
/* GTID */ BEGIN;
|
|
/* GTID */ CREATE TEMPORARY TABLE t5 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
|
/* GTID */ INSERT INTO t1 VALUES (11, 7, 0);
|
|
/* GTID */ COMMIT;
|
|
disconnect tmp_con;
|
|
connection default;
|
|
FLUSH LOGS;
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# trans thread_id=#
|
|
START TRANSACTION
|
|
#Q> /* GTID */ INSERT INTO t1 VALUES (1,0)
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
COMMIT/*!*/;
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# trans thread_id=#
|
|
START TRANSACTION
|
|
#Q> /* GTID */ INSERT INTO t1 VALUES (2,0)
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
COMMIT/*!*/;
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# ddl thread_id=#
|
|
/* GTID */ ALTER TABLE t1 ADD c INT
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# trans thread_id=#
|
|
START TRANSACTION
|
|
#Q> /* GTID */ INSERT INTO t1 VALUES (3,0,0)
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
COMMIT/*!*/;
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# trans thread_id=#
|
|
START TRANSACTION
|
|
#Q> /* GTID */ UPDATE t1 SET b=1, c=1 WHERE a=2
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Update_rows: table id # flags: STMT_END_F
|
|
#Q> /* GTID */ INSERT INTO t1 SELECT a, 2, b FROM t2
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
#Q> /* GTID */ INSERT INTO t1 VALUES (6, 3, 0)
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
COMMIT/*!*/;
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# trans thread_id=#
|
|
START TRANSACTION
|
|
#Q> /* GTID */ DELETE FROM t1 WHERE a=5
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Delete_rows: table id # flags: STMT_END_F
|
|
#Q> /* GTID */ INSERT INTO t1 SELECT a, 4, 0 FROM t3
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
#Q> /* GTID */ UPDATE t1 SET c=1 WHERE a=7
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Update_rows: table id # flags: STMT_END_F
|
|
COMMIT/*!*/;
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# trans thread_id=#
|
|
START TRANSACTION
|
|
#Q> /* GTID */ INSERT INTO t1 VALUES (8, 5, 0)
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
COMMIT/*!*/;
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# trans thread_id=#
|
|
START TRANSACTION
|
|
#Q> /* GTID */ INSERT INTO t1 VALUES (9, 5, 1)
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
COMMIT/*!*/;
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# trans thread_id=#
|
|
START TRANSACTION
|
|
#Q> /* GTID */ INSERT INTO t1 VALUES (10, 6, 0)
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
COMMIT/*!*/;
|
|
# server id 1 end_log_pos # CRC32 0x######## GTID #-#-# trans thread_id=#
|
|
START TRANSACTION
|
|
#Q> /* GTID */ INSERT INTO t1 VALUES (11, 7, 0)
|
|
# server id 1 end_log_pos # CRC32 0x######## Table_map: `test`.`t1` mapped to number #
|
|
# server id 1 end_log_pos # CRC32 0x######## Write_rows: table id # flags: STMT_END_F
|
|
COMMIT/*!*/;
|
|
DROP TABLE t1;
|