Skip to content

Commit f18f07b

Browse files
Update
Signed-off-by: Rohit Nayak <[email protected]>
1 parent d4e83e7 commit f18f07b

File tree

8 files changed

+142
-31
lines changed

8 files changed

+142
-31
lines changed

examples/.cleanup.sh.swp

-12 KB
Binary file not shown.

examples/adopt.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sleep 2
2828
echo ">>>>>> Step 3. Calling MoveTables"
2929

3030
vtctlclient MoveTables -tablet_types=MASTER -workflow=commerce2customer commerce customer customer,corder #'{"customer":{}, "corder":{}}'
31-
echo ">>>>> Step 4. Waiting for Vreplication to be copy the data ..."
31+
echo ">>>>> Step 4. Waiting for Vreplication to copy the data ..."
3232
sleep 5
3333
echo ">>>>> Step 5. Run VDiff "
3434
vtctlclient VDiff customer.commerce2customer
@@ -38,25 +38,34 @@ vtctlclient SwitchReads -tablet_type=replica customer.commerce2customer
3838
sleep 5
3939
echo ">>>>>> Step 7. Calling SwitchWrites"
4040
vtctlclient SwitchWrites customer.commerce2customer
41-
exit
42-
echo ">>>>> Step 8. Run VDiff after inserting data into the customer keyspace"
41+
vtctlclient VExec commerce.commerce2customer_reverse "select * from _vt.vreplication"
4342

43+
echo ">>>>> Step 8. Run VDiff after inserting data into the customer keyspace"
44+
sleep 15
4445
mysql -h 127.0.0.1 -P 15306 -u msandbox --password=msandbox customer < sql/insert_commerce_data_after_switch.sql
4546

47+
#//BUG: tables customer/corder not found in schema
48+
#exit
49+
4650
vtctlclient VDiff commerce.commerce2customer_reverse
4751

4852
echo "Steps for rolling back"
53+
vtctlclient VExec commerce.commerce2customer_reverse "select * from _vt.vreplication"
4954

5055
echo ">>>>>> Step 9. Rollback SwitchReads"
5156
vtctlclient SwitchReads -tablet_type=rdonly commerce.commerce2customer_reverse
5257
vtctlclient SwitchReads -tablet_type=replica commerce.commerce2customer_reverse
58+
vtctlclient VExec commerce.commerce2customer_reverse "select * from _vt.vreplication"
59+
5360

5461
echo ">>>>>> Step 10. Rollback SwitchWrites"
5562
vtctlclient SwitchWrites commerce.commerce2customer_reverse
5663

5764
echo ">>>>>> Rolled back to original setup. VReplication is still running on Vitess cluster, so you can still move forward ..."
5865

5966

60-
mysql -h 127.0.0.1 -P $DB_PORT -u msandbox --password=msandbox commerce < sql/insert_commerce_data_after_rollback.sql
67+
mysql -h 127.0.0.1 -P 19327 -u msandbox --password=msandbox commerce < sql/insert_commerce_data_after_rollback.sql
6168

6269
vtctlclient VDiff customer.commerce2customer
70+
71+
echo ">>>>>>>>> ALL DONE"

examples/load.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
echo ">>>>> Cleaning up previous runs, if any"
2+
./cleanup.sh
3+
4+
source ./env.sh
5+
6+
echo ">>>>>> Starting etcd"
7+
scripts/etcd-up.sh
8+
echo ">>>>>> Starting vtctld"
9+
scripts/vtctld-up.sh
10+
echo ">>>>>> Starting vtgate"
11+
scripts/vtgate-up.sh
12+
sleep 2
13+
echo ">>>>>> Step 1: Starting unmanaged tablet (load1 keyspace)"
14+
scripts/unmanaged_load.sh
15+
sleep 5
16+
17+
echo ">>>>>> Step 2: Starting load2 tablets"
18+
for shard in "0"; do
19+
for i in 200 201 202; do
20+
CELL=zone1 TABLET_UID=$i ./scripts/mysqlctl-up.sh
21+
CELL=zone1 KEYSPACE=load2 TABLET_UID=$i SHARD=$shard ./scripts/vttablet-up.sh
22+
done
23+
done
24+
25+
sleep 10
26+
27+
vtctlclient -server localhost:15999 InitShardMaster -force load2/0 zone1-200
28+
sleep 2
29+
vtctlclient -server localhost:15999 MoveTables -tablet_types=MASTER -workflow=wf1 load1 load2 c1
30+
sleep 5
31+
vtctlclient -server localhost:15999 VDiff load2.wf1
32+
exit
33+
34+
sleep 2
35+
echo ">>>>>> Step 3. Calling MoveTables"
36+
37+
vtctlclient MoveTables -tablet_types=MASTER -workflow=wf1 load1 load2 c1
38+
#vtctlclient MoveTables -tablet_types=MASTER -workflow=wf2 load1 load2 table2
39+
#vtctlclient MoveTables -tablet_types=MASTER -workflow=wf3 load1 load2 table3
40+
#vtctlclient MoveTables -tablet_types=MASTER -workflow=wf4 load1 load2 table4
41+
42+
echo ">>>>> Step 4. Waiting for Vreplication to copy the data ..."
43+
sleep 5
44+
echo ">>>>> Step 5. Run VDiff "
45+
vtctlclient VDiff load2.wf
46+
echo ">>>>>> Step 6. Calling SwitchReads"
47+
vtctlclient SwitchReads -tablet_type=rdonly load2.wf
48+
vtctlclient SwitchReads -tablet_type=replica load2.wf
49+
sleep 5
50+
echo ">>>>>> Step 7. Calling SwitchWrites"
51+
vtctlclient SwitchWrites load2.wf

examples/scripts/unmanaged_load.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
source env.sh
2+
mkdir -p $VTDATAROOT/vt_0000000100
3+
DB_USER=msandbox
4+
DB_PASS=msandbox
5+
DB_PORT=19327
6+
vttablet \
7+
$TOPOLOGY_FLAGS \
8+
-logtostderr \
9+
-log_queries_to_file $VTDATAROOT/tmp/vttablet_0000000100_querylog.txt \
10+
-tablet-path "zone1-0000000100" \
11+
-init_keyspace load1 \
12+
-init_shard 0 \
13+
-init_tablet_type replica \
14+
-port 15100 \
15+
-grpc_port 16100 \
16+
-service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \
17+
-pid_file $VTDATAROOT/vt_0000000100/vttablet.pid \
18+
-vtctld_addr http://localhost:15000/ \
19+
-db_host 127.0.0.1 \
20+
-db_port $DB_PORT \
21+
-db_app_user $DB_USER \
22+
-db_app_password $DB_PASS \
23+
-db_allprivs_user $DB_USER \
24+
-db_allprivs_password $DB_PASS \
25+
-db_appdebug_user $DB_USER \
26+
-db_appdebug_password $DB_PASS \
27+
-db_dba_user $DB_USER \
28+
-db_dba_password $DB_PASS \
29+
-db_filtered_user $DB_USER \
30+
-db_filtered_password $DB_PASS \
31+
-db_repl_user $DB_USER \
32+
-db_repl_password $DB_PASS \
33+
-vtctld_addr http://$hostname:$vtctld_web_port/ \
34+
-init_db_name_override test \
35+
-init_populate_metadata \
36+
> $VTDATAROOT/vt_0000000100/vttablet.out 2>&1 &
37+
38+
sleep 10
39+
40+
vtctlclient InitShardMaster -force load1/0 zone1-100
41+
42+
# create the vschema
43+
vtctlclient ApplyVSchema -vschema_file sql/vschema_load_initial.json load1

examples/scripts/vttablet-up.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

33
# Copyright 2019 The Vitess Authors.
4-
#
4+
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
77
# You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing, software
1212
# distributed under the License is distributed on an "AS IS" BASIS,
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -46,6 +46,7 @@ vttablet \
4646
-init_tablet_type $tablet_type \
4747
-health_check_interval 5s \
4848
-enable_semi_sync \
49+
-watch_replication_stream \
4950
-enable_replication_reporter \
5051
-backup_storage_implementation file \
5152
-file_backup_storage_root $VTDATAROOT/backups \

examples/sql/create_commerce_schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use commerce;
22
drop table if exists product;
33
drop table if exists customer;
44
drop table if exists corder;
5-
5+
drop database if exists _vt;
66
create table product(
77
sku varbinary(128),
88
description varbinary(128),
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tables": {
3+
"c1": {}
4+
}
5+
}

examples/vstream/vstream_client.go

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,44 @@ func main() {
1818
vstreamCopy()
1919
}
2020

21-
var vgtid_current_customerAllShards = &binlogdatapb.VGtid{
22-
ShardGtids: []*binlogdatapb.ShardGtid{{
23-
Keyspace: "customer",
24-
Shard: "-80",
25-
Gtid: "current",
26-
},{
27-
Keyspace: "customer",
28-
Shard: "80-",
29-
Gtid: "current",
30-
}},
31-
}
32-
33-
var vgtid_copy_commerce = &binlogdatapb.VGtid{
34-
ShardGtids: []*binlogdatapb.ShardGtid{{
35-
Keyspace: "customer",
36-
Shard: "80-",
37-
Gtid: "",
38-
}},
39-
}
40-
4121
func vstreamCurrent() {
22+
vgtid := &binlogdatapb.VGtid{
23+
ShardGtids: []*binlogdatapb.ShardGtid{{
24+
Keyspace: "customer",
25+
Shard: "-80",
26+
Gtid: "current",
27+
},{
28+
Keyspace: "customer",
29+
Shard: "80-",
30+
Gtid: "current",
31+
}},
32+
}
4233
filter := &binlogdatapb.Filter{
4334
Rules: []*binlogdatapb.Rule{{
4435
Match: "/.*/",
4536
}},
4637
}
47-
startVStream(vgtid_current_customerAllShards, filter)
38+
startVStream(vgtid, filter)
4839
}
4940

5041
func vstreamCopy() {
42+
vgtid := &binlogdatapb.VGtid{
43+
ShardGtids: []*binlogdatapb.ShardGtid{{
44+
Keyspace: "customer",
45+
Shard: "80-",
46+
Gtid: "",
47+
},{
48+
Keyspace: "customer",
49+
Shard: "-80",
50+
Gtid: "",
51+
}},
52+
}
5153
filter := &binlogdatapb.Filter{
5254
Rules: []*binlogdatapb.Rule{{
53-
Match: "/customer/",
55+
Match: "/c.*/",
5456
}},
5557
}
56-
startVStream(vgtid_copy_commerce, filter)
58+
startVStream(vgtid, filter)
5759
}
5860

5961
func startVStream(vgtid *binlogdatapb.VGtid, filter *binlogdatapb.Filter) {

0 commit comments

Comments
 (0)