Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0c8c5ac
Handle FuncExpr columns
rohit-nayak-ps Aug 27, 2020
a3359a1
Add collation to e2e test to table with unicode_loose_md5
rohit-nayak-ps Aug 27, 2020
272226e
Turn off schema tracker by default
rohit-nayak-ps Sep 13, 2020
a5eacbc
Merge pull request #6746 from planetscale/rn-backport-6712
deepthi Sep 18, 2020
2ae1bc0
Merge pull request #6745 from planetscale/rn-backport-6640
deepthi Sep 18, 2020
7b075b6
end to end test for reserved connection in autocommit mode
harshit-gangal Sep 19, 2020
3b73b84
handle reserved connection in autocommit enabled
harshit-gangal Sep 21, 2020
7f918ea
Merge pull request #6760 from planetscale/bp-6748
deepthi Sep 21, 2020
937dd29
operator precedence must take associativity into consideration
systay Sep 21, 2020
9af279d
add more precedence tests
systay Sep 21, 2020
aea21dc
Merge pull request #6764 from GuptaManan100/release-7.0
systay Sep 22, 2020
0ac6a3d
sort tabledefinitions before comparing them
systay Sep 22, 2020
ec88581
restore: checkNoDB should not require tables to be present when the d…
deepthi Sep 10, 2020
635c0c6
tests: disable schema tracking in reparent tests for now, fix spare t…
deepthi Sep 10, 2020
ee6db6a
Merge pull request #6788 from planetscale/ds-backport-6695
deepthi Sep 25, 2020
b5651b7
Merge pull request #6784 from planetscale/backport-6765
deepthi Sep 28, 2020
61ab6e0
Merge remote-tracking branch 'upstream/release-7.0' into slack-vitess…
ameetkotian Sep 29, 2020
87ee0ee
This is a squashed rebase of am_show_filtered_tablets without the fin…
Sep 19, 2020
6682c70
Regenerate parser post-cherry-pick, fix govet error in tests
Sep 29, 2020
3d2ed67
tm: call SetReadOnly inside ChangeTabletType so that a tablet doesn't…
deepthi Sep 30, 2020
07d0bad
Merge pull request #6804 from planetscale/ds-backport-6762-6786
deepthi Sep 30, 2020
58eb423
Merge remote-tracking branch 'upstream/release-7.0' into slack-vitess…
ameetkotian Oct 1, 2020
9c14b62
Merge pull request #6766 from GuptaManan100/warning-for-context
systay Sep 22, 2020
b8901b9
Merge pull request #6721 from tinyspeck/fixes-long-wait-filter-keyspa…
deepthi Sep 18, 2020
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
8 changes: 4 additions & 4 deletions go/test/endtoend/reparent/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func TestMain(m *testing.M) {
clusterInstance.VtTabletExtraArgs = []string{
"-lock_tables_timeout", "5s",
"-enable_semi_sync",
"-track_schema_versions=false", // remove this line once https://github.com/vitessio/vitess/issues/6474 is fixed
}

// Initialize Cluster
Expand All @@ -124,12 +125,11 @@ func TestMain(m *testing.M) {
for _, shard := range clusterInstance.Keyspaces[0].Shards {
for _, tablet := range shard.Vttablets {
log.Infof("Starting MySql for tablet %v", tablet.Alias)
if proc, err := tablet.MysqlctlProcess.StartProcess(); err != nil {
proc, err := tablet.MysqlctlProcess.StartProcess()
if err != nil {
return 1
} else {
// ignore golint warning, we need the else block to use proc
mysqlCtlProcessList = append(mysqlCtlProcessList, proc)
}
mysqlCtlProcessList = append(mysqlCtlProcessList, proc)
}
}

Expand Down
91 changes: 49 additions & 42 deletions go/test/endtoend/reparent/reparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,36 @@ import (
func TestMasterToSpareStateChangeImpossible(t *testing.T) {
defer cluster.PanicHandler(t)

args := []string{"InitTablet", "-hostname", hostname,
"-port", fmt.Sprintf("%d", tablet62344.HTTPPort), "-allow_update", "-parent",
"-keyspace", keyspaceName,
"-shard", shardName,
"-mysql_port", fmt.Sprintf("%d", tablet62344.MySQLPort),
"-grpc_port", fmt.Sprintf("%d", tablet62344.GrpcPort)}
args = append(args, fmt.Sprintf("%s-%010d", tablet62344.Cell, tablet62344.TabletUID), "master")
err := clusterInstance.VtctlclientProcess.ExecuteCommand(args...)
require.NoError(t, err)
// need at least one replica because of semi-sync
for _, tablet := range []cluster.Vttablet{*tablet62344, *tablet62044} {

// Start the tablet
err = tablet62344.VttabletProcess.Setup()
require.NoError(t, err)
// Start the tablet
err := tablet.VttabletProcess.Setup()
require.NoError(t, err)

// Create Database
err = tablet62344.VttabletProcess.CreateDB(keyspaceName)
require.NoError(t, err)
// Create Database
err = tablet.VttabletProcess.CreateDB(keyspaceName)
require.NoError(t, err)
}
for _, tablet := range []cluster.Vttablet{*tablet62344, *tablet62044} {
err := tablet.VttabletProcess.WaitForTabletTypes([]string{"SERVING", "NOT_SERVING"})
require.NoError(t, err)
}

// Init Shard Master
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
require.NoError(t, err, out)
// We cannot change a master to spare
err = clusterInstance.VtctlclientProcess.ExecuteCommand("ChangeReplicaType", tablet62344.Alias, "spare")
require.Error(t, err)
out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("ChangeTabletType", tablet62344.Alias, "spare")
require.Error(t, err, out)
require.Contains(t, out, "type change MASTER -> SPARE is not an allowed transition for ChangeTabletType")

//kill Tablet
//kill Tablets
err = tablet62344.VttabletProcess.TearDown()
require.NoError(t, err)
err = tablet62044.VttabletProcess.TearDown()
require.NoError(t, err)
}

func TestReparentDownMaster(t *testing.T) {
Expand All @@ -90,9 +95,9 @@ func TestReparentDownMaster(t *testing.T) {
}

// Init Shard Master
err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

validateTopology(t, true)

Expand Down Expand Up @@ -171,20 +176,20 @@ func TestReparentCrossCell(t *testing.T) {
}

// Force the replica to reparent assuming that all the datasets are identical.
err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

validateTopology(t, true)

checkMasterTablet(t, tablet62344)

// Perform a graceful reparent operation to another cell.
err = clusterInstance.VtctlclientProcess.ExecuteCommand(
out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
"PlannedReparentShard",
"-keyspace_shard", keyspaceShard,
"-new_master", tablet31981.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

validateTopology(t, false)

Expand Down Expand Up @@ -215,9 +220,9 @@ func TestReparentGraceful(t *testing.T) {
}

// Force the replica to reparent assuming that all the datasets are identical.
err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

validateTopology(t, true)

Expand Down Expand Up @@ -292,9 +297,9 @@ func TestReparentReplicaOffline(t *testing.T) {
}

// Force the replica to reparent assuming that all the datasets are identical.
err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", keyspaceShard, tablet62344.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

validateTopology(t, true)

Expand All @@ -305,7 +310,7 @@ func TestReparentReplicaOffline(t *testing.T) {
require.NoError(t, err)

// Perform a graceful reparent operation.
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
"PlannedReparentShard",
"-keyspace_shard", keyspaceShard,
"-new_master", tablet62044.Alias,
Expand All @@ -321,9 +326,11 @@ func TestReparentReplicaOffline(t *testing.T) {

func TestReparentAvoid(t *testing.T) {
defer cluster.PanicHandler(t)

// Remove tablet41983 from topology as that tablet is not required for this test
err := clusterInstance.VtctlclientProcess.ExecuteCommand("DeleteTablet", tablet41983.Alias)
require.NoError(t, err)
// Ignore error. Depending on previous tests this topo entry may or may not exist
// TODO: fix inter-test dependencies
_ = clusterInstance.VtctlclientProcess.ExecuteCommand("DeleteTablet", tablet41983.Alias)

for _, tablet := range []cluster.Vttablet{*tablet62344, *tablet62044, *tablet31981} {
// create database
Expand All @@ -341,9 +348,9 @@ func TestReparentAvoid(t *testing.T) {
}

// Force the replica to reparent assuming that all the dataset's are identical.
err = clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", keyspaceShard, tablet62344.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

validateTopology(t, true)

Expand Down Expand Up @@ -438,9 +445,9 @@ func reparentFromOutside(t *testing.T, downMaster bool) {
}

// Reparent as a starting point
err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

validateTopology(t, true)

Expand Down Expand Up @@ -526,9 +533,9 @@ func TestReparentWithDownReplica(t *testing.T) {
}

// Init Shard Master
err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

validateTopology(t, true)

Expand Down Expand Up @@ -600,9 +607,9 @@ func TestChangeTypeSemiSync(t *testing.T) {
}

// Init Shard Master
err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), master.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

// Updated rdonly tablet and set tablet type to rdonly
// TODO: replace with ChangeTabletType once ChangeSlaveType is removed
Expand Down Expand Up @@ -679,9 +686,9 @@ func TestReparentDoesntHangIfMasterFails(t *testing.T) {
}

// Init Shard Master
err := clusterInstance.VtctlclientProcess.ExecuteCommand("InitShardMaster",
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput("InitShardMaster",
"-force", fmt.Sprintf("%s/%s", keyspaceName, shardName), tablet62344.Alias)
require.NoError(t, err)
require.NoError(t, err, out)

validateTopology(t, true)

Expand All @@ -693,7 +700,7 @@ func TestReparentDoesntHangIfMasterFails(t *testing.T) {

// Perform a planned reparent operation, the master will fail the
// insert. The replicas should then abort right away.
out, err := clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
out, err = clusterInstance.VtctlclientProcess.ExecuteCommandWithOutput(
"PlannedReparentShard",
"-keyspace_shard", keyspaceShard,
"-new_master", tablet62044.Alias)
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vreplication/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var (
initialProductSchema = `
create table product(pid int, description varbinary(128), primary key(pid));
create table customer(cid int, name varbinary(128), primary key(cid));
create table merchant(mname varchar(128), category varchar(128), primary key(mname));
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';
Expand Down
30 changes: 30 additions & 0 deletions go/test/endtoend/vtgate/setstatement/sysvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,36 @@ func TestSetSystemVariableAndThenSuccessfulTx(t *testing.T) {
assertMatches(t, conn, "select @@sql_safe_updates", "[[INT64(1)]]")
}

func TestSetSystemVariableAndThenSuccessfulAutocommitDML(t *testing.T) {
vtParams := mysql.ConnParams{
Host: "localhost",
Port: clusterInstance.VtgateMySQLPort,
}

conn, err := mysql.Connect(context.Background(), &vtParams)
require.NoError(t, err)
defer conn.Close()
checkedExec(t, conn, `delete from test`)

checkedExec(t, conn, `set sql_safe_updates = 1`)

checkedExec(t, conn, `insert into test (id, val1) values (80, null)`)
assertMatches(t, conn, `select id, val1 from test`, `[[INT64(80) NULL]]`)
assertMatches(t, conn, `select @@sql_safe_updates`, `[[INT64(1)]]`)

checkedExec(t, conn, `update test set val2 = 2 where val1 is null`)
assertMatches(t, conn, `select id, val1, val2 from test`, `[[INT64(80) NULL INT32(2)]]`)
assertMatches(t, conn, `select @@sql_safe_updates`, `[[INT64(1)]]`)

checkedExec(t, conn, `update test set val1 = 'text' where val1 is null`)
assertMatches(t, conn, `select id, val1, val2 from test`, `[[INT64(80) VARCHAR("text") INT32(2)]]`)
assertMatches(t, conn, `select @@sql_safe_updates`, `[[INT64(1)]]`)

checkedExec(t, conn, `delete from test where val1 = 'text'`)
assertMatches(t, conn, `select id, val1, val2 from test`, `[]`)
assertMatches(t, conn, `select @@sql_safe_updates`, `[[INT64(1)]]`)
}

func TestStartTxAndSetSystemVariableAndThenSuccessfulCommit(t *testing.T) {
vtParams := mysql.ConnParams{
Host: "localhost",
Expand Down
27 changes: 27 additions & 0 deletions go/vt/discovery/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,30 @@ func (hc *HealthCheckImpl) WaitForAllServingTablets(ctx context.Context, targets
return hc.waitForTablets(ctx, targets, true)
}

// FilterTargetsByKeyspaces only returns the targets that are part of the provided keyspaces
func FilterTargetsByKeyspaces(keyspaces []string, targets []*query.Target) []*query.Target {
filteredTargets := make([]*query.Target, 0)

// Keep them all if there are no keyspaces to watch
if len(KeyspacesToWatch) == 0 {
return append(filteredTargets, targets...)
}

// Let's remove from the target shards that are not in the keyspaceToWatch list.
for _, target := range targets {
for _, keyspaceToWatch := range keyspaces {
if target.Keyspace == keyspaceToWatch {
filteredTargets = append(filteredTargets, target)
}
}
}
return filteredTargets
}

// waitForTablets is the internal method that polls for tablets.
func (hc *HealthCheckImpl) waitForTablets(ctx context.Context, targets []*query.Target, requireServing bool) error {
targets = FilterTargetsByKeyspaces(KeyspacesToWatch, targets)

for {
// We nil targets as we find them.
allPresent := true
Expand Down Expand Up @@ -645,6 +667,11 @@ func (hc *HealthCheckImpl) waitForTablets(ctx context.Context, targets []*query.
select {
case <-ctx.Done():
timer.Stop()
for _, target := range targets {
if target != nil {
log.Infof("couldn't find tablets for target: %v", target)
}
}
return ctx.Err()
case <-timer.C:
}
Expand Down
Loading