Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ set(source_files
src/binsrv/events/gtid_log_post_header_impl_fwd.hpp
src/binsrv/events/gtid_log_post_header_impl.hpp

src/binsrv/events/gtid_renumberer_fwd.hpp
src/binsrv/events/gtid_renumberer.hpp
src/binsrv/events/gtid_renumberer.cpp

src/binsrv/events/gtid_tagged_log_body_impl_fwd.hpp
src/binsrv/events/gtid_tagged_log_body_impl.hpp
src/binsrv/events/gtid_tagged_log_body_impl.cpp
Expand Down
47 changes: 47 additions & 0 deletions mtr/binlog_streaming/r/gtid_renumbering.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
*** Resetting replication at the very beginning of the test.

*** Generating a configuration file in JSON format for the Binlog
*** Server utility.

*** Determining binlog file directory from the server.

*** Creating a temporary directory <BINSRV_STORAGE_PATH> for storing
*** binlog files downloaded via the Binlog Server utility.

*** Building deterministic binlog content with two source-binlog
*** rotations between transaction groups.

*** Source binlog A: CREATE TABLE + 9 INSERTs (10 GTIDs total).
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE=InnoDB;

*** Flushing source binary log (introduces the first
*** source-binlog rotation that the rewriter must absorb).
FLUSH BINARY LOGS;

*** Source binlog B: 5 INSERTs.

*** Flushing source binary log one more time (second
*** source-binlog rotation absorbed inside the same local file).
FLUSH BINARY LOGS;

*** Source binlog C: 3 INSERTs.

*** Executing the Binlog Server utility in rewrite mode.

*** Materializing the local binlog file produced by the rewriter
*** and dumping it via mysqlbinlog for textual inspection.

*** Validating (sequence_number, last_committed) of every GTID
*** event in the local binlog file. Aborts with --die on any
*** invariant violation; produces no output otherwise.

*** Removing temporary files.

*** Dropping the table.
DROP TABLE t1;

*** Removing the Binlog Server utility storage directory.

*** Removing the Binlog Server utility log file.

*** Removing the Binlog Server utility configuration file.
34 changes: 34 additions & 0 deletions mtr/binlog_streaming/r/gtid_renumbering_local_rotation.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
*** Resetting replication at the very beginning of the test.

*** Generating a configuration file in JSON format for the Binlog
*** Server utility.

*** Determining binlog file directory from the server.

*** Creating a temporary directory <BINSRV_STORAGE_PATH> for storing
*** binlog files downloaded via the Binlog Server utility.

*** Building a single-source-binlog workload that is large enough
*** to span multiple 1K local binlog files after rewrite.
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, payload VARCHAR(100) NOT NULL, PRIMARY KEY(id)) ENGINE=InnoDB;

*** Executing the Binlog Server utility in rewrite mode.

*** Asserting that the rewriter actually rotated locally
*** (bnlg.000002 must exist - otherwise the test does not
*** exercise the local-rotation reset code path).

*** Validating per-local-file sequence_number reset and
*** last_committed range. Aborts with --die on violation;
*** produces no output otherwise.

*** Removing temporary files.

*** Dropping the table.
DROP TABLE t1;

*** Removing the Binlog Server utility storage directory.

*** Removing the Binlog Server utility log file.

*** Removing the Binlog Server utility configuration file.
50 changes: 50 additions & 0 deletions mtr/binlog_streaming/r/gtid_renumbering_resume.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
*** Resetting replication at the very beginning of the test.

*** Generating a configuration file in JSON format for the Binlog
*** Server utility.

*** Determining binlog file directory from the server.

*** Creating a temporary directory <BINSRV_STORAGE_PATH> for storing
*** binlog files downloaded via the Binlog Server utility.

*** Phase 1: CREATE TABLE + 4 INSERTs in source binlog A
*** (5 GTID events).
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE=InnoDB;

*** First binsrv invocation: writes 5 GTID events with
*** sequence_number 1..5 to bnlg.000001 and persists the
*** renumberer recovery snapshot (next_local_seq=5) in the
*** per-binlog metadata file.

*** Flushing source binary log between invocations so the
*** second binsrv run also has to absorb a source-side
*** rotation right after resuming.
FLUSH BINARY LOGS;

*** Phase 2: 5 INSERTs in source binlog B (5 more GTID events).

*** Second binsrv invocation: must resume the renumberer from
*** the persisted snapshot (next_local_seq=5) and append
*** sequence_number 6..10 to bnlg.000001.

*** Materializing the local binlog file produced across the two
*** invocations and dumping it via mysqlbinlog for textual
*** inspection.

*** Validating that sequence_number is gap-free across the
*** binsrv-invocation boundary and that the post-resume
*** source-binlog-boundary event has last_committed =
*** sequence_number - 1. Aborts with --die on any invariant
*** violation; produces no output otherwise.

*** Removing temporary files.

*** Dropping the table.
DROP TABLE t1;

*** Removing the Binlog Server utility storage directory.

*** Removing the Binlog Server utility log file.

*** Removing the Binlog Server utility configuration file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
*** Resetting replication at the very beginning of the test.

*** Generating a configuration file in JSON format for the Binlog
*** Server utility.

*** Determining binlog file directory from the server.

*** Creating a temporary directory <BINSRV_STORAGE_PATH> for storing
*** binlog files downloaded via the Binlog Server utility.

*** Phase 1: T_first = CREATE TABLE t1 (1 GTID event, no
*** Write_rows).
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE=InnoDB;

*** First binsrv invocation: writes T_first with
*** sequence_number=1 to bnlg.000001 and persists
*** next_local_seq=1 in the per-binlog metadata.

*** Phase 2: arm the source dump thread to pause AFTER
*** sending the first WRITE_ROWS event of any transaction.
*** Combined with the short binsrv read_timeout, this freezes
*** the second binsrv invocation mid-T_third (after T_third's
*** GTID has been processed by binsrv but before T_third's
*** XID can be received).
SET @old_global_debug = @@global.debug;
SET GLOBAL DEBUG = '+d,dump_thread_wait_after_send_write_rows';

*** Workload that the second binsrv invocation will read:
*** T_second (CREATE TABLE t2, no Write_rows; will be
*** absorbed in full) and T_third (INSERT INTO t1, has
*** Write_rows; binsrv will receive its GTID and prefix
*** events and then time out waiting for the rest).
CREATE TABLE t2(id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(DEFAULT);

*** Second binsrv invocation: expected to exit with non-zero
*** status after read_timeout. The storage destructor flushes
*** the COMMITTED transaction (T_second) and persists the
*** per-binlog metadata. The renumberer recovery snapshot
*** persisted here MUST be next_local_seq=2 (committed, in
*** lockstep with the flushed bytes) and not the speculative
*** next_local_seq=3 produced by T_third's GTID rewrite.

*** Releasing the paused source dump thread: SIGNAL wakes it
*** from the debug_sync wait, after which its first attempt
*** to send the next event fails on the half-closed socket
*** and the dump thread exits. DEBUG flag is then restored so
*** the new dump thread spawned by binsrv 3 does not pause.
SET DEBUG_SYNC = 'now SIGNAL signal.continue';
SET GLOBAL DEBUG = @old_global_debug;
SET DEBUG_SYNC = 'RESET';

*** Third binsrv invocation: the source resends T_third
*** (binsrv never acknowledged it), and the renumberer
*** continues from the persisted committed snapshot. T_third
*** must land as sequence_number=3 so bnlg.000001 ends up
*** gap-free.

*** Materializing bnlg.000001 produced across all three
*** invocations and dumping it via mysqlbinlog for textual
*** inspection.

*** Validating that bnlg.000001 contains exactly 3 GTID
*** events with contiguous sequence_numbers 1, 2, 3 and
*** that every last_committed value references an in-file
*** sequence_number. Aborts with --die on any invariant
*** violation; produces no output otherwise.

*** Removing temporary files.

*** Dropping the tables.
DROP TABLE t1, t2;

*** Removing the Binlog Server utility storage directory.

*** Removing the Binlog Server utility log file.

*** Removing the Binlog Server utility configuration file.
2 changes: 2 additions & 0 deletions mtr/binlog_streaming/t/gtid_renumbering-master.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--gtid-mode=on
--enforce-gtid-consistency
Loading
Loading