-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-37605 Extend mariadb-binlog to convert innodb based binary logs to legacy #5276
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
Draft
tarunw07
wants to merge
1
commit into
MariaDB:main
Choose a base branch
from
tarunw07:MDEV-37605-convert-innodb-binlog-to-legacy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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
Large diffs are not rendered by default.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
mysql-test/suite/binlog_in_engine/mysqlbinlog_convert_engine_binlog_basic.result
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,25 @@ | ||
| include/reset_master.inc | ||
| set TIMESTAMP= UNIX_TIMESTAMP("1970-01-21 15:32:22"); | ||
| *** Generate a small workload into binlog-000000.ibb | ||
| CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; | ||
| INSERT INTO t1 VALUES (1, 0), (2, 0), (3, 0); | ||
| UPDATE t1 SET b=1 WHERE a=1; | ||
| DELETE FROM t1 WHERE a=2; | ||
| REPLACE INTO t1 VALUES (3, 3); | ||
| SELECT * FROM t1 ORDER BY a; | ||
| a b | ||
| 1 1 | ||
| 3 3 | ||
| FLUSH BINARY LOGS; | ||
| *** Convert binlog-000000.ibb to legacy format | ||
| *** Converted file contains the synthesized header events | ||
| FOUND 1 /Gtid list/ in conv_listing.txt | ||
| FOUND 1 /Binlog checkpoint/ in conv_listing.txt | ||
| FOUND 1 /Start: binlog v 4/ in conv_listing.txt | ||
| *** Round-trip: replay the converted file and compare data | ||
| DROP TABLE t1; | ||
| SELECT * FROM t1 ORDER BY a; | ||
| a b | ||
| 1 1 | ||
| 3 3 | ||
| DROP TABLE t1; |
61 changes: 61 additions & 0 deletions
61
mysql-test/suite/binlog_in_engine/mysqlbinlog_convert_engine_binlog_basic.test
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,61 @@ | ||
| # mysqlbinlog_convert.test | ||
| # | ||
| # Purpose: | ||
| # Basic test for MDEV-37605: mariadb-binlog conversion of InnoDB-format | ||
| # binlogs (.ibb) into legacy-format binary log | ||
| # | ||
|
|
||
| --source include/have_binlog_format_row.inc | ||
| --source include/have_innodb_binlog.inc | ||
|
|
||
| --let $datadir= `SELECT @@datadir` | ||
|
|
||
| --source include/reset_master.inc | ||
|
|
||
| # Fixed timestamp for deterministic event listings (with --timezone=GMT-3 | ||
| # from the -master.opt file, matching binlog_in_engine.mysqlbinlog). | ||
| set TIMESTAMP= UNIX_TIMESTAMP("1970-01-21 15:32:22"); | ||
|
|
||
| --echo *** Generate a small workload into binlog-000000.ibb | ||
| CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; | ||
| INSERT INTO t1 VALUES (1, 0), (2, 0), (3, 0); | ||
| UPDATE t1 SET b=1 WHERE a=1; | ||
| DELETE FROM t1 WHERE a=2; | ||
| REPLACE INTO t1 VALUES (3, 3); | ||
| SELECT * FROM t1 ORDER BY a; | ||
|
|
||
| # Rotate so binlog-000000.ibb is complete on disk. Waiting for the *next* | ||
| # pre-allocated file (binlog-000002.ibb, fully pre-allocated and empty) | ||
| # guarantees both 000000 and the new active 000001 exist. | ||
| FLUSH BINARY LOGS; | ||
| --let $binlog_name= binlog-000002.ibb | ||
| --let $binlog_size= 262144 | ||
| --source include/wait_for_engine_binlog.inc | ||
|
|
||
| --echo *** Convert binlog-000000.ibb to legacy format | ||
| --exec $MYSQL_BINLOG --convert-engine-binlog --result-file=$MYSQL_TMP_DIR/conv $datadir/binlog-000000.ibb | ||
|
|
||
|
|
||
| --echo *** Converted file contains the synthesized header events | ||
| --exec $MYSQL_BINLOG --verbose $MYSQL_TMP_DIR/conv.000001 > $MYSQL_TMP_DIR/conv_listing.txt | ||
| --let SEARCH_FILE= $MYSQL_TMP_DIR/conv_listing.txt | ||
| --let SEARCH_PATTERN= Gtid list | ||
| --source include/search_pattern_in_file.inc | ||
| --let SEARCH_PATTERN= Binlog checkpoint | ||
| --source include/search_pattern_in_file.inc | ||
| --let SEARCH_PATTERN= Start: binlog v 4 | ||
| --source include/search_pattern_in_file.inc | ||
| --remove_file $MYSQL_TMP_DIR/conv_listing.txt | ||
|
|
||
| --echo *** Round-trip: replay the converted file and compare data | ||
| # The replayed GTIDs duplicate the originals, so the replay must not use | ||
| # GTID strict mode (same as in binlog_in_engine.mysqlbinlog). | ||
| --exec $MYSQL_BINLOG --gtid-strict-mode=0 $MYSQL_TMP_DIR/conv.000001 > $MYSQLTEST_VARDIR/tmp/convert_replay.sql | ||
| DROP TABLE t1; | ||
| --exec $MYSQL --abort-source-on-error -e "source $MYSQLTEST_VARDIR/tmp/convert_replay.sql;" test | ||
| --remove_file $MYSQLTEST_VARDIR/tmp/convert_replay.sql | ||
| SELECT * FROM t1 ORDER BY a; | ||
|
|
||
| # Cleanup | ||
| --remove_file $MYSQL_TMP_DIR/conv.000001 | ||
| DROP TABLE t1; |
46 changes: 46 additions & 0 deletions
46
mysql-test/suite/binlog_in_engine/mysqlbinlog_convert_engine_binlog_gtid_list_event.result
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,46 @@ | ||
| SET @@session.sql_log_bin= 0; | ||
| CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| CREATE TABLE t3 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| CREATE TABLE t4 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| SET @@session.sql_log_bin= 1; | ||
| include/reset_master.inc | ||
| *** Generate GTIDs across several InnoDB binlog files | ||
| SET @@session.gtid_domain_id= 0; | ||
| SET @@session.server_id= 1; | ||
| INSERT INTO t1 VALUES (2); | ||
| SET @@session.gtid_domain_id= 1; | ||
| SET @@session.server_id= 2; | ||
| INSERT INTO t2 VALUES (1); | ||
| FLUSH BINARY LOGS; | ||
| SET @@session.gtid_domain_id= 0; | ||
| SET @@session.server_id= 1; | ||
| INSERT INTO t1 VALUES (1); | ||
| SET @@session.gtid_domain_id= 2; | ||
| SET @@session.server_id= 3; | ||
| INSERT INTO t3 VALUES (1); | ||
| FLUSH BINARY LOGS; | ||
| SET @@session.gtid_domain_id= 1; | ||
| SET @@session.server_id= 1; | ||
| INSERT INTO t2 VALUES (2); | ||
| SET @@session.gtid_domain_id= 3; | ||
| SET @@session.server_id= 4; | ||
| INSERT INTO t4 VALUES (1); | ||
| # restart | ||
| SET @@session.gtid_domain_id= 0; | ||
| SET @@session.server_id= 1; | ||
| INSERT INTO t1 VALUES (3); | ||
| FLUSH BINARY LOGS; | ||
| *** Convert the generated InnoDB binlogs to legacy format | ||
| *** Verify synthesized Gtid_list events in converted legacy binlogs | ||
| FOUND 1 /Gtid list \[\]/ in gtid_conv_listing.txt | ||
| FOUND 1 /Gtid list \[0-1-1,\n# 1-2-1\]/ in gtid_conv_listing.txt | ||
| FOUND 1 /Gtid list \[0-1-2,\n# 1-2-1,\n# 2-3-1\]/ in gtid_conv_listing.txt | ||
| FOUND 1 /Gtid list \[0-1-2,\n# 1-2-1,\n# 1-1-2,\n# 2-3-1,\n# 3-4-1\]/ in gtid_conv_listing.txt | ||
| *** Convert the generated InnoDB binlog(binlog-000002.ibb) to legacy format in random order | ||
| *** Verify synthesized Gtid_list events in converted legacy binlogs | ||
| NOT FOUND /Gtid list \[0-1-2,\n# 1-2-1,\n# 1-1-2,\n# 2-3-1,\n# 3-4-1\]/ in gtid_conv_listing.txt | ||
| DROP TABLE t1; | ||
| DROP TABLE t2; | ||
| DROP TABLE t3; | ||
| DROP TABLE t4; |
129 changes: 129 additions & 0 deletions
129
mysql-test/suite/binlog_in_engine/mysqlbinlog_convert_engine_binlog_gtid_list_event.test
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,129 @@ | ||
| # | ||
| # Purpose: | ||
| # Verify that mariadb-binlog populates synthesized GTID_LIST_EVENTs correctly | ||
| # when converting InnoDB-format binlogs (.ibb) to legacy binlog files. | ||
| # | ||
| # Methodology: | ||
| # Generate several .ibb files with GTIDs across multiple domains and server | ||
| # ids, including GTIDs that are not ordered by server id. Restart the server | ||
| # in the middle so the converter sees another FORMAT_DESCRIPTION_EVENT and | ||
| # rotates the generated legacy output. Convert all completed .ibb files and | ||
| # verify each generated legacy binlog contains the expected Gtid_list state. | ||
| # Convert the .ibb files again in random order and verify the generated | ||
| # legacy binlogs contain the expected Gtid_list state. | ||
| # | ||
|
|
||
| --source include/have_binlog_format_row.inc | ||
| --source include/have_innodb_binlog.inc | ||
|
|
||
| --let $datadir= `SELECT @@datadir` | ||
|
|
||
| # start of binlog-000000.ibb | ||
|
|
||
| SET @@session.sql_log_bin= 0; | ||
| CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| CREATE TABLE t3 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| CREATE TABLE t4 (a INT PRIMARY KEY) ENGINE=InnoDB; | ||
| SET @@session.sql_log_bin= 1; | ||
|
|
||
| --source include/reset_master.inc | ||
|
|
||
| --echo *** Generate GTIDs across several InnoDB binlog files | ||
| SET @@session.gtid_domain_id= 0; | ||
| SET @@session.server_id= 1; | ||
| INSERT INTO t1 VALUES (2); | ||
|
|
||
| SET @@session.gtid_domain_id= 1; | ||
| SET @@session.server_id= 2; | ||
| INSERT INTO t2 VALUES (1); | ||
|
|
||
| # end of binlog-000000.ibb | ||
|
|
||
| FLUSH BINARY LOGS; | ||
|
|
||
| # start of binlog-000001.ibb | ||
|
|
||
| SET @@session.gtid_domain_id= 0; | ||
| SET @@session.server_id= 1; | ||
| INSERT INTO t1 VALUES (1); | ||
|
|
||
| SET @@session.gtid_domain_id= 2; | ||
| SET @@session.server_id= 3; | ||
| INSERT INTO t3 VALUES (1); | ||
|
|
||
| # end of binlog-000001.ibb | ||
|
|
||
| FLUSH BINARY LOGS; | ||
|
|
||
| # start of binlog-000002.ibb | ||
|
|
||
| SET @@session.gtid_domain_id= 1; | ||
| SET @@session.server_id= 1; | ||
| INSERT INTO t2 VALUES (2); | ||
|
|
||
| SET @@session.gtid_domain_id= 3; | ||
| SET @@session.server_id= 4; | ||
| INSERT INTO t4 VALUES (1); | ||
|
|
||
| --source include/restart_mysqld.inc | ||
|
|
||
| SET @@session.gtid_domain_id= 0; | ||
| SET @@session.server_id= 1; | ||
| INSERT INTO t1 VALUES (3); | ||
|
|
||
| # end of binlog-000002.ibb | ||
|
|
||
| FLUSH BINARY LOGS; | ||
|
|
||
| --let $binlog_name= binlog-000003.ibb | ||
| --let $binlog_size= 262144 | ||
| --source include/wait_for_engine_binlog.inc | ||
|
|
||
|
|
||
| --echo *** Convert the generated InnoDB binlogs to legacy format | ||
| --exec $MYSQL_BINLOG --convert-engine-binlog --result-file=$MYSQL_TMP_DIR/gtid_conv $datadir/binlog-000000.ibb $datadir/binlog-000001.ibb $datadir/binlog-000002.ibb | ||
|
|
||
| --echo *** Verify synthesized Gtid_list events in converted legacy binlogs | ||
| --exec $MYSQL_BINLOG --verbose $MYSQL_TMP_DIR/gtid_conv.000001 > $MYSQL_TMP_DIR/gtid_conv_listing.txt | ||
| --let SEARCH_FILE= $MYSQL_TMP_DIR/gtid_conv_listing.txt | ||
| --let SEARCH_PATTERN= Gtid list \[\] | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| --exec $MYSQL_BINLOG --verbose $MYSQL_TMP_DIR/gtid_conv.000002 > $MYSQL_TMP_DIR/gtid_conv_listing.txt | ||
| --let SEARCH_PATTERN= Gtid list \[0-1-1,\n# 1-2-1\] | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| --exec $MYSQL_BINLOG --verbose $MYSQL_TMP_DIR/gtid_conv.000003 > $MYSQL_TMP_DIR/gtid_conv_listing.txt | ||
| --let SEARCH_PATTERN= Gtid list \[0-1-2,\n# 1-2-1,\n# 2-3-1\] | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| --exec $MYSQL_BINLOG --verbose $MYSQL_TMP_DIR/gtid_conv.000004 > $MYSQL_TMP_DIR/gtid_conv_listing.txt | ||
| --let SEARCH_PATTERN= Gtid list \[0-1-2,\n# 1-2-1,\n# 1-1-2,\n# 2-3-1,\n# 3-4-1\] | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| --remove_file $MYSQL_TMP_DIR/gtid_conv_listing.txt | ||
| --remove_file $MYSQL_TMP_DIR/gtid_conv.000001 | ||
| --remove_file $MYSQL_TMP_DIR/gtid_conv.000002 | ||
| --remove_file $MYSQL_TMP_DIR/gtid_conv.000003 | ||
| --remove_file $MYSQL_TMP_DIR/gtid_conv.000004 | ||
|
|
||
|
|
||
| --echo *** Convert the generated InnoDB binlog(binlog-000002.ibb) to legacy format in random order | ||
| --exec $MYSQL_BINLOG --convert-engine-binlog --result-file=$MYSQL_TMP_DIR/gtid_conv $datadir/binlog-000002.ibb | ||
|
|
||
| --echo *** Verify synthesized Gtid_list events in converted legacy binlogs | ||
| --exec $MYSQL_BINLOG --verbose $MYSQL_TMP_DIR/gtid_conv.000001 > $MYSQL_TMP_DIR/gtid_conv_listing.txt | ||
| --let SEARCH_FILE= $MYSQL_TMP_DIR/gtid_conv_listing.txt | ||
| --let SEARCH_PATTERN= Gtid list \[0-1-2,\n# 1-2-1,\n# 1-1-2,\n# 2-3-1,\n# 3-4-1\] | ||
| # TODO: Tarun this search will fail now as this functionality is not yet implemented | ||
| --source include/search_pattern_in_file.inc | ||
|
|
||
| --remove_file $MYSQL_TMP_DIR/gtid_conv_listing.txt | ||
| --remove_file $MYSQL_TMP_DIR/gtid_conv.000001 | ||
|
|
||
|
|
||
| DROP TABLE t1; | ||
| DROP TABLE t2; | ||
| DROP TABLE t3; | ||
| DROP TABLE t4; |
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.
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.
If
listisNULL(which can happen ifmy_mallocfailed during construction or if the event is invalid), dereferencinglist[i]in the loop will cause a crash. We should checkis_valid()orlist != NULLbefore proceeding. This also cleans up a double semicolon typo on line 2850.