-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rampup][clone] Persist synchronization gtid from P_S.log_status
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D55614528
- Loading branch information
sunxiayi
committed
Apr 30, 2024
1 parent
f010842
commit 2ddce33
Showing
15 changed files
with
499 additions
and
30 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
mysql-test/suite/clone/r/local_create_synchronization_coordinates.result
This file contains 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,37 @@ | ||
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY=ON; | ||
SET @@GLOBAL.GTID_MODE=OFF_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=ON_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=ON; | ||
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 char(64)); | ||
INSERT INTO t1 VALUES(10, 'clone row 1'); | ||
INSERT INTO t1 VALUES(20, 'clone row 2'); | ||
INSERT INTO t1 VALUES(30, 'clone row 3'); | ||
INSTALL PLUGIN clone SONAME 'CLONE_PLUGIN'; | ||
SET GLOBAL clone_autotune_concurrency = OFF; | ||
SET GLOBAL clone_max_concurrency = 8; | ||
CLONE LOCAL DATA DIRECTORY = 'CLONE_DATADIR'; | ||
select ID, STATE, ERROR_NO from performance_schema.clone_status; | ||
ID STATE ERROR_NO | ||
1 Completed 0 | ||
select ID, STAGE, STATE from performance_schema.clone_progress; | ||
ID STAGE STATE | ||
1 DROP DATA Completed | ||
1 FILE COPY Completed | ||
1 PAGE COPY Completed | ||
1 SST COPY Completed | ||
1 REDO COPY Completed | ||
1 FILE SYNC Completed | ||
1 RESTART Not Started | ||
1 RECOVERY Not Started | ||
SELECT * from t1 ORDER BY col1; | ||
col1 col2 | ||
10 clone row 1 | ||
20 clone row 2 | ||
30 clone row 3 | ||
#synchronization_coordinates contents match content from log_status table. | ||
SET @@GLOBAL.GTID_MODE=ON_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=OFF_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=OFF; | ||
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY=OFF; | ||
DROP TABLE t1; | ||
UNINSTALL PLUGIN clone; |
38 changes: 38 additions & 0 deletions
38
mysql-test/suite/clone/r/remote_create_synchronization_coordinates.result
This file contains 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,38 @@ | ||
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY=ON; | ||
SET @@GLOBAL.GTID_MODE=OFF_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=ON_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=ON; | ||
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 char(64)); | ||
INSERT INTO t1 VALUES(10, 'clone row 1'); | ||
INSERT INTO t1 VALUES(20, 'clone row 2'); | ||
INSERT INTO t1 VALUES(30, 'clone row 3'); | ||
INSTALL PLUGIN clone SONAME 'CLONE_PLUGIN'; | ||
SET GLOBAL clone_autotune_concurrency = OFF; | ||
SET GLOBAL clone_max_concurrency = 8; | ||
SET GLOBAL clone_valid_donor_list = 'AnY'; | ||
CLONE INSTANCE FROM USER@HOST:PORT IDENTIFIED BY '' DATA DIRECTORY = 'CLONE_DATADIR'; | ||
select ID, STATE, ERROR_NO from performance_schema.clone_status; | ||
ID STATE ERROR_NO | ||
1 Completed 0 | ||
select ID, STAGE, STATE from performance_schema.clone_progress; | ||
ID STAGE STATE | ||
1 DROP DATA Completed | ||
1 FILE COPY Completed | ||
1 PAGE COPY Completed | ||
1 SST COPY Completed | ||
1 REDO COPY Completed | ||
1 FILE SYNC Completed | ||
1 RESTART Not Started | ||
1 RECOVERY Not Started | ||
SELECT * from t1 ORDER BY col1; | ||
col1 col2 | ||
10 clone row 1 | ||
20 clone row 2 | ||
30 clone row 3 | ||
#synchronization_coordinates contents match content from log_status table. | ||
SET @@GLOBAL.GTID_MODE=ON_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=OFF_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=OFF; | ||
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY=OFF; | ||
DROP TABLE t1; | ||
UNINSTALL PLUGIN clone; |
104 changes: 104 additions & 0 deletions
104
mysql-test/suite/clone/t/local_create_synchronization_coordinates.test
This file contains 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,104 @@ | ||
# Test after local clone command, synchronization_coordinates file is created | ||
# synchronization_coordinates file contains 4 key/val pairs, only examine 3 Here | ||
# excluding gtid get from binlog_file/offset | ||
|
||
--source include/have_example_plugin.inc | ||
--source ../include/clone_connection_begin.inc | ||
|
||
# Populate gtid | ||
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY=ON; | ||
SET @@GLOBAL.GTID_MODE=OFF_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=ON_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=ON; | ||
|
||
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 char(64)); | ||
INSERT INTO t1 VALUES(10, 'clone row 1'); | ||
INSERT INTO t1 VALUES(20, 'clone row 2'); | ||
INSERT INTO t1 VALUES(30, 'clone row 3'); | ||
|
||
# Install Clone Plugin | ||
--replace_result $CLONE_PLUGIN CLONE_PLUGIN | ||
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN' | ||
|
||
# Clone data | ||
--connection clone_conn_1 | ||
--let $CLONE_DATADIR = $MYSQL_TMP_DIR/data_new | ||
--source ../include/clone_command.inc | ||
--connection default | ||
|
||
# Validate data | ||
SELECT * from t1 ORDER BY col1; | ||
|
||
# Validate gtid value | ||
--disable_query_log | ||
output $MYSQLTEST_VARDIR/tmp/v_local.json; | ||
SELECT local FROM performance_schema.log_status; | ||
--enable_query_log | ||
file_exists $CLONE_DATADIR/#clone/#synchronization_coordinates; | ||
|
||
--perl | ||
use JSON; | ||
my $json_text; | ||
{ | ||
open(my $json_fh, "<:encoding(UTF-8)", "$ENV{MYSQLTEST_VARDIR}/tmp/v_local.json") | ||
or die("Can't open \$ENV{MYSQLTEST_VARDIR}/tmp/v_local.json\": $!\n"); | ||
my $line_count = 0; | ||
while (my $line = <$json_fh>) { | ||
$line_count++; | ||
if ($line_count == 2) { | ||
$json_text = $line; | ||
last; # Exit the loop after reading the second line | ||
} | ||
} | ||
close($json_fh); | ||
} | ||
|
||
my $data = decode_json($json_text); | ||
my $gtid = $data->{"gtid_executed"}; | ||
my $binlog_file = $data->{"binary_log_file"}; | ||
my $binlog_pos = $data->{"binary_log_position"}; | ||
chomp($gtid); # Normalize | ||
chomp($binlog_file); # Normalize | ||
chomp($binlog_pos); # Normalize | ||
open(my $fh, '<', "$ENV{MYSQL_TMP_DIR}/data_new/#clone/#synchronization_coordinates") or die "Cannot open #synchronization_coordinates file: $!"; | ||
my $line_number = 1; | ||
my ($gtid_created, $binlog_file_created, $binlog_pos_created); | ||
while (my $line = <$fh>) { | ||
chomp $line; # Remove newline character | ||
if ($line_number == 2) { | ||
$gtid_created = $line; | ||
} | ||
elsif ($line_number == 4) { | ||
$binlog_file_created = $line; | ||
} | ||
elsif ($line_number == 6) { | ||
$binlog_pos_created = $line; | ||
} | ||
last if $line_number >= 6; # Stop processing after line 6 | ||
$line_number++; | ||
} | ||
close $fh; | ||
|
||
if ($gtid eq $gtid_created && $binlog_file == $binlog_file_created && $binlog_pos == $binlog_pos_created) { | ||
print "#synchronization_coordinates contents match content from log_status table.\n"; | ||
} else { | ||
print "gtid from log_status: |$gtid|\n"; | ||
print "gtid from file: |$gtid_created|\n"; | ||
print "binlog_file from log_status: |$binlog_file|\n"; | ||
print "binlog_file from file: |$binlog_file_created|\n"; | ||
print "binlog_pos from log_status: |$binlog_pos|\n"; | ||
print "binlog_pos from file: |$binlog_pos_created|\n"; | ||
die "Mismatch between #synchronization_coordinates and log_status table."; | ||
} | ||
EOF | ||
|
||
# Cleanup | ||
SET @@GLOBAL.GTID_MODE=ON_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=OFF_PERMISSIVE; | ||
SET @@GLOBAL.GTID_MODE=OFF; | ||
SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY=OFF; | ||
DROP TABLE t1; | ||
UNINSTALL PLUGIN clone; | ||
--force-rmdir $CLONE_DATADIR | ||
--exec rm -f $MYSQLTEST_VARDIR/tmp/v_local.json; | ||
--source ../include/clone_connection_end.inc |
9 changes: 9 additions & 0 deletions
9
mysql-test/suite/clone/t/remote_create_synchronization_coordinates.test
This file contains 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,9 @@ | ||
# Test after remote clone command to replace data directory, synchronization_coordinates file is created | ||
|
||
--let $remote_clone = 1 | ||
--let $any_donor_address = 1 | ||
--let $HOST = 127.0.0.1 | ||
--let $PORT =`select @@port` | ||
--let $USER = root | ||
|
||
--source local_create_synchronization_coordinates.test |
This file contains 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 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 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 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 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 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.