Skip to content
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

New VReplication workflows cli UX. Allow reads/writes to be switched independently #7071

Merged
merged 26 commits into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
96d5608
Initial commit for switching reads and writes independently
rohit-nayak-ps Nov 19, 2020
8c1d6d1
Added tests for new sr/sw flows. Remove validations no longer applica…
rohit-nayak-ps Nov 23, 2020
88c7a95
Initial commit of a state-machine based MoveTables workflow
rohit-nayak-ps Nov 27, 2020
6bb0454
Minor fixes/cleanup
rohit-nayak-ps Nov 30, 2020
601182c
MoveTablesv2: -v2 flag, Refactored tests/code. Added code for Workflo…
rohit-nayak-ps Dec 6, 2020
0e2016a
Test reverse flows, show copy progress
rohit-nayak-ps Dec 15, 2020
7bdb870
Update wrangler table migration unit tests
rohit-nayak-ps Dec 16, 2020
0f52f23
Removed state machine since it does not fit the use case, use SwitchT…
rohit-nayak-ps Dec 17, 2020
583035d
Add more validations, implement workflow state
rohit-nayak-ps Dec 18, 2020
b990a3f
Add single step switch/reverse traffic test, get existing tests working
rohit-nayak-ps Dec 18, 2020
b64025d
Fix more tests
rohit-nayak-ps Dec 19, 2020
820e6e9
Add tests for Complete/Abort, fix check for switched writes
rohit-nayak-ps Dec 19, 2020
c288334
Fix state computation for reverse writes, add tests for states pre/po…
rohit-nayak-ps Dec 20, 2020
8df1ca7
Common VReplicationWorkflow abstraction for both MoveTables and Reshard
rohit-nayak-ps Dec 21, 2020
d093aa3
Mods for reshard v2 command, Tests for reshard flow
rohit-nayak-ps Dec 22, 2020
2157e91
Minor cleanup
rohit-nayak-ps Dec 22, 2020
a40c31f
Minor cleanup, some comments
rohit-nayak-ps Dec 23, 2020
6d8f21c
Tests for switching cells partially, add rdonly tablets to test
rohit-nayak-ps Dec 24, 2020
3fce881
Unit tests for move tables and copy progress
rohit-nayak-ps Dec 25, 2020
9dcd560
Add tests for reverse and abort
rohit-nayak-ps Dec 25, 2020
2a7a492
Fix Start validation
rohit-nayak-ps Dec 26, 2020
962b81c
Filter out backquotes while checking if query is executed on a tablet…
rohit-nayak-ps Dec 26, 2020
6271514
Remove rdonly for CI and move V2 test to new test shard
rohit-nayak-ps Dec 26, 2020
b3c1d7b
Revert local changes to local example script
rohit-nayak-ps Dec 26, 2020
35cd400
Improve test coverage, fix reshard test
rohit-nayak-ps Dec 30, 2020
4b8eb39
Fix debug flag
rohit-nayak-ps Jan 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ require (
github.com/klauspost/pgzip v1.2.4
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/krishicks/yaml-patch v0.0.10
github.com/looplab/fsm v0.2.0
github.com/magiconair/properties v1.8.1
github.com/martini-contrib/auth v0.0.0-20150219114609-fa62c19b7ae8
github.com/martini-contrib/gzip v0.0.0-20151124214156-6c035326b43f
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/krishicks/yaml-patch v0.0.10 h1:H4FcHpnNwVmw8u0MjPRjWyIXtco6zM2F78t+57oNM3E=
github.com/krishicks/yaml-patch v0.0.10/go.mod h1:Sm5TchwZS6sm7RJoyg87tzxm2ZcKzdRE4Q7TjNhPrME=
github.com/looplab/fsm v0.2.0 h1:M8hf5EF4AYLcT1FNKVUX8nu7D0xfp291iGeuigSxfrw=
github.com/looplab/fsm v0.2.0/go.mod h1:p+IElwgCnAByqr2DWMuNbPjgMwqcHvTRZZn3dvKEke0=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
Expand Down
4 changes: 4 additions & 0 deletions go/cmd/vtctlclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package main
import (
"errors"
"flag"
"fmt"
"os"
"strings"
"time"

"golang.org/x/net/context"
Expand Down Expand Up @@ -64,6 +66,8 @@ func main() {
logutil.LogEvent(logger, e)
})
if err != nil {
errStr := strings.Replace(err.Error(), "remote error: ", "", -1)
fmt.Printf("%s Error: %s\n", flag.Arg(0), errStr)
log.Error(err)
os.Exit(1)
}
Expand Down
3 changes: 2 additions & 1 deletion go/test/endtoend/vreplication/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
)

var (
debug = false // set to true to always use local env vtdataroot for local debugging
debug = false // set to true to always use local env vtdataroot for local debugging

originalVtdataroot string
vtdataroot string
)
Expand Down
22 changes: 20 additions & 2 deletions go/test/endtoend/vreplication/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@ var (
initialProductSchema = `
create table product(pid int, description varbinary(128), primary key(pid));
create table customer(cid int, name varbinary(128), typ enum('individual','soho','enterprise'), sport set('football','cricket','baseball'),ts timestamp not null default current_timestamp, primary key(cid));
create table customer_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence';
create table merchant(mname varchar(128), category varchar(128), primary key(mname)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
create table orders(oid int, cid int, pid int, mname varchar(128), price int, primary key(oid));
create table customer_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence';
create table order_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence';
create table customer2(cid int, name varbinary(128), typ enum('individual','soho','enterprise'), sport set('football','cricket','baseball'),ts timestamp not null default current_timestamp, primary key(cid));
create table customer_seq2(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence';
`

initialProductVSchema = `
{
"tables": {
"product": {},
"customer": {},
"merchant": {},
"orders": {},
"customer": {},
"customer_seq": {
"type": "sequence"
},
"customer2": {},
"customer_seq2": {
"type": "sequence"
},
"order_seq": {
"type": "sequence"
}
Expand Down Expand Up @@ -47,6 +53,18 @@ create table order_seq(id int, next_id bigint, cache bigint, primary key(id)) co
"column": "cid",
"sequence": "customer_seq"
}
},
"customer2": {
"column_vindexes": [
{
"column": "cid",
"name": "reverse_bits"
}
],
"auto_increment": {
"column": "cid",
"sequence": "customer_seq2"
}
}
}

Expand Down
29 changes: 24 additions & 5 deletions go/test/endtoend/vreplication/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/require"

"github.com/buger/jsonparser"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/test/endtoend/cluster"

Expand Down Expand Up @@ -145,13 +144,16 @@ func getQueryCount(url string, query string) int {
if len(row) != len(headings) {
continue
}
filterChars := []string{"_", "`"}
//Queries seem to include non-printable characters at times and hence equality fails unless these are removed
re := regexp.MustCompile("[[:^ascii:]]")
foundQuery := re.ReplaceAllLiteralString(row[queryIndex], "")
foundQuery = strings.ReplaceAll(foundQuery, "_", "")
cleanQuery := re.ReplaceAllLiteralString(query, "")
cleanQuery = strings.ReplaceAll(cleanQuery, "_", "")
if foundQuery == cleanQuery {
for _, filterChar := range filterChars {
foundQuery = strings.ReplaceAll(foundQuery, filterChar, "")
cleanQuery = strings.ReplaceAll(cleanQuery, filterChar, "")
}
if foundQuery == cleanQuery || strings.Contains(foundQuery, cleanQuery) {
count, _ = strconv.Atoi(row[countIndex])
}
}
Expand Down Expand Up @@ -239,3 +241,20 @@ func printShardPositions(vc *VitessCluster, ksShards []string) {
}
}
}

func clearRoutingRules(t *testing.T, vc *VitessCluster) error {
if _, err := vc.VtctlClient.ExecuteCommandWithOutput("ApplyRoutingRules", "-rules={}"); err != nil {
return err
}
return nil
}

func printRoutingRules(t *testing.T, vc *VitessCluster, msg string) error {
var output string
var err error
if output, err = vc.VtctlClient.ExecuteCommandWithOutput("GetRoutingRules"); err != nil {
return err
}
fmt.Printf("Routing Rules::%s:\n%s\n", msg, output)
return nil
}
Loading