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

MDEV-34705: Inplement starting from a specific GTID position

To find the target position, we first loop backwards over binlog files,
reading the initial GTID state written at the start to find the file to
start in. We then binary search on the differential GTID states written
every --innodb-binlog-state-interval bytes.

This patch does only minimal changes to the dump thread code in sql_repl.cc
to be able to send out binlog data to the client. Some re-factoring/cleanup
should be done in a follow-up patch to more cleanly separate the two code
paths, avoid a lot of if-statements and make the binlog-in-engine code path
free of much of the cruft from the legacy binlog implementation.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
Kristian Nielsen
2024-11-04 17:36:24 +01:00
parent de6f3512f3
commit 951a472437
8 changed files with 543 additions and 73 deletions

View File

@@ -2,6 +2,7 @@
--source include/have_binlog_format_mixed.inc
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--let $gtid_pos= `SELECT @@last_gtid`
INSERT INTO t1 VALUES (1);
BEGIN;
INSERT INTO t1 VALUES (2);
@@ -25,6 +26,6 @@ while ($i < $num_trx) {
--enable_query_log
SET SESSION binlog_format= MIXED;
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog.txt
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --start-position=$gtid_pos > $MYSQLTEST_VARDIR/tmp/mysqlbinlog.txt
DROP TABLE t2;

View File

@@ -11,11 +11,12 @@ while ($i < 10) {
inc $i;
}
SELECT @@GLOBAL.gtid_binlog_state;
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog1.txt
--exec $MYSQL_BINLOG --start-position=42-42-42 --gtid-strict-mode=0 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog1.txt
--source include/restart_mysqld.inc
SELECT @@GLOBAL.gtid_binlog_state;
--let $gtid_pos2= `SELECT @@GLOBAL.gtid_binlog_pos`
INSERT INTO t1 VALUES (2, 0);
let $i= 0;
while ($i < 10) {
@@ -23,11 +24,12 @@ while ($i < 10) {
inc $i;
}
SELECT @@GLOBAL.gtid_binlog_state;
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog2.txt
--exec $MYSQL_BINLOG --start-position=$gtid_pos2 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog2.txt
--source include/restart_mysqld.inc
SELECT @@GLOBAL.gtid_binlog_state;
--let $gtid_pos3= `SELECT @@GLOBAL.gtid_binlog_pos`
INSERT INTO t1 VALUES (3, 0);
let $i= 0;
while ($i < 10) {
@@ -35,6 +37,6 @@ while ($i < 10) {
inc $i;
}
--exec $MYSQL_BINLOG --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog3.txt
--exec $MYSQL_BINLOG --start-position=$gtid_pos3 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog3.txt
DROP TABLE t1;