Repository navigation
PBS-42 feature: Implement basic support for COM_BINLOG_DUMP packet handling (part 4) #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
percona-ysorokin
merged 1 commit into
Percona-Lab:main
from
percona-ysorokin:com_binlog_dump_mtr
Sep 30, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
mtr/binlog_streaming/include/kill_binlog_dump_connection.inc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # ==== Purpose ==== | ||
| # | ||
| # Kill the server-side Binlog Dump connection left by a terminated Binlog | ||
| # Server Utility process, if one is still present. | ||
| # | ||
| # ==== Usage ==== | ||
| # | ||
| # --source ../include/kill_binlog_dump_connection.inc | ||
| # | ||
|
|
||
| --let $binlog_dump_connection_id = `SELECT ID FROM performance_schema.processlist WHERE COMMAND = 'Binlog Dump'` | ||
| if ($binlog_dump_connection_id != '') | ||
| { | ||
| --disable_query_log | ||
| eval KILL CONNECTION $binlog_dump_connection_id; | ||
| --enable_query_log | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # ==== Purpose ==== | ||
| # | ||
| # Start a process in the background and return its PID. | ||
| # | ||
| # ==== Usage ==== | ||
| # | ||
| # --let $proc_command_line = command with arguments and redirects | ||
| # --source ../include/start_proc_in_background.inc | ||
| # | ||
| # Parameters: | ||
| # $proc_command_line | ||
| # Complete command line to execute before the background operator. | ||
| # | ||
| # Output: | ||
| # $proc_pid | ||
| # PID of the started process. | ||
| # | ||
| if (!$proc_command_line) | ||
| { | ||
| --die ERROR IN TEST: 'proc_command_line' parameter not specified | ||
| } | ||
|
|
||
| # We route the spawn through Perl's system() rather than --exec because | ||
| # mysqltest strips the shell's `$!` before it can be expanded, leaving the | ||
| # PID file empty. Passing the command as an env var and executing it from | ||
| # Perl leaves the shell metacharacters intact. | ||
|
|
||
| --let $proc_pid_file = $MYSQL_TMP_DIR/start_proc_in_background.pid | ||
| --let $proc_spawn_command_line = $proc_command_line & echo \$! > $proc_pid_file | ||
| --let EXPORTED_PROC_COMMAND_LINE = $proc_spawn_command_line | ||
| --perl | ||
| use strict; | ||
| use warnings; | ||
| my $cmd = $ENV{'EXPORTED_PROC_COMMAND_LINE'}; | ||
| system("$cmd"); | ||
| EOF | ||
|
|
||
| --let $read_from_file = $proc_pid_file | ||
| --source include/read_file_to_var.inc | ||
| --let $proc_pid = $result | ||
| --remove_file $proc_pid_file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # ==== Purpose ==== | ||
| # | ||
| # Send SIGTERM to a process and wait for it to terminate gracefully. | ||
| # | ||
| # ==== Usage ==== | ||
| # | ||
| # --let $proc_pid = process PID | ||
| # [--let $proc_termination_timeout = timeout in seconds] | ||
| # --source ../include/terminate_proc.inc | ||
| # | ||
| # Parameters: | ||
| # $proc_pid | ||
| # PID of the process to terminate. | ||
| # | ||
| # $proc_termination_timeout | ||
| # Maximum number of seconds to wait. Defaults to 30. | ||
| # | ||
| if (!$proc_pid) | ||
| { | ||
| --die ERROR IN TEST: 'proc_pid' parameter not specified | ||
| } | ||
| if (!$proc_termination_timeout) | ||
| { | ||
| --let $proc_termination_timeout = 60 | ||
| } | ||
|
|
||
| --exec kill -s TERM $proc_pid | ||
|
|
||
| --let $proc_termination_iteration = 0 | ||
| --let $proc_running = 1 | ||
| while ($proc_termination_iteration < $proc_termination_timeout) | ||
| { | ||
| if ($proc_running) | ||
| { | ||
| --error 0, 1 | ||
| --exec kill -0 $proc_pid 2>/dev/null | ||
| --let $proc_kill_status = $__error | ||
| if ($proc_kill_status != 0) | ||
| { | ||
| --let $proc_running = 0 | ||
| --let $proc_termination_iteration = $proc_termination_timeout | ||
| } | ||
| if ($proc_kill_status == 0) | ||
| { | ||
| --sleep 1 | ||
| --inc $proc_termination_iteration | ||
| } | ||
| } | ||
| } | ||
| if ($proc_running) | ||
| { | ||
| --die Process did not terminate within the configured timeout | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # ==== Purpose ==== | ||
| # | ||
| # Waits until a specified network port is ready to accept connections. | ||
| # | ||
| # ==== Usage ==== | ||
| # | ||
| # --let $listening_port = 3306 | ||
| # --source ../include/wait_for_listening_port.inc | ||
| # | ||
| # Parameters: | ||
| # $listening_port | ||
| # Network port to wait for. | ||
| # | ||
|
|
||
| # We probe with bash's '/dev/tcp' because it uses a plain connect(2), so each | ||
| # attempt is cheap and measures exactly the "listening on the port" state we | ||
| # care about. | ||
|
|
||
| --let $max_wait = 300 | ||
| --let $iteration = 0 | ||
| --let $port_open = 0 | ||
| while ($iteration < $max_wait) | ||
| { | ||
| --error 0, 1 | ||
| --exec bash -c "echo > /dev/tcp/127.0.0.1/$listening_port" 2>/dev/null | ||
| --let $port_status = $__error | ||
| if ($port_status == 0) | ||
| { | ||
| --let $port_open = 1 | ||
| --let $iteration = $max_wait | ||
| } | ||
| if ($port_status != 0) | ||
| { | ||
| --sleep 1 | ||
| --inc $iteration | ||
| } | ||
| } | ||
| if (!$port_open) | ||
| { | ||
| --die The Binlog Server replication source listener did not become reachable within 300 seconds | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| *** 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. | ||
|
|
||
| *** Determining the first binary log name. | ||
|
|
||
| *** Creating source_db.tbl and inserting the first batch of rows. | ||
| CREATE DATABASE source_db; | ||
| CREATE TABLE source_db.tbl( | ||
| id INT UNSIGNED NOT NULL, | ||
| value VARCHAR(32) NOT NULL, | ||
| PRIMARY KEY(id) | ||
| ) ENGINE=InnoDB; | ||
| INSERT INTO source_db.tbl VALUES (1, 'one'), (2, 'two'), (3, 'three'); | ||
|
|
||
| *** Flushing the source binary log. | ||
| FLUSH BINARY LOGS; | ||
|
|
||
| *** Inserting the second batch of rows. | ||
| INSERT INTO source_db.tbl VALUES (4, 'four'), (5, 'five'), (6, 'six'); | ||
|
|
||
| *** Fetching the source binary logs in position mode. | ||
|
|
||
| *** Starting Binlog Server Utility in background in pull mode. | ||
| include/read_file_to_var.inc | ||
|
|
||
| *** Waiting for the replication source listener port ready to accept | ||
| *** connections. | ||
|
|
||
| *** Dumping the binary logs from the Binlog Server replication source. | ||
|
|
||
| *** Sending SIGTERM signal to the Binlog Server Utility and waiting for | ||
| *** the process to terminate | ||
|
|
||
| *** Moving source_db.tbl to backup_db.tbl. | ||
| CREATE DATABASE backup_db; | ||
| RENAME TABLE source_db.tbl TO backup_db.tbl; | ||
| DROP DATABASE source_db; | ||
|
|
||
| *** Restoring source_db from the replication source dump. | ||
|
|
||
| *** Comparing the restored and backup tables. | ||
| include/diff_tables.inc [source_db.tbl, backup_db.tbl] | ||
|
|
||
| *** Dropping the round-trip databases. | ||
| DROP DATABASE source_db; | ||
| DROP DATABASE backup_db; | ||
|
|
||
| *** Removing the Binlog Server utility storage directory. | ||
|
|
||
| *** Removing the Binlog Server utility log file. | ||
|
|
||
| *** Removing the Binlog Server utility configuration file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was moved to a dedicated inc file,which is fine, but the comment explaining the magic is worth keeping there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment moved to the .inc file as well