-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/vt/wrangler: reduce VReplicationExec calls when getting copy state (…
…#14375) Signed-off-by: Max Englander <[email protected]> Signed-off-by: Max Englander <[email protected]> Co-authored-by: Matt Lord <[email protected]>
- Loading branch information
1 parent
e5b7def
commit 2783e32
Showing
14 changed files
with
2,170 additions
and
1,930 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -149,7 +149,8 @@ func TestMoveTables(t *testing.T) { | |
shard := "0" | ||
sourceKs := "sourceks" | ||
targetKs := "targetks" | ||
table := "customer" | ||
table1 := "customer" | ||
table2 := "customer_order" | ||
wf := "testwf" | ||
ksWf := fmt.Sprintf("%s.%s", targetKs, wf) | ||
minTableSize := 16384 // a single 16KiB InnoDB page | ||
|
@@ -159,16 +160,22 @@ func TestMoveTables(t *testing.T) { | |
defer env.close() | ||
source := env.addTablet(100, sourceKs, shard, &topodatapb.KeyRange{}, topodatapb.TabletType_PRIMARY) | ||
target := env.addTablet(200, targetKs, shard, &topodatapb.KeyRange{}, topodatapb.TabletType_PRIMARY) | ||
sourceCol := fmt.Sprintf(`keyspace:"%s" shard:"%s" filter:{rules:{match:"%s" filter:"select * from %s"}}`, | ||
sourceKs, shard, table, table) | ||
sourceCol := fmt.Sprintf(`keyspace:"%s" shard:"%s" filter:{rules:{match:"%s" filter:"select * from %s"} rules:{match:"%s" filter:"select * from %s"}}`, | ||
sourceKs, shard, table1, table1, table2, table2) | ||
bls := &binlogdatapb.BinlogSource{ | ||
Keyspace: sourceKs, | ||
Shard: shard, | ||
Filter: &binlogdatapb.Filter{ | ||
Rules: []*binlogdatapb.Rule{{ | ||
Match: table, | ||
Filter: fmt.Sprintf("select * from %s", table), | ||
}}, | ||
Rules: []*binlogdatapb.Rule{ | ||
{ | ||
Match: table1, | ||
Filter: fmt.Sprintf("select * from %s", table1), | ||
}, | ||
{ | ||
Match: table2, | ||
Filter: fmt.Sprintf("select * from %s", table2), | ||
}, | ||
}, | ||
}, | ||
} | ||
now := time.Now().UTC().Unix() | ||
|
@@ -200,12 +207,13 @@ func TestMoveTables(t *testing.T) { | |
expectResults: func() { | ||
env.tmc.setVRResults( | ||
target.tablet, | ||
fmt.Sprintf("select table_name, lastpk from _vt.copy_state where vrepl_id = %d and id in (select max(id) from _vt.copy_state where vrepl_id = %d group by vrepl_id, table_name)", | ||
fmt.Sprintf("select vrepl_id, table_name, lastpk from _vt.copy_state where vrepl_id in (%d) and id in (select max(id) from _vt.copy_state where vrepl_id in (%d) group by vrepl_id, table_name)", | ||
vrID, vrID), | ||
sqltypes.MakeTestResult(sqltypes.MakeTestFields( | ||
"table_name|lastpk", | ||
"varchar|varbinary"), | ||
fmt.Sprintf("%s|", table), | ||
"vrepl_id|table_name|lastpk", | ||
"int64|varchar|varbinary"), | ||
fmt.Sprintf("%d|%s|", vrID, table1), | ||
fmt.Sprintf("%d|%s|", vrID, table2), | ||
), | ||
) | ||
env.tmc.setDBAResults( | ||
|
@@ -215,7 +223,8 @@ func TestMoveTables(t *testing.T) { | |
sqltypes.MakeTestResult(sqltypes.MakeTestFields( | ||
"table_name", | ||
"varchar"), | ||
table, | ||
table1, | ||
table2, | ||
), | ||
) | ||
env.tmc.setVRResults( | ||
|
@@ -231,26 +240,28 @@ func TestMoveTables(t *testing.T) { | |
) | ||
env.tmc.setDBAResults( | ||
target.tablet, | ||
fmt.Sprintf("select table_name, table_rows, data_length from information_schema.tables where table_schema = 'vt_%s' and table_name in ('%s')", | ||
targetKs, table), | ||
fmt.Sprintf("select table_name, table_rows, data_length from information_schema.tables where table_schema = 'vt_%s' and table_name in ('%s','%s')", | ||
targetKs, table1, table2), | ||
sqltypes.MakeTestResult(sqltypes.MakeTestFields( | ||
"table_name|table_rows|data_length", | ||
"varchar|int64|int64"), | ||
fmt.Sprintf("%s|0|%d", table, minTableSize), | ||
fmt.Sprintf("%s|0|%d", table1, minTableSize), | ||
fmt.Sprintf("%s|0|%d", table2, minTableSize), | ||
), | ||
) | ||
env.tmc.setDBAResults( | ||
source.tablet, | ||
fmt.Sprintf("select table_name, table_rows, data_length from information_schema.tables where table_schema = 'vt_%s' and table_name in ('%s')", | ||
sourceKs, table), | ||
fmt.Sprintf("select table_name, table_rows, data_length from information_schema.tables where table_schema = 'vt_%s' and table_name in ('%s','%s')", | ||
sourceKs, table1, table2), | ||
sqltypes.MakeTestResult(sqltypes.MakeTestFields( | ||
"table_name|table_rows|data_length", | ||
"varchar|int64|int64"), | ||
fmt.Sprintf("%s|10|%d", table, minTableSize), | ||
fmt.Sprintf("%s|10|%d", table1, minTableSize), | ||
fmt.Sprintf("%s|10|%d", table2, minTableSize), | ||
), | ||
) | ||
}, | ||
want: fmt.Sprintf("\nCopy Progress (approx):\n\n\ncustomer: rows copied 0/10 (0%%), size copied 16384/16384 (100%%)\n\n\n\nThe following vreplication streams exist for workflow %s:\n\nid=%d on %s/%s-0000000%d: Status: Copying. VStream has not started.\n\n\n", | ||
want: fmt.Sprintf("\nCopy Progress (approx):\n\n\ncustomer: rows copied 0/10 (0%%), size copied 16384/16384 (100%%)\ncustomer_order: rows copied 0/10 (0%%), size copied 16384/16384 (100%%)\n\n\n\nThe following vreplication streams exist for workflow %s:\n\nid=%d on %s/%s-0000000%d: Status: Copying. VStream has not started.\n\n\n", | ||
ksWf, vrID, shard, env.cell, target.tablet.Alias.Uid), | ||
}, | ||
{ | ||
|
@@ -260,12 +271,13 @@ func TestMoveTables(t *testing.T) { | |
expectResults: func() { | ||
env.tmc.setVRResults( | ||
target.tablet, | ||
fmt.Sprintf("select table_name, lastpk from _vt.copy_state where vrepl_id = %d and id in (select max(id) from _vt.copy_state where vrepl_id = %d group by vrepl_id, table_name)", | ||
fmt.Sprintf("select vrepl_id, table_name, lastpk from _vt.copy_state where vrepl_id in (%d) and id in (select max(id) from _vt.copy_state where vrepl_id in (%d) group by vrepl_id, table_name)", | ||
vrID, vrID), | ||
sqltypes.MakeTestResult(sqltypes.MakeTestFields( | ||
"table_name|lastpk", | ||
"varchar|varbinary"), | ||
fmt.Sprintf("%s|", table), | ||
"vrepl_id|table_name|lastpk", | ||
"int64|varchar|varbinary"), | ||
fmt.Sprintf("%d|%s|", vrID, table1), | ||
fmt.Sprintf("%d|%s|", vrID, table2), | ||
), | ||
) | ||
env.tmc.setDBAResults( | ||
|
@@ -275,7 +287,8 @@ func TestMoveTables(t *testing.T) { | |
sqltypes.MakeTestResult(sqltypes.MakeTestFields( | ||
"table_name", | ||
"varchar"), | ||
table, | ||
table1, | ||
table2, | ||
), | ||
) | ||
env.tmc.setVRResults( | ||
|
@@ -291,26 +304,28 @@ func TestMoveTables(t *testing.T) { | |
) | ||
env.tmc.setDBAResults( | ||
target.tablet, | ||
fmt.Sprintf("select table_name, table_rows, data_length from information_schema.tables where table_schema = 'vt_%s' and table_name in ('%s')", | ||
targetKs, table), | ||
fmt.Sprintf("select table_name, table_rows, data_length from information_schema.tables where table_schema = 'vt_%s' and table_name in ('%s','%s')", | ||
targetKs, table1, table2), | ||
sqltypes.MakeTestResult(sqltypes.MakeTestFields( | ||
"table_name|table_rows|data_length", | ||
"varchar|int64|int64"), | ||
fmt.Sprintf("%s|5|%d", table, minTableSize), | ||
fmt.Sprintf("%s|5|%d", table1, minTableSize), | ||
fmt.Sprintf("%s|5|%d", table2, minTableSize), | ||
), | ||
) | ||
env.tmc.setDBAResults( | ||
source.tablet, | ||
fmt.Sprintf("select table_name, table_rows, data_length from information_schema.tables where table_schema = 'vt_%s' and table_name in ('%s')", | ||
sourceKs, table), | ||
fmt.Sprintf("select table_name, table_rows, data_length from information_schema.tables where table_schema = 'vt_%s' and table_name in ('%s','%s')", | ||
sourceKs, table1, table2), | ||
sqltypes.MakeTestResult(sqltypes.MakeTestFields( | ||
"table_name|table_rows|data_length", | ||
"varchar|int64|int64"), | ||
fmt.Sprintf("%s|10|%d", table, minTableSize), | ||
fmt.Sprintf("%s|10|%d", table1, minTableSize), | ||
fmt.Sprintf("%s|10|%d", table2, minTableSize), | ||
), | ||
) | ||
}, | ||
want: fmt.Sprintf("\nCopy Progress (approx):\n\n\ncustomer: rows copied 5/10 (50%%), size copied 16384/16384 (100%%)\n\n\n\nThe following vreplication streams exist for workflow %s:\n\nid=%d on %s/%s-0000000%d: Status: Error: Duplicate entry '6' for key 'customer.PRIMARY' (errno 1062) (sqlstate 23000) during query: insert into customer(customer_id,email) values (6,'[email protected]').\n\n\n", | ||
want: fmt.Sprintf("\nCopy Progress (approx):\n\n\ncustomer: rows copied 5/10 (50%%), size copied 16384/16384 (100%%)\ncustomer_order: rows copied 5/10 (50%%), size copied 16384/16384 (100%%)\n\n\n\nThe following vreplication streams exist for workflow %s:\n\nid=%d on %s/%s-0000000%d: Status: Error: Duplicate entry '6' for key 'customer.PRIMARY' (errno 1062) (sqlstate 23000) during query: insert into customer(customer_id,email) values (6,'[email protected]').\n\n\n", | ||
ksWf, vrID, shard, env.cell, target.tablet.Alias.Uid), | ||
}, | ||
{ | ||
|
@@ -320,7 +335,7 @@ func TestMoveTables(t *testing.T) { | |
expectResults: func() { | ||
env.tmc.setVRResults( | ||
target.tablet, | ||
fmt.Sprintf("select table_name, lastpk from _vt.copy_state where vrepl_id = %d and id in (select max(id) from _vt.copy_state where vrepl_id = %d group by vrepl_id, table_name)", | ||
fmt.Sprintf("select vrepl_id, table_name, lastpk from _vt.copy_state where vrepl_id in (%d) and id in (select max(id) from _vt.copy_state where vrepl_id in (%d) group by vrepl_id, table_name)", | ||
vrID, vrID), | ||
&sqltypes.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
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.