Repository: vitessio/vitess
Pull request #6648 (2020-08-29 01:25:38)

tm init: publish displayState
This fixes a bug where checkMastership changes the internal state, but initTablet doesn't know about it.

Signed-off-by: deepthi <deepthi@planetscale.com>


Patch:
diff --git a/go/vt/discovery/replicationlag.go b/go/vt/discovery/replicationlag.go
index 4840bd6205..b527bfb8ab 100644
--- a/go/vt/discovery/replicationlag.go
+++ b/go/vt/discovery/replicationlag.go
@@ -26,8 +26,8 @@ import (
 var (
 	// lowReplicationLag defines the duration that replication lag is low enough that the VTTablet is considered healthy.
 	lowReplicationLag             = flag.Duration("discovery_low_replication_lag", 30*time.Second, "the replication lag that is considered low enough to be healthy")
-	highReplicationLagMinServing  = flag.Duration("discovery_high_replication_lag_minimum_serving", 2*time.Hour, "the replication lag that is considered too high when applying the min_number_serving_vttablets threshold")
-	minNumTablets                 = flag.Int("min_number_serving_vttablets", 2, "the minimum number of vttablets for each replicating tablet_type (e.g. replica, rdonly) that will be continue to be used even with replication lag above discovery_low_replication_lag, but still below discovery_high_replication_lag_minimum_serving")
+	highReplicationLagMinServing  = flag.Duration("discovery_high_replication_lag_minimum_serving", 2*time.Hour, "the replication lag that is considered too high when selecting the minimum num vttablets for serving")
+	minNumTablets                 = flag.Int("min_number_serving_vttablets", 2, "the minimum number of vttablets that will be continue to be used even with low replication lag")
 	legacyReplicationLagAlgorithm = flag.Bool("legacy_replication_lag_algorithm", true, "use the legacy algorithm when selecting the vttablets for serving")
 )
 
diff --git a/go/vt/vtgate/engine/primitive.go b/go/vt/vtgate/engine/primitive.go
index 4e2e40e7ed..7c3bac5c93 100644
--- a/go/vt/vtgate/engine/primitive.go
+++ b/go/vt/vtgate/engine/primitive.go
@@ -86,8 +86,6 @@ type (
 		Session() SessionActions
 
 		ExecuteLock(rs *srvtopo.ResolvedShard, query *querypb.BoundQuery) (*sqltypes.Result, error)
-
-		InTransactionAndIsDML() bool
 	}
 
 	//SessionActions gives primitives ability to interact with the session state
diff --git a/go/vt/vtgate/engine/route.go b/go/vt/vtgate/engine/route.go
index 962665a6a2..5c4c49227c 100644
--- a/go/vt/vtgate/engine/route.go
+++ b/go/vt/vtgate/engine/route.go
@@ -90,10 +90,6 @@ type Route struct {
 	// ScatterErrorsAsWarnings is true if results should be returned even if some shards have an error
 	ScatterErrorsAsWarnings bool
 
-	// SysTableKeyspaceExpr contains the schema expressions
-	// It will be used to route the system table queries to a keyspace.
-	SysTableKeyspaceExpr []evalengine.Expr
-
 	// Route does not take inputs
 	noInputs
 
@@ -232,9 +228,7 @@ func (route *Route) execute(vcursor VCursor, bindVars map[string]*querypb.BindVa
 	var bvs []map[string]*querypb.BindVariable
 	var err error
 	switch route.Opcode {
-	case SelectDBA:
-		rss, bvs, err = route.paramsSystemQuery(vcursor, bindVars)
-	case SelectUnsharded, SelectNext, SelectReference:
+	case SelectUnsharded, SelectNext, SelectDBA, SelectReference:
 		rss, bvs, err = route.paramsAnyShard(vcursor, bindVars)
 	case SelectScatter:
 		rss, bvs, err = route.paramsAllShards(vcursor, bindVars)
@@ -295,9 +289,7 @@ func (route *Route) StreamExecute(vcursor VCursor, bindVars map[string]*querypb.
 		defer cancel()
 	}
 	switch route.Opcode {
-	case SelectDBA:
-		rss, bvs, err = route.paramsSystemQuery(vcursor, bindVars)
-	case SelectUnsharded, SelectNext, SelectReference:
+	case SelectUnsharded, SelectNext, SelectDBA, SelectReference:
 		rss, bvs, err = route.paramsAnyShard(vcursor, bindVars)
 	case SelectScatter:
 		rss, bvs, err = route.paramsAllShards(vcursor, bindVars)
@@ -377,36 +369,6 @@ func (route *Route) paramsAllShards(vcursor VCursor, bindVars map[string]*queryp
 	return rss, multiBindVars, nil
 }
 
-func (route *Route) paramsSystemQuery(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) {
-	env := evalengine.ExpressionEnv{
-		BindVars: bindVars,
-		Row:      []sqltypes.Value{},
-	}
-
-	var keyspace string
-	for _, expr := range route.SysTableKeyspaceExpr {
-		result, err := expr.Evaluate(env)
-		if err != nil {
-			return nil, nil, err
-		}
-		if keyspace == "" {
-			keyspace = result.Value().ToString()
-		} else if other := result.Value().ToString(); keyspace != other {
-			return nil, nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "can't use more than one keyspace per system table query - found both '%s' and '%s'", keyspace, other)
-		}
-	}
-
-	if keyspace == "" {
-		keyspace = route.Keyspace.Name
-	}
-
-	destinations, _, err := vcursor.ResolveDestinations(keyspace, nil, []key.Destination{key.DestinationAnyShard{}})
-	if err != nil {
-		return nil, nil, vterrors.Wrapf(err, "failed to find information about keyspace `%s`", keyspace)
-	}
-	return destinations, []map[string]*querypb.BindVariable{bindVars}, nil
-}
-
 func (route *Route) paramsAnyShard(vcursor VCursor, bindVars map[string]*querypb.BindVariable) ([]*srvtopo.ResolvedShard, []map[string]*querypb.BindVariable, error) {
 	rss, _, err := vcursor.ResolveDestinations(route.Keyspace.Name, nil, []key.Destination{key.DestinationAnyShard{}})
 	if err != nil {
@@ -615,13 +577,6 @@ func (route *Route) description() PrimitiveDescription {
 	if len(route.Values) > 0 {
 		other["Values"] = route.Values
 	}
-	if len(route.SysTableKeyspaceExpr) > 0 {
-		var exprs []string
-		for _, expr := range route.SysTableKeyspaceExpr {
-			exprs = append(exprs, expr.String())
-		}
-		other["SysTableKeyspaceExpr"] = exprs
-	}
 
 	return PrimitiveDescription{
 		OperatorType:      "Route",
diff --git a/go/vt/vtgate/planbuilder/from.go b/go/vt/vtgate/planbuilder/from.go
index 467e83ac75..642e22de8e 100644
--- a/go/vt/vtgate/planbuilder/from.go
+++ b/go/vt/vtgate/planbuilder/from.go
@@ -173,7 +173,7 @@ func (pb *primitiveBuilder) buildTablePrimitive(tableExpr *sqlparser.AliasedTabl
 	sel := &sqlparser.Select{From: sqlparser.TableExprs([]sqlparser.TableExpr{tableExpr})}
 
 	if systemTable(tableName.Qualifier.String()) {
-		ks, err := pb.vschema.AnyKeyspace()
+		ks, err := pb.vschema.DefaultKeyspace()
 		if err != nil {
 			return err
 		}
@@ -182,7 +182,7 @@ func (pb *primitiveBuilder) buildTablePrimitive(tableExpr *sqlparser.AliasedTabl
 		pb.bldr, pb.st = rb, st
 		// Add the table to symtab
 		return st.AddTable(&table{
-			alias:  alias,
+			alias:  tableName,
 			origin: rb,
 		})
 	}
diff --git a/go/vt/vtgate/planbuilder/select.go b/go/vt/vtgate/planbuilder/select.go
index d7764a2764..d33596d025 100644
--- a/go/vt/vtgate/planbuilder/select.go
+++ b/go/vt/vtgate/planbuilder/select.go
@@ -22,7 +22,7 @@ import (
 
 	"vitess.io/vitess/go/vt/key"
 
-	vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
+	"vitess.io/vitess/go/vt/proto/vtrpc"
 	"vitess.io/vitess/go/vt/vterrors"
 
 	"vitess.io/vitess/go/vt/vtgate/evalengine"
@@ -92,11 +92,11 @@ func (pb *primitiveBuilder) processSelect(sel *sqlparser.Select, outer *symtab)
 	// Check and error if there is any locking function present in select expression.
 	for _, expr := range sel.SelectExprs {
 		if aExpr, ok := expr.(*sqlparser.AliasedExpr); ok && sqlparser.IsLockingFunc(aExpr.Expr) {
-			return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "%v allowed only with dual", sqlparser.String(aExpr))
+			return vterrors.Errorf(vtrpc.Code_FAILED_PRECONDITION, "%v allowed only with dual", sqlparser.String(aExpr))
 		}
 	}
 	if sel.SQLCalcFoundRows && sel.Limit != nil {
-		return vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "sql_calc_found_rows not yet fully supported")
+		return vterrors.Errorf(vtrpc.Code_UNIMPLEMENTED, "sql_calc_found_rows not yet fully supported")
 	}
 
 	if err := pb.processTableExprs(sel.From); err != nil {
@@ -215,18 +215,6 @@ func (pb *primitiveBuilder) pushFilter(in sqlparser.Expr, whereType string) erro
 		if err != nil {
 			return err
 		}
-		rut, isRoute := origin.(*route)
-		if isRoute && rut.eroute.Opcode == engine.SelectDBA {
-			r := &rewriter{}
-			sqlparser.Rewrite(expr, r.rewriteTableSchema, nil)
-			if r.err == sqlparser.ErrExprNotSupported {
-				return vterrors.Errorf(vtrpcpb.Code_UNIMPLEMENTED, "comparison with `table_schema` column not supported")
-			}
-			if r.err != nil {
-				return r.err
-			}
-			rut.eroute.SysTableKeyspaceExpr = append(rut.eroute.SysTableKeyspaceExpr, r.tableNameExpressions...)
-		}
 		// The returned expression may be complex. Resplit before pushing.
 		for _, subexpr := range splitAndExpression(nil, expr) {
 			if err := pb.bldr.PushFilter(pb, subexpr, whereType, origin); err != nil {
@@ -238,42 +226,6 @@ func (pb *primitiveBuilder) pushFilter(in sqlparser.Expr, whereType string) erro
 	return nil
 }
 
-type rewriter struct {
-	tableNameExpressions []evalengine.Expr
-	err                  error
-}
-
-func (r *rewriter) rewriteTableSchema(cursor *sqlparser.Cursor) bool {
-	switch node := cursor.Node().(type) {
-	case *sqlparser.ColName:
-		if node.Name.EqualString("table_schema") {
-			switch parent := cursor.Parent().(type) {
-			case *sqlparser.ComparisonExpr:
-				if parent.Operator == sqlparser.EqualStr && shouldRewrite(parent.Right) {
-
-					evalExpr, err := sqlparser.Convert(parent.Right)
-					if err != nil {
-						r.err = err
-						return false
-					}
-					r.tableNameExpressions = append(r.tableNameExpressions, evalExpr)
-					parent.Right = sqlparser.NewValArg([]byte(":__vtschemaname"))
-				}
-			}
-		}
-	}
-	return true
-}
-
-func shouldRewrite(e sqlparser.Expr) bool {
-	switch node := e.(type) {
-	case *sqlparser.FuncExpr:
-		// we should not rewrite database() calls against information_schema
-		return !(node.Name.EqualString("database") || node.Name.EqualString("schema"))
-	}
-	return true
-}
-
 // reorderBySubquery reorders the filters by pushing subqueries
 // to the end. This allows the non-subquery filters to be
 // pushed first because they can potentially improve the routing
diff --git a/go/vt/vtgate/vcursor_impl.go b/go/vt/vtgate/vcursor_impl.go
index 09ea335ba7..76eb2ec927 100644
--- a/go/vt/vtgate/vcursor_impl.go
+++ b/go/vt/vtgate/vcursor_impl.go
@@ -54,7 +54,6 @@ import (
 var _ engine.VCursor = (*vcursorImpl)(nil)
 var _ planbuilder.ContextVSchema = (*vcursorImpl)(nil)
 var _ iExecute = (*Executor)(nil)
-var _ vindexes.VCursor = (*vcursorImpl)(nil)
 
 // vcursor_impl needs these facilities to be able to be able to execute queries for vindexes
 type iExecute interface {
@@ -321,17 +320,6 @@ func (vc *vcursorImpl) ExecuteMultiShard(rss []*srvtopo.ResolvedShard, queries [
 	return qr, errs
 }
 
-func (vc *vcursorImpl) InTransactionAndIsDML() bool {
-	if !vc.safeSession.InTransaction() {
-		return false
-	}
-	switch vc.logStats.StmtType {
-	case "INSERT", "REPLACE", "UPDATE", "DELETE":
-		return true
-	}
-	return false
-}
-
 func (vc *vcursorImpl) ExecuteLock(rs *srvtopo.ResolvedShard, query *querypb.BoundQuery) (*sqltypes.Result, error) {
 	query.Sql = vc.marginComments.Leading + query.Sql + vc.marginComments.Trailing
 	return vc.executor.ExecuteLock(vc.ctx, rs, query, vc.safeSession)
diff --git a/go/vt/vtgate/vindexes/lookup_internal.go b/go/vt/vtgate/vindexes/lookup_internal.go
index 346c7219f8..a139fb187e 100644
--- a/go/vt/vtgate/vindexes/lookup_internal.go
+++ b/go/vt/vtgate/vindexes/lookup_internal.go
@@ -76,10 +76,6 @@ func (lkp *lookupInternal) Lookup(vcursor VCursor, ids []sqltypes.Value, co vtga
 	if lkp.Autocommit {
 		co = vtgatepb.CommitOrder_AUTOCOMMIT
 	}
-	sel := lkp.sel
-	if vcursor.InTransactionAndIsDML() {
-		sel = sel + " for update"
-	}
 	if !ids[0].IsIntegral() && !ids[0].IsBinary() {
 		// for non integral and binary type, fallback to send query per id
 		for _, id := range ids {
@@ -91,7 +87,7 @@ func (lkp *lookupInternal) Lookup(vcursor VCursor, ids []sqltypes.Value, co vtga
 				lkp.FromColumns[0]: vars,
 			}
 			var result *sqltypes.Result
-			result, err = vcursor.Execute("VindexLookup", sel, bindVars, false /* rollbackOnError */, co)
+			result, err = vcursor.Execute("VindexLookup", lkp.sel, bindVars, false /* rollbackOnError */, co)
 			if err != nil {
 				return nil, fmt.Errorf("lookup.Map: %v", err)
 			}
@@ -112,7 +108,7 @@ func (lkp *lookupInternal) Lookup(vcursor VCursor, ids []sqltypes.Value, co vtga
 		bindVars := map[string]*querypb.BindVariable{
 			lkp.FromColumns[0]: vars,
 		}
-		result, err := vcursor.Execute("VindexLookup", sel, bindVars, false /* rollbackOnError */, co)
+		result, err := vcursor.Execute("VindexLookup", lkp.sel, bindVars, false /* rollbackOnError */, co)
 		if err != nil {
 			return nil, fmt.Errorf("lookup.Map: %v", err)
 		}
diff --git a/go/vt/vtgate/vindexes/vindex.go b/go/vt/vtgate/vindexes/vindex.go
index b6beec7398..0fea9233bb 100644
--- a/go/vt/vtgate/vindexes/vindex.go
+++ b/go/vt/vtgate/vindexes/vindex.go
@@ -37,7 +37,6 @@ import (
 type VCursor interface {
 	Execute(method string, query string, bindvars map[string]*querypb.BindVariable, rollbackOnError bool, co vtgatepb.CommitOrder) (*sqltypes.Result, error)
 	ExecuteKeyspaceID(keyspace string, ksid []byte, query string, bindVars map[string]*querypb.BindVariable, rollbackOnError, autocommit bool) (*sqltypes.Result, error)
-	InTransactionAndIsDML() bool
 }
 
 // Vindex defines the interface required to register a vindex.
diff --git a/go/vt/vttablet/tabletmanager/tm_init.go b/go/vt/vttablet/tabletmanager/tm_init.go
index 6b247604ba..8c88333bc4 100644
--- a/go/vt/vttablet/tabletmanager/tm_init.go
+++ b/go/vt/vttablet/tabletmanager/tm_init.go
@@ -305,7 +305,7 @@ func (tm *TabletManager) Start(tablet *topodatapb.Tablet, healthCheckInterval ti
 		return nil
 	}
 
-	tm.tmState.Open(tm.BatchCtx)
+	tm.tmState.Open()
 	return nil
 }
 
@@ -473,7 +473,7 @@ func (tm *TabletManager) checkMastership(ctx context.Context, si *topo.ShardInfo
 					tablet.MasterTermStartTime = oldTablet.MasterTermStartTime
 				})
 			} else {
-				log.Warningf("Shard master alias matches, but existing tablet is not master. Switching to master with the shard's master term start time: %v", oldTablet.MasterTermStartTime)
+				log.Warningf("Shard master alias matches, but existing tablet is not master. Switching from %v to master with the shard's master term start time: %v", oldTablet.Type, si.MasterTermStartTime)
 				tm.tmState.UpdateTablet(func(tablet *topodatapb.Tablet) {
 					tablet.Type = topodatapb.TabletType_MASTER
 					tablet.MasterTermStartTime = si.MasterTermStartTime
@@ -599,7 +599,7 @@ func (tm *TabletManager) handleRestore(ctx context.Context) (bool, error) {
 	if *restoreFromBackup {
 		go func() {
 			// Open the state manager after restore is done.
-			defer tm.tmState.Open(ctx)
+			defer tm.tmState.Open()
 
 			// restoreFromBackup will just be a regular action
 			// (same as if it was triggered remotely)
diff --git a/go/vt/vttablet/tabletmanager/tm_state.go b/go/vt/vttablet/tabletmanager/tm_state.go
index 86ca17fced..fad4a8b904 100644
--- a/go/vt/vttablet/tabletmanager/tm_state.go
+++ b/go/vt/vttablet/tabletmanager/tm_state.go
@@ -68,26 +68,28 @@ type tmState struct {
 }
 
 func newTMState(tm *TabletManager, tablet *topodatapb.Tablet) *tmState {
+	ctx, cancel := context.WithCancel(tm.BatchCtx)
 	return &tmState{
 		tm: tm,
 		displayState: displayState{
 			tablet: proto.Clone(tablet).(*topodatapb.Tablet),
 		},
 		tablet: tablet,
+		ctx:    ctx,
+		cancel: cancel,
 	}
 }
 
-func (ts *tmState) Open(ctx context.Context) {
+func (ts *tmState) Open() {
 	ts.mu.Lock()
 	defer ts.mu.Unlock()
 	if ts.isOpen {
 		return
 	}
 
-	ts.ctx, ts.cancel = context.WithCancel(ctx)
 	ts.isOpen = true
 	ts.updateLocked(ts.ctx)
-	ts.publishStateLocked(ctx)
+	ts.publishStateLocked(ts.ctx)
 }
 
 func (ts *tmState) Close() {
@@ -192,18 +194,19 @@ func (ts *tmState) UpdateTablet(update func(tablet *topodatapb.Tablet)) {
 	ts.mu.Lock()
 	defer ts.mu.Unlock()
 	update(ts.tablet)
+	ts.publishForDisplay()
 }
 
 func (ts *tmState) updateLocked(ctx context.Context) {
 	span, ctx := trace.NewSpan(ctx, "tmState.update")
 	defer span.Finish()
+	ts.publishForDisplay()
 
 	if !ts.isOpen {
 		return
 	}
 
 	terTime := logutil.ProtoToTime(ts.tablet.MasterTermStartTime)
-	ts.publishForDisplay()
 
 	// Disable TabletServer first so the nonserving state gets advertised
 	// before other services are shutdown.
diff --git a/go/vt/vttablet/tabletserver/query_executor.go b/go/vt/vttablet/tabletserver/query_executor.go
index a2c444b0cd..2cd757df3a 100644
--- a/go/vt/vttablet/tabletserver/query_executor.go
+++ b/go/vt/vttablet/tabletserver/query_executor.go
@@ -124,7 +124,6 @@ func (qre *QueryExecutor) Execute() (reply *sqltypes.Result, err error) {
 	case planbuilder.PlanSelect, planbuilder.PlanSelectImpossible, planbuilder.PlanShowTables:
 		maxrows := qre.getSelectLimit()
 		qre.bindVars["#maxLimit"] = sqltypes.Int64BindVariable(maxrows + 1)
-		qre.bindVars["__vtschemaname"] = sqltypes.StringBindVariable(qre.tsv.config.DB.DBName)
 		qr, err := qre.execSelect()
 		if err != nil {
 			return nil, err
@@ -207,7 +206,6 @@ func (qre *QueryExecutor) txConnExec(conn *StatefulConnection) (*sqltypes.Result
 	case planbuilder.PlanSelect, planbuilder.PlanSelectLock, planbuilder.PlanSelectImpossible, planbuilder.PlanShowTables:
 		maxrows := qre.getSelectLimit()
 		qre.bindVars["#maxLimit"] = sqltypes.Int64BindVariable(maxrows + 1)
-		qre.bindVars["__vtschemaname"] = sqltypes.StringBindVariable(qre.tsv.config.DB.DBName)
 		qr, err := qre.txFetch(conn, false)
 		if err != nil {
 			return nil, err
diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go
index 1a25f8c7d0..f68e8da3c0 100644
--- a/go/vt/vttablet/tabletserver/tabletenv/config.go
+++ b/go/vt/vttablet/tabletserver/tabletenv/config.go
@@ -149,8 +149,8 @@ func init() {
 	flag.BoolVar(&currentConfig.CacheResultFields, "enable-query-plan-field-caching", defaultConfig.CacheResultFields, "This option fetches & caches fields (columns) when storing query plans")
 
 	flag.DurationVar(&healthCheckInterval, "health_check_interval", 20*time.Second, "Interval between health checks")
-	flag.DurationVar(&degradedThreshold, "degraded_threshold", 30*time.Second, "replication lag after which a replica is considered degraded")
-	flag.DurationVar(&unhealthyThreshold, "unhealthy_threshold", 2*time.Hour, "replication lag after which a replica is considered unhealthy")
+	flag.DurationVar(&degradedThreshold, "degraded_threshold", 30*time.Second, "replication lag after which a replica is considered degraded (only used in status UI)")
+	flag.DurationVar(&unhealthyThreshold, "unhealthy_threshold", 2*time.Hour, "replication lag  after which a replica is considered unhealthy")
 	flag.DurationVar(&transitionGracePeriod, "serving_state_grace_period", 0, "how long to pause after broadcasting health to vtgate, before enforcing a new serving state")
 
 	flag.BoolVar(&enableReplicationReporter, "enable_replication_reporter", false, "Use polling to track replication lag.")


Test patch:
diff --git a/go/test/endtoend/vtgate/dbnameoverride/tablet_master_test.go b/go/test/endtoend/tabletmanager/dbnameoverride/tablet_master_test.go
similarity index 85%
rename from go/test/endtoend/vtgate/dbnameoverride/tablet_master_test.go
rename to go/test/endtoend/tabletmanager/dbnameoverride/tablet_master_test.go
index d4bae5200d..88fcbc7674 100644
--- a/go/test/endtoend/vtgate/dbnameoverride/tablet_master_test.go
+++ b/go/test/endtoend/tabletmanager/dbnameoverride/tablet_master_test.go
@@ -119,16 +119,3 @@ func TestDbNameOverride(t *testing.T) {
 	require.Equal(t, 1, len(qr.Rows), "did not get enough rows back")
 	require.Equal(t, dbName, qr.Rows[0][0].ToString())
 }
-
-func TestInformationSchemaQuery(t *testing.T) {
-	defer cluster.PanicHandler(t)
-	ctx := context.Background()
-	conn, err := mysql.Connect(ctx, &vtParams)
-	require.Nil(t, err)
-	defer conn.Close()
-	qr, err := conn.ExecuteFetch("SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'ks'", 1000, true)
-
-	require.Nil(t, err)
-	require.Equal(t, 1, len(qr.Rows), "did not get enough rows back")
-	require.Equal(t, "t1", qr.Rows[0][0].ToString())
-}
diff --git a/go/test/endtoend/vtgate/concurrentdml/main_test.go b/go/test/endtoend/vtgate/concurrentdml/main_test.go
deleted file mode 100644
index ef73b7adab..0000000000
--- a/go/test/endtoend/vtgate/concurrentdml/main_test.go
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
-Copyright 2019 The Vitess Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package concurrentdml
-
-import (
-	"context"
-	"flag"
-	"fmt"
-	"os"
-	"sync"
-	"testing"
-	"time"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-	"vitess.io/vitess/go/mysql"
-	"vitess.io/vitess/go/sqltypes"
-	"vitess.io/vitess/go/test/endtoend/cluster"
-)
-
-var (
-	clusterInstance *cluster.LocalProcessCluster
-	cell            = "zone1"
-	hostname        = "localhost"
-	unsKs           = "commerce"
-	unsSchema       = `
-CREATE TABLE t1_seq (
-    id INT, 
-    next_id BIGINT, 
-    cache BIGINT, 
-    PRIMARY KEY(id)
-) comment 'vitess_sequence';
-
-INSERT INTO t1_seq (id, next_id, cache) values(0, 1, 1000);
-`
-
-	unsVSchema = `
-{
-  "sharded": false,
-  "tables": {}
-}
-`
-	sKs     = "customer"
-	sSchema = `
-CREATE TABLE t1 (
-    c1 BIGINT NOT NULL,
-    c2 BIGINT NOT NULL,
-    c3 BIGINT,
-    PRIMARY KEY (c1),
-    UNIQUE KEY (c2),
-    UNIQUE KEY (c3)
-) ENGINE=Innodb;
-
-CREATE TABLE lookup_t1 (
-    c2 BIGINT NOT NULL,
-    keyspace_id BINARY(8),
-    primary key (c2)
-);
-
-CREATE TABLE lookup_t2 (
-    c3 BIGINT NOT NULL,
-    keyspace_id BINARY(8),
-    primary key (c3)
-);
-`
-
-	sVSchema = `
-{
-    "sharded": true,
-    "vindexes": {
-        "xxhash": {
-            "type": "xxhash"
-        },
-        "lookup_c2": {
-            "type": "consistent_lookup_unique",
-            "params": {
-                "table": "lookup_t1",
-                "from": "c2",
-                "to": "keyspace_id",
-                "ignore_nulls": "true"
-            },
-            "owner": "t1"
-        },
-        "lookup_c3": {
-            "type": "consistent_lookup_unique",
-            "params": {
-                "table": "lookup_t2",
-                "from": "c3",
-                "to": "keyspace_id",
-                "ignore_nulls": "true"
-            },
-            "owner": "t1"
-        }
-    },
-    "tables": {
-        "t1": {
-            "columnVindexes": [
-                {
-                    "column": "c1",
-                    "name": "xxhash"
-                },
-                {
-                    "column": "c2",
-                    "name": "lookup_c2"
-                },
-                {
-                    "column": "c3",
-                    "name": "lookup_c3"
-                }
-            ],
-            "columns": [
-                {
-                    "name": "c1",
-                    "type": "INT64"
-                },
-                {
-                    "name": "c2",
-                    "type": "INT64"
-                },
-                {
-                    "name": "c3",
-                    "type": "INT64"
-                }
-            ],
-            "autoIncrement": {
-                "column": "c1",
-                "sequence": "commerce.t1_seq"
-            },
-            "columnListAuthoritative": true
-        },
-        "lookup_t1": {
-            "columnVindexes": [
-                {
-                    "column": "c2",
-                    "name": "xxhash"
-                }
-            ]
-        },
-        "lookup_t2": {
-            "columnVindexes": [
-                {
-                    "column": "c3",
-                    "name": "xxhash"
-                }
-            ]
-        }
-    }
-}
-`
-)
-
-func TestMain(m *testing.M) {
-	defer cluster.PanicHandler(nil)
-	flag.Parse()
-
-	exitCode := func() int {
-		clusterInstance = cluster.NewCluster(cell, hostname)
-		defer clusterInstance.Teardown()
-		//defer time.Sleep(10 * time.Minute)
-
-		// Start topo server
-		if err := clusterInstance.StartTopo(); err != nil {
-			return 1
-		}
-
-		// Start keyspace
-		uKeyspace := &cluster.Keyspace{
-			Name:      unsKs,
-			SchemaSQL: unsSchema,
-			VSchema:   unsVSchema,
-		}
-		if err := clusterInstance.StartUnshardedKeyspace(*uKeyspace, 1, false); err != nil {
-			return 1
-		}
-
-		sKeyspace := &cluster.Keyspace{
-			Name:      sKs,
-			SchemaSQL: sSchema,
-			VSchema:   sVSchema,
-		}
-		if err := clusterInstance.StartKeyspace(*sKeyspace, []string{"-80", "80-"}, 1, false); err != nil {
-			return 1
-		}
-
-		// Start vtgate
-		if err := clusterInstance.StartVtgate(); err != nil {
-			return 1
-		}
-
-		return m.Run()
-	}()
-	os.Exit(exitCode)
-}
-
-func TestInsertIgnoreOnLookupUniqueVindex(t *testing.T) {
-	defer cluster.PanicHandler(t)
-	ctx := context.Background()
-	vtParams := mysql.ConnParams{
-		Host: "localhost",
-		Port: clusterInstance.VtgateMySQLPort,
-	}
-	conn, err := mysql.Connect(ctx, &vtParams)
-	require.Nil(t, err)
-	defer conn.Close()
-
-	exec(t, conn, `delete from t1 where c1 = 300`)
-	exec(t, conn, `insert into t1 values (300,100,300)`)
-	qr1 := exec(t, conn, `select c2.keyspace_id, c3.keyspace_id from lookup_t1 c2, lookup_t2 c3`)
-
-	qr := exec(t, conn, `insert ignore into t1 values (200,100,200)`)
-	assert.Zero(t, qr.RowsAffected)
-
-	qr = exec(t, conn, `select * from t1 order by c1`)
-	assert.Equal(t, fmt.Sprintf("%v", qr.Rows), `[[INT64(300) INT64(100) INT64(300)]]`)
-
-	qr2 := exec(t, conn, `select c2.keyspace_id, c3.keyspace_id from lookup_t1 c2, lookup_t2 c3`)
-	// To ensure lookup vindex is not updated.
-	assert.Equal(t, qr1.Rows, qr2.Rows, "")
-}
-
-func TestOpenTxBlocksInSerial(t *testing.T) {
-	defer cluster.PanicHandler(t)
-	ctx := context.Background()
-	vtParams := mysql.ConnParams{
-		Host: "localhost",
-		Port: clusterInstance.VtgateMySQLPort,
-	}
-	conn1, err := mysql.Connect(ctx, &vtParams)
-	require.Nil(t, err)
-	defer conn1.Close()
-
-	conn2, err := mysql.Connect(ctx, &vtParams)
-	require.Nil(t, err)
-	defer conn2.Close()
-
-	exec(t, conn1, `delete from t1 where c1 = 300`)
-	exec(t, conn1, `insert into t1 values (300,100,300)`)
-	exec(t, conn1, `begin`)
-	exec(t, conn1, `UPDATE t1 SET c3 = 400 WHERE c2 = 100`)
-
-	// This will wait for innodb_lock_wait_timeout timeout pf 20 seconds to kick in.
-	execAssertError(t, conn2, `insert into t1 values (400,100,400)`, `Lock wait timeout exceeded`)
-
-	qr := exec(t, conn1, `insert ignore into t1 values (200,100,200)`)
-	assert.Zero(t, qr.RowsAffected)
-	exec(t, conn1, `commit`)
-
-	qr = exec(t, conn1, `select * from t1 order by c1`)
-	assert.Equal(t, fmt.Sprintf("%v", qr.Rows), `[[INT64(300) INT64(100) INT64(400)]]`)
-}
-
-func TestOpenTxBlocksInConcurrent(t *testing.T) {
-	defer cluster.PanicHandler(t)
-	ctx := context.Background()
-	vtParams := mysql.ConnParams{
-		Host: "localhost",
-		Port: clusterInstance.VtgateMySQLPort,
-	}
-	conn1, err := mysql.Connect(ctx, &vtParams)
-	require.Nil(t, err)
-	defer conn1.Close()
-
-	conn2, err := mysql.Connect(ctx, &vtParams)
-	require.Nil(t, err)
-	defer conn2.Close()
-
-	exec(t, conn1, `delete from t1 where c1 = 300`)
-	exec(t, conn1, `insert into t1 values (300,100,300)`)
-	exec(t, conn1, `begin`)
-	exec(t, conn1, `UPDATE t1 SET c3 = 400 WHERE c2 = 100`)
-
-	var wg sync.WaitGroup
-	wg.Add(1)
-	go func() {
-		// This will wait for other transaction to complete to through the duplicate key error.
-		execAssertError(t, conn2, `insert into t1 values (400,100,400)`, `Duplicate entry '100' for key`)
-		wg.Done()
-	}()
-
-	time.Sleep(3 * time.Second)
-	qr := exec(t, conn1, `insert ignore into t1 values (200,100,200)`)
-	assert.Zero(t, qr.RowsAffected)
-	exec(t, conn1, `commit`)
-
-	qr = exec(t, conn1, `select * from t1 order by c1`)
-	assert.Equal(t, fmt.Sprintf("%v", qr.Rows), `[[INT64(300) INT64(100) INT64(400)]]`)
-	wg.Wait()
-}
-
-func exec(t *testing.T, conn *mysql.Conn, query string) *sqltypes.Result {
-	t.Helper()
-	qr, err := conn.ExecuteFetch(query, 1000, true)
-	require.NoError(t, err)
-	return qr
-}
-
-func execAssertError(t *testing.T, conn *mysql.Conn, query string, errorString string) {
-	t.Helper()
-	_, err := conn.ExecuteFetch(query, 1000, true)
-	require.Error(t, err)
-	assert.Contains(t, err.Error(), errorString)
-}
diff --git a/go/vt/vtexplain/testdata/multi-output/deletesharded-output.txt b/go/vt/vtexplain/testdata/multi-output/deletesharded-output.txt
index 73db1a50d6..2a24f2f873 100644
--- a/go/vt/vtexplain/testdata/multi-output/deletesharded-output.txt
+++ b/go/vt/vtexplain/testdata/multi-output/deletesharded-output.txt
@@ -27,7 +27,7 @@ delete from user where id=1
 delete from user where name='billy'
 
 1 ks_sharded/c0-: begin
-1 ks_sharded/c0-: select name, user_id from name_user_map where name in ('billy') limit 10001 for update
+1 ks_sharded/c0-: select name, user_id from name_user_map where name in ('billy') limit 10001
 2 ks_sharded/-40: begin
 2 ks_sharded/-40: select id, name from user where name = 'billy' limit 10001 for update
 3 ks_sharded/40-80: begin
diff --git a/go/vt/vtexplain/testdata/multi-output/updatesharded-output.txt b/go/vt/vtexplain/testdata/multi-output/updatesharded-output.txt
index 2bd0b63868..ac612b26fb 100644
--- a/go/vt/vtexplain/testdata/multi-output/updatesharded-output.txt
+++ b/go/vt/vtexplain/testdata/multi-output/updatesharded-output.txt
@@ -9,7 +9,7 @@ update user set nickname='alice' where id=1
 update user set nickname='alice' where name='alice'
 
 1 ks_sharded/40-80: begin
-1 ks_sharded/40-80: select name, user_id from name_user_map where name in ('alice') limit 10001 for update
+1 ks_sharded/40-80: select name, user_id from name_user_map where name in ('alice') limit 10001
 2 ks_sharded/-40: begin
 2 ks_sharded/-40: update user set nickname = 'alice' where name = 'alice' limit 10001
 3 ks_sharded/40-80: commit
@@ -40,7 +40,7 @@ update user set name='alicia' where id=1
 update user set name='alicia' where name='alice'
 
 1 ks_sharded/40-80: begin
-1 ks_sharded/40-80: select name, user_id from name_user_map where name in ('alice') limit 10001 for update
+1 ks_sharded/40-80: select name, user_id from name_user_map where name in ('alice') limit 10001
 2 ks_sharded/-40: begin
 2 ks_sharded/-40: select id, name from user where name = 'alice' limit 10001 for update
 3 ks_sharded/40-80: delete from name_user_map where name = 'name_val_2' and user_id = 1 limit 10001
@@ -71,7 +71,7 @@ update /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ name_info set has_nickname=1 where nick
 update user set pet='rover' where name='alice'
 
 1 ks_sharded/40-80: begin
-1 ks_sharded/40-80: select name, user_id from name_user_map where name in ('alice') limit 10001 for update
+1 ks_sharded/40-80: select name, user_id from name_user_map where name in ('alice') limit 10001
 2 ks_sharded/-40: begin
 2 ks_sharded/-40: update user set pet = 'rover' where name = 'alice' limit 10001
 3 ks_sharded/40-80: commit
diff --git a/go/vt/vtexplain/vtexplain_flaky_test.go b/go/vt/vtexplain/vtexplain_flaky_test.go
index 8162ff43f3..fdec04732d 100644
--- a/go/vt/vtexplain/vtexplain_flaky_test.go
+++ b/go/vt/vtexplain/vtexplain_flaky_test.go
@@ -216,7 +216,6 @@ func TestJSONOutput(t *testing.T) {
             {
                 "BindVars": {
                     "#maxLimit": "10001",
-                    "__vtschemaname": "''",
                     "vtg1": "1"
                 },
                 "SQL": "select :vtg1 from user where id = :vtg1",
@@ -225,8 +224,5 @@ func TestJSONOutput(t *testing.T) {
         ]
     }
 }`
-	diff := cmp.Diff(wantJSON, string(actionsJSON))
-	if diff != "" {
-		t.Errorf(diff)
-	}
+	require.Equal(t, wantJSON, string(actionsJSON))
 }
diff --git a/go/vt/vtgate/autocommit_test.go b/go/vt/vtgate/autocommit_test.go
index f84fa89edb..f0bed579fa 100644
--- a/go/vt/vtgate/autocommit_test.go
+++ b/go/vt/vtgate/autocommit_test.go
@@ -66,7 +66,7 @@ func TestAutocommitUpdateLookup(t *testing.T) {
 	require.NoError(t, err)
 
 	testQueries(t, "sbclookup", sbclookup, []*querypb.BoundQuery{{
-		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id for update",
+		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id",
 		BindVariables: map[string]*querypb.BindVariable{
 			"music_id": vars,
 		},
@@ -155,7 +155,7 @@ func TestAutocommitDeleteLookup(t *testing.T) {
 	require.NoError(t, err)
 
 	testQueries(t, "sbclookup", sbclookup, []*querypb.BoundQuery{{
-		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id for update",
+		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id",
 		BindVariables: map[string]*querypb.BindVariable{
 			"music_id": vars,
 		},
diff --git a/go/vt/vtgate/engine/fake_vcursor_test.go b/go/vt/vtgate/engine/fake_vcursor_test.go
index 04448731c4..9f9464c4ac 100644
--- a/go/vt/vtgate/engine/fake_vcursor_test.go
+++ b/go/vt/vtgate/engine/fake_vcursor_test.go
@@ -21,17 +21,18 @@ import (
 	"fmt"
 	"reflect"
 	"sort"
+	"strings"
 	"testing"
 	"time"
 
-	"github.com/google/go-cmp/cmp"
-
 	"golang.org/x/sync/errgroup"
 
 	topodatapb "vitess.io/vitess/go/vt/proto/topodata"
 
 	"vitess.io/vitess/go/vt/sqlparser"
 
+	"github.com/stretchr/testify/require"
+
 	"golang.org/x/net/context"
 
 	"vitess.io/vitess/go/sqltypes"
@@ -53,10 +54,6 @@ type noopVCursor struct {
 	ctx context.Context
 }
 
-func (t noopVCursor) InTransactionAndIsDML() bool {
-	panic("implement me")
-}
-
 func (t noopVCursor) ExecuteLock(rs *srvtopo.ResolvedShard, query *querypb.BoundQuery) (*sqltypes.Result, error) {
 	panic("implement me")
 }
@@ -199,10 +196,6 @@ type loggingVCursor struct {
 	resolvedTargetTabletType topodatapb.TabletType
 }
 
-func (f *loggingVCursor) InTransactionAndIsDML() bool {
-	return false
-}
-
 func (f *loggingVCursor) SetUDV(key string, value interface{}) error {
 	f.log = append(f.log, fmt.Sprintf("UDV set with (%s,%v)", key, value))
 	return nil
@@ -365,14 +358,7 @@ func (f *loggingVCursor) ResolveDestinations(keyspace string, ids []*querypb.Val
 
 func (f *loggingVCursor) ExpectLog(t *testing.T, want []string) {
 	t.Helper()
-	if len(want) == 0 && len(f.log) == 0 {
-		// both are empty. no need to compare empty array with nil
-		return
-	}
-	diff := cmp.Diff(want, f.log)
-	if diff != "" {
-		t.Fatalf("log not what was expected: %s", diff)
-	}
+	require.Equal(t, strings.Join(want, "\n"), strings.Join(f.log, "\n"))
 }
 
 func (f *loggingVCursor) ExpectWarnings(t *testing.T, want []*querypb.QueryWarning) {
diff --git a/go/vt/vtgate/executor_dml_test.go b/go/vt/vtgate/executor_dml_test.go
index 3c21303660..942cede020 100644
--- a/go/vt/vtgate/executor_dml_test.go
+++ b/go/vt/vtgate/executor_dml_test.go
@@ -81,7 +81,7 @@ func TestUpdateEqual(t *testing.T) {
 	vars, err := sqltypes.BuildBindVariable([]interface{}{sqltypes.NewInt64(2)})
 	require.NoError(t, err)
 	wantQueries = []*querypb.BoundQuery{{
-		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id for update",
+		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id",
 		BindVariables: map[string]*querypb.BindVariable{
 			"music_id": vars,
 		},
@@ -389,7 +389,7 @@ func TestDeleteEqual(t *testing.T) {
 	vars, err := sqltypes.BuildBindVariable([]interface{}{sqltypes.NewInt64(1)})
 	require.NoError(t, err)
 	wantQueries = []*querypb.BoundQuery{{
-		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id for update",
+		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id",
 		BindVariables: map[string]*querypb.BindVariable{
 			"music_id": vars,
 		},
@@ -794,7 +794,7 @@ func TestInsertShardedIgnore(t *testing.T) {
 	})
 	require.NoError(t, err)
 	wantQueries = []*querypb.BoundQuery{{
-		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id for update",
+		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id",
 		BindVariables: map[string]*querypb.BindVariable{
 			"music_id": vars,
 		},
@@ -869,7 +869,7 @@ func TestInsertShardedIgnore(t *testing.T) {
 	vars, err = sqltypes.BuildBindVariable([]interface{}{sqltypes.NewInt64(1)})
 	require.NoError(t, err)
 	wantQueries = []*querypb.BoundQuery{{
-		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id for update",
+		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id",
 		BindVariables: map[string]*querypb.BindVariable{
 			"music_id": vars,
 		},
@@ -907,7 +907,7 @@ func TestInsertOnDupKey(t *testing.T) {
 	vars, err := sqltypes.BuildBindVariable([]interface{}{sqltypes.NewInt64(1)})
 	require.NoError(t, err)
 	wantQueries = []*querypb.BoundQuery{{
-		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id for update",
+		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id",
 		BindVariables: map[string]*querypb.BindVariable{
 			"music_id": vars,
 		},
@@ -1215,7 +1215,7 @@ func TestInsertLookupUnownedUnsupplied(t *testing.T) {
 	vars, err := sqltypes.BuildBindVariable([]interface{}{sqltypes.NewInt64(3)})
 	require.NoError(t, err)
 	wantQueries = []*querypb.BoundQuery{{
-		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id for update",
+		Sql: "select music_id, user_id from music_user_map where music_id in ::music_id",
 		BindVariables: map[string]*querypb.BindVariable{
 			"music_id": vars,
 		},
diff --git a/go/vt/vtgate/executor_select_test.go b/go/vt/vtgate/executor_select_test.go
index cbdb136275..0f3eb6046d 100644
--- a/go/vt/vtgate/executor_select_test.go
+++ b/go/vt/vtgate/executor_select_test.go
@@ -2281,26 +2281,3 @@ func TestSelectLock(t *testing.T) {
 	utils.MustMatch(t, wantQueries, sbc1.Queries, "")
 	utils.MustMatch(t, wantSession, session.Session, "")
 }
-
-func TestSelectFromInformationSchema(t *testing.T) {
-	executor, sbc1, _, _ := createExecutorEnv()
-	session := NewSafeSession(nil)
-
-	// check failure when trying to query two keyspaces
-	_, err := exec(executor, session, "SELECT B.TABLE_NAME FROM INFORMATION_SCHEMA.TABLES AS A, INFORMATION_SCHEMA.COLUMNS AS B WHERE A.TABLE_SCHEMA = 'TestExecutor' AND A.TABLE_SCHEMA = 'TestXBadSharding'")
-	require.Error(t, err)
-	require.Contains(t, err.Error(), "can't use more than one keyspace per system table query - found both 'TestExecutor' and 'TestXBadSharding")
-
-	// we pick a keyspace and query for table_schema = database(). should be routed to the picked keyspace
-	session.TargetString = "TestExecutor"
-	_, err = exec(executor, session, "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()")
-	require.NoError(t, err)
-	assert.Equal(t, sbc1.StringQueries(), []string{"select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = database()"})
-
-	// `USE TestXBadSharding` and then query info_schema about TestExecutor - should target TestExecutor and not use the default keyspace
-	sbc1.Queries = nil
-	session.TargetString = "TestXBadSharding"
-	_, err = exec(executor, session, "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'TestExecutor'")
-	require.NoError(t, err)
-	assert.Equal(t, sbc1.StringQueries(), []string{"select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname"})
-}
diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
index 79d9ddbbd1..c368362ad1 100644
--- a/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
+++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.txt
@@ -1387,42 +1387,3 @@
     "Table": "music"
   }
 }
-
-# query trying to query two different keyspaces at the same time
-"SELECT B.TABLE_NAME FROM INFORMATION_SCHEMA.TABLES AS A, INFORMATION_SCHEMA.COLUMNS AS B WHERE A.TABLE_SCHEMA = 'user' AND A.TABLE_SCHEMA = 'main' AND B.TABLE_NAME = A.TABLE_NAME"
-{
-  "QueryType": "SELECT",
-  "Original": "SELECT B.TABLE_NAME FROM INFORMATION_SCHEMA.TABLES AS A, INFORMATION_SCHEMA.COLUMNS AS B WHERE A.TABLE_SCHEMA = 'user' AND A.TABLE_SCHEMA = 'main' AND B.TABLE_NAME = A.TABLE_NAME",
-  "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectDBA",
-    "Keyspace": {
-      "Name": "main",
-      "Sharded": false
-    },
-    "FieldQuery": "select B.TABLE_NAME from INFORMATION_SCHEMA.`TABLES` as A, INFORMATION_SCHEMA.`COLUMNS` as B where 1 != 1",
-    "Query": "select B.TABLE_NAME from INFORMATION_SCHEMA.`TABLES` as A, INFORMATION_SCHEMA.`COLUMNS` as B where A.TABLE_SCHEMA = :__vtschemaname and A.TABLE_SCHEMA = :__vtschemaname and B.TABLE_NAME = A.TABLE_NAME",
-    "SysTableKeyspaceExpr": [
-      "VARBINARY(\"user\")",
-      "VARBINARY(\"main\")"
-    ]
-  }
-}
-
-# information_schema query using database() func
-"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()"
-{
-  "QueryType": "SELECT",
-  "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()",
-  "Instructions": {
-    "OperatorType": "Route",
-    "Variant": "SelectDBA",
-    "Keyspace": {
-      "Name": "main",
-      "Sharded": false
-    },
-    "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1",
-    "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = database()"
-  }
-}
-                
\ No newline at end of file
diff --git a/go/vt/vtgate/vindexes/consistent_lookup_test.go b/go/vt/vtgate/vindexes/consistent_lookup_test.go
index d8123543d4..02ed5ede36 100644
--- a/go/vt/vtgate/vindexes/consistent_lookup_test.go
+++ b/go/vt/vtgate/vindexes/consistent_lookup_test.go
@@ -497,8 +497,6 @@ func createConsistentLookup(t *testing.T, name string, writeOnly bool) SingleCol
 	return l.(SingleColumn)
 }
 
-var _ VCursor = (*loggingVCursor)(nil)
-
 type loggingVCursor struct {
 	results []*sqltypes.Result
 	errors  []error
@@ -506,10 +504,6 @@ type loggingVCursor struct {
 	log     []string
 }
 
-func (vc *loggingVCursor) InTransactionAndIsDML() bool {
-	return false
-}
-
 type bv struct {
 	Name string
 	Bv   string
diff --git a/go/vt/vtgate/vindexes/lookup_test.go b/go/vt/vtgate/vindexes/lookup_test.go
index ecdebe8154..ea517f89b2 100644
--- a/go/vt/vtgate/vindexes/lookup_test.go
+++ b/go/vt/vtgate/vindexes/lookup_test.go
@@ -21,8 +21,6 @@ import (
 	"reflect"
 	"testing"
 
-	"vitess.io/vitess/go/test/utils"
-
 	"strings"
 
 	"github.com/stretchr/testify/assert"
@@ -38,8 +36,6 @@ import (
 // LookupNonUnique tests are more comprehensive than others.
 // They also test lookupInternal functionality.
 
-var _ VCursor = (*vcursor)(nil)
-
 type vcursor struct {
 	mustFail    bool
 	numRows     int
@@ -50,10 +46,6 @@ type vcursor struct {
 	keys        []sqltypes.Value
 }
 
-func (vc *vcursor) InTransactionAndIsDML() bool {
-	return false
-}
-
 func (vc *vcursor) Execute(method string, query string, bindvars map[string]*querypb.BindVariable, rollbackOnError bool, co vtgatepb.CommitOrder) (*sqltypes.Result, error) {
 	switch co {
 	case vtgatepb.CommitOrder_PRE:
@@ -176,7 +168,9 @@ func TestLookupNonUniqueMap(t *testing.T) {
 			"fromc": vars,
 		},
 	}}
-	utils.MustMatch(t, wantqueries, vc.queries, "lookup.Map")
+	if !reflect.DeepEqual(vc.queries, wantqueries) {
+		t.Errorf("lookup.Map queries:\n%v, want\n%v", vc.queries, wantqueries)
+	}
 
 	// Test query fail.
 	vc.mustFail = true
diff --git a/go/vt/vttablet/tabletmanager/tm_init_test.go b/go/vt/vttablet/tabletmanager/tm_init_test.go
index 81ef2d5cf7..4ff49654c3 100644
--- a/go/vt/vttablet/tabletmanager/tm_init_test.go
+++ b/go/vt/vttablet/tabletmanager/tm_init_test.go
@@ -432,6 +432,71 @@ func TestStartDoesNotUpdateReplicationDataForTabletInWrongShard(t *testing.T) {
 	assert.Equal(t, 0, len(tablets))
 }
 
+func TestCheckTabletTypeResets(t *testing.T) {
+	defer func(saved time.Duration) { rebuildKeyspaceRetryInterval = saved }(rebuildKeyspaceRetryInterval)
+	rebuildKeyspaceRetryInterval = 10 * time.Millisecond
+
+	ctx := context.Background()
+	cell := "cell1"
+	ts := memorytopo.NewServer(cell)
+	alias := &topodatapb.TabletAlias{
+		Cell: "cell1",
+		Uid:  1,
+	}
+
+	// 1. Initialize the tablet as REPLICA.
+	// This will create the respective topology records.
+	tm := newTestTM(t, ts, 1, "ks", "0")
+	tablet := tm.Tablet()
+	ensureSrvKeyspace(t, ts, cell, "ks")
+	ti, err := ts.GetTablet(ctx, alias)
+	require.NoError(t, err)
+	assert.Equal(t, topodatapb.TabletType_REPLICA, ti.Type)
+	tm.Stop()
+
+	// 2. Update tablet record with tabletType RESTORE
+	_, err = ts.UpdateTabletFields(ctx, alias, func(t *topodatapb.Tablet) error {
+		t.Type = topodatapb.TabletType_RESTORE
+		return nil
+	})
+	require.NoError(t, err)
+	err = tm.Start(tablet, 0)
+	require.NoError(t, err)
+	assert.Equal(t, tm.tmState.tablet.Type, tm.tmState.displayState.tablet.Type)
+	ti, err = ts.GetTablet(ctx, alias)
+	require.NoError(t, err)
+	// Verify that it changes back to initTabletType
+	assert.Equal(t, topodatapb.TabletType_REPLICA, ti.Type)
+
+	// 3. Update shard's master to our alias, then try to init again.
+	// (This simulates the case where the MasterAlias in the shard record says
+	// that we are the master but the tablet record says otherwise. In that case,
+	// we become master by inheriting the shard record's timestamp.)
+	now := time.Now()
+	_, err = ts.UpdateShardFields(ctx, "ks", "0", func(si *topo.ShardInfo) error {
+		si.MasterAlias = alias
+		si.MasterTermStartTime = logutil.TimeToProto(now)
+		// Reassign to now for easier comparison.
+		now = si.GetMasterTermStartTime()
+		return nil
+	})
+	require.NoError(t, err)
+	si, err := tm.createKeyspaceShard(ctx)
+	require.NoError(t, err)
+	err = tm.checkMastership(ctx, si)
+	require.NoError(t, err)
+	assert.Equal(t, tm.tmState.tablet.Type, tm.tmState.displayState.tablet.Type)
+	err = tm.initTablet(ctx)
+	require.NoError(t, err)
+	assert.Equal(t, tm.tmState.tablet.Type, tm.tmState.displayState.tablet.Type)
+	ti, err = ts.GetTablet(ctx, alias)
+	require.NoError(t, err)
+	assert.Equal(t, topodatapb.TabletType_MASTER, ti.Type)
+	ter0 := ti.GetMasterTermStartTime()
+	assert.Equal(t, now, ter0)
+	tm.Stop()
+}
+
 func newTestTM(t *testing.T, ts *topo.Server, uid int, keyspace, shard string) *TabletManager {
 	t.Helper()
 	ctx := context.Background()
diff --git a/go/vt/vttablet/tabletmanager/tm_state_test.go b/go/vt/vttablet/tabletmanager/tm_state_test.go
index 031c42c2c4..680fa41e08 100644
--- a/go/vt/vttablet/tabletmanager/tm_state_test.go
+++ b/go/vt/vttablet/tabletmanager/tm_state_test.go
@@ -41,7 +41,7 @@ func TestStateOpenClose(t *testing.T) {
 	savedCtx := tm.tmState.ctx
 	tm.tmState.mu.Unlock()
 
-	tm.tmState.Open(context.Background())
+	tm.tmState.Open()
 
 	tm.tmState.mu.Lock()
 	assert.Equal(t, savedCtx, tm.tmState.ctx)
diff --git a/go/vt/vttablet/tabletserver/query_executor_test.go b/go/vt/vttablet/tabletserver/query_executor_test.go
index d33d4c46b3..0974d2ba6b 100644
--- a/go/vt/vttablet/tabletserver/query_executor_test.go
+++ b/go/vt/vttablet/tabletserver/query_executor_test.go
@@ -477,7 +477,7 @@ func TestQueryExecutorPlanPassSelectWithLockOutsideATransaction(t *testing.T) {
 		Rows:   [][]sqltypes.Value{},
 	}
 	db.AddQuery(query, want)
-	db.AddQuery("select * from test_table limit 10001 for update", &sqltypes.Result{
+	db.AddQuery("select * from test_table where 1 != 1", &sqltypes.Result{
 		Fields: getTestTableFields(),
 	})
 	ctx := context.Background()
@@ -487,7 +487,6 @@ func TestQueryExecutorPlanPassSelectWithLockOutsideATransaction(t *testing.T) {
 	assert.Equal(t, planbuilder.PlanSelectLock, qre.plan.PlanID)
 	_, err := qre.Execute()
 	if code := vterrors.Code(err); code != vtrpcpb.Code_FAILED_PRECONDITION {
-		assert.NoError(t, err)
 		t.Fatalf("qre.Execute: %v, want %v", code, vtrpcpb.Code_FAILED_PRECONDITION)
 	}
 }
diff --git a/test/config.json b/test/config.json
index 87165b334c..a8099ef99a 100644
--- a/test/config.json
+++ b/test/config.json
@@ -428,15 +428,6 @@
 			"RetryMax": 0,
 			"Tags": []
 		},
-		"vtgate_concurrentdml": {
-			"File": "unused.go",
-			"Args": ["vitess.io/vitess/go/test/endtoend/vtgate/concurrentdml"],
-			"Command": [],
-			"Manual": false,
-			"Shard": 17,
-			"RetryMax": 0,
-			"Tags": []
-		},
 		"vtgate_schema": {
 			"File": "unused.go",
 			"Args": ["vitess.io/vitess/go/test/endtoend/vtgate/schema"],