Repository: vitessio/vitess
Pull request #6649 (2020-08-31 04:17:25)

Add unit test for func Proto3ValuesEqual.
Signed-off-by: Hu Shuai <hus.fnst@cn.fujitsu.com>


Patch:
diff --git a/go/vt/binlog/binlogplayer/binlog_player.go b/go/vt/binlog/binlogplayer/binlog_player.go
index d8f6f51c28..892eb97a9e 100644
--- a/go/vt/binlog/binlogplayer/binlog_player.go
+++ b/go/vt/binlog/binlogplayer/binlog_player.go
@@ -614,17 +614,6 @@ func GenerateUpdatePos(uid uint32, pos mysql.Position, timeUpdated int64, txTime
 		encodeString(mysql.EncodePosition(pos)), timeUpdated, uid)
 }
 
-// GenerateUpdateTime returns a statement to update time_updated and transaction_timestamp in the
-// _vt.vreplication table.
-func GenerateUpdateTime(uid uint32, timeUpdated int64, txTimestamp int64) (string, error) {
-	if timeUpdated == 0 || txTimestamp == 0 {
-		return "", fmt.Errorf("invalid timeUpdated or txTimestamp supplied")
-	}
-	return fmt.Sprintf(
-		"update _vt.vreplication set time_updated=%v, transaction_timestamp=%v where id=%v",
-		timeUpdated, txTimestamp, uid), nil
-}
-
 // StartVReplication returns a statement to start the replication.
 func StartVReplication(uid uint32) string {
 	return fmt.Sprintf(
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/discovery/tablet_picker.go b/go/vt/discovery/tablet_picker.go
index abb649c2e8..27362382b9 100644
--- a/go/vt/discovery/tablet_picker.go
+++ b/go/vt/discovery/tablet_picker.go
@@ -157,19 +157,12 @@ func (tp *TabletPicker) getMatchingTablets(ctx context.Context) []*topo.TabletIn
 			// non-blocking read so that this is fast
 			shortCtx, cancel := context.WithTimeout(ctx, *topo.RemoteOperationTimeout)
 			defer cancel()
-			_, err := tp.ts.GetCellInfo(shortCtx, cell, false)
+			alias, err := tp.ts.GetCellsAlias(shortCtx, cell, false)
 			if err != nil {
-				// not a valid cell, check whether it is a cell alias
-				shortCtx, cancel := context.WithTimeout(ctx, *topo.RemoteOperationTimeout)
-				defer cancel()
-				alias, err := tp.ts.GetCellsAlias(shortCtx, cell, false)
-				// if we get an error, either cellAlias doesn't exist or it isn't a cell alias at all. Ignore and continue
-				if err == nil {
-					actualCells = append(actualCells, alias.Cells...)
-				}
-			} else {
-				// valid cell, add it to our list
+				// either cellAlias doesn't exist or it isn't a cell alias at all. In that case assume it is a cell
 				actualCells = append(actualCells, cell)
+			} else {
+				actualCells = append(actualCells, alias.Cells...)
 			}
 		}
 		for _, cell := range actualCells {
@@ -178,6 +171,9 @@ func (tp *TabletPicker) getMatchingTablets(ctx context.Context) []*topo.TabletIn
 			// match cell, keyspace and shard
 			sri, err := tp.ts.GetShardReplication(shortCtx, cell, tp.keyspace, tp.shard)
 			if err != nil {
+				//log.Errorf("missing shard in topo %s", debug.Stack()) //FIXME: remove after all tests run
+
+				//log.Warningf("error %v from GetShardReplication for %v %v %v", err, cell, tp.keyspace, tp.shard)
 				continue
 			}
 
@@ -195,17 +191,14 @@ func (tp *TabletPicker) getMatchingTablets(ctx context.Context) []*topo.TabletIn
 	tabletMap, err := tp.ts.GetTabletMap(shortCtx, aliases)
 	if err != nil {
 		log.Warningf("error fetching tablets from topo: %v", err)
-		// If we get a partial result we can still use it, otherwise return
-		if len(tabletMap) == 0 {
-			return nil
-		}
+		return nil
 	}
 	tablets := make([]*topo.TabletInfo, 0, len(aliases))
 	for _, tabletAlias := range aliases {
 		tabletInfo, ok := tabletMap[topoproto.TabletAliasString(tabletAlias)]
 		if !ok {
-			// Either tablet disappeared on us, or we got a partial result (GetTabletMap ignores
-			// topo.ErrNoNode). Just log a warning
+			// tablet disappeared on us (GetTabletMap ignores
+			// topo.ErrNoNode), just echo a warning
 			log.Warningf("failed to load tablet %v", tabletAlias)
 		} else if topoproto.IsTypeInList(tabletInfo.Type, tp.tabletTypes) {
 			tablets = append(tablets, tabletInfo)
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/vttablet/tabletmanager/tm_init.go b/go/vt/vttablet/tabletmanager/tm_init.go
index 8c88333bc4..6b247604ba 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.tmState.Open(tm.BatchCtx)
 	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 from %v to master with the shard's master term start time: %v", oldTablet.Type, si.MasterTermStartTime)
+				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)
 				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()
+			defer tm.tmState.Open(ctx)
 
 			// 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 fad4a8b904..86ca17fced 100644
--- a/go/vt/vttablet/tabletmanager/tm_state.go
+++ b/go/vt/vttablet/tabletmanager/tm_state.go
@@ -68,28 +68,26 @@ 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() {
+func (ts *tmState) Open(ctx context.Context) {
 	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(ts.ctx)
+	ts.publishStateLocked(ctx)
 }
 
 func (ts *tmState) Close() {
@@ -194,19 +192,18 @@ 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/tabletmanager/vreplication/vplayer.go b/go/vt/vttablet/tabletmanager/vreplication/vplayer.go
index 847276ec38..ba442fea3c 100644
--- a/go/vt/vttablet/tabletmanager/vreplication/vplayer.go
+++ b/go/vt/vttablet/tabletmanager/vreplication/vplayer.go
@@ -243,21 +243,6 @@ func (vp *vplayer) updatePos(ts int64) (posReached bool, err error) {
 	return posReached, nil
 }
 
-func (vp *vplayer) updateTime(ts int64) (err error) {
-	update, err := binlogplayer.GenerateUpdateTime(vp.vr.id, time.Now().Unix(), ts)
-	if err != nil {
-		return err
-	}
-	if _, err := vp.vr.dbClient.Execute(update); err != nil {
-		return fmt.Errorf("error %v updating time", err)
-	}
-	vp.unsavedEvent = nil
-	vp.timeLastSaved = time.Now()
-	return nil
-}
-
-// applyEvents is the main thread that applies the events. It has the following use
-
 // applyEvents is the main thread that applies the events. It has the following use
 // cases to take into account:
 // * Normal transaction that has row mutations. In this case, the transaction
@@ -595,12 +580,7 @@ func (vp *vplayer) applyEvent(ctx context.Context, event *binlogdatapb.VEvent, m
 		stats.Send(fmt.Sprintf("%v", event.Journal))
 		return io.EOF
 	case binlogdatapb.VEventType_HEARTBEAT:
-		if !vp.vr.dbClient.InTransaction {
-			err := vp.updateTime(event.Timestamp)
-			if err != nil {
-				return err
-			}
-		}
+		// No-op: heartbeat timings are calculated in outer loop.
 	}
 	return nil
 }
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.")
diff --git a/go/vt/wrangler/vexec.go b/go/vt/wrangler/vexec.go
index 72e8ab716a..f7b64a2738 100644
--- a/go/vt/wrangler/vexec.go
+++ b/go/vt/wrangler/vexec.go
@@ -254,8 +254,6 @@ type ReplicationStatusResult struct {
 	SourceLocation ReplicationLocation
 	// TargetLocation represents the keyspace and shards that we are vreplicating into.
 	TargetLocation ReplicationLocation
-	// MaxVReplicationLag represents the maximum vreplication lag seen across all shards.
-	MaxVReplicationLag int64
 
 	// Statuses is a map of <shard>/<master tablet alias> : ShardReplicationStatus (for the given shard).
 	ShardStatuses map[string]*ShardReplicationStatus
@@ -302,8 +300,6 @@ type ReplicationStatus struct {
 	MaxReplicationLag int64
 	// DbName represents the db_name column from the _vt.vreplication table.
 	DBName string
-	// TransactionTimestamp represents the transaction_timestamp column from the _vt.vreplication table.
-	TransactionTimestamp int64
 	// TimeUpdated represents the time_updated column from the _vt.vreplication table.
 	TimeUpdated int64
 	// Message represents the message column from the _vt.vreplication table.
@@ -315,7 +311,7 @@ type ReplicationStatus struct {
 
 func (wr *Wrangler) getReplicationStatusFromRow(ctx context.Context, row []sqltypes.Value, master *topo.TabletInfo) (*ReplicationStatus, string, error) {
 	var err error
-	var id, maxReplicationLag, timeUpdated, transactionTimestamp int64
+	var id, maxReplicationLag, timeUpdated int64
 	var state, dbName, pos, stopPos, message string
 	var bls binlogdatapb.BinlogSource
 	id, err = evalengine.ToInt64(row[0])
@@ -337,24 +333,19 @@ func (wr *Wrangler) getReplicationStatusFromRow(ctx context.Context, row []sqlty
 	if err != nil {
 		return nil, "", err
 	}
-	transactionTimestamp, err = evalengine.ToInt64(row[8])
-	if err != nil {
-		return nil, "", err
-	}
-	message = row[9].ToString()
+	message = row[8].ToString()
 	status := &ReplicationStatus{
-		Shard:                master.Shard,
-		Tablet:               master.AliasString(),
-		ID:                   id,
-		Bls:                  bls,
-		Pos:                  pos,
-		StopPos:              stopPos,
-		State:                state,
-		DBName:               dbName,
-		MaxReplicationLag:    maxReplicationLag,
-		TransactionTimestamp: transactionTimestamp,
-		TimeUpdated:          timeUpdated,
-		Message:              message,
+		Shard:             master.Shard,
+		Tablet:            master.AliasString(),
+		ID:                id,
+		Bls:               bls,
+		Pos:               pos,
+		StopPos:           stopPos,
+		State:             state,
+		DBName:            dbName,
+		MaxReplicationLag: maxReplicationLag,
+		TimeUpdated:       timeUpdated,
+		Message:           message,
 	}
 	status.CopyState, err = wr.getCopyState(ctx, master, id)
 	if err != nil {
@@ -370,7 +361,7 @@ func (wr *Wrangler) getStreams(ctx context.Context, workflow, keyspace string) (
 	rsr.ShardStatuses = make(map[string]*ShardReplicationStatus)
 	rsr.Workflow = workflow
 	var results map[*topo.TabletInfo]*querypb.QueryResult
-	query := "select id, source, pos, stop_pos, max_replication_lag, state, db_name, time_updated, transaction_timestamp, message from _vt.vreplication"
+	query := "select id, source, pos, stop_pos, max_replication_lag, state, db_name, time_updated, message from _vt.vreplication"
 	results, err := wr.runVexec(ctx, workflow, keyspace, query, false)
 	if err != nil {
 		return nil, err
@@ -393,13 +384,8 @@ func (wr *Wrangler) getStreams(ctx context.Context, workflow, keyspace string) (
 			}
 			sourceKeyspace = sk
 			sourceShards.Insert(status.Bls.Shard)
-			rsrStatus = append(rsrStatus, status)
 
-			transactionTimestamp := time.Unix(status.TransactionTimestamp, 0)
-			replicationLag := time.Since(transactionTimestamp)
-			if replicationLag.Seconds() > float64(rsr.MaxVReplicationLag) {
-				rsr.MaxVReplicationLag = int64(replicationLag.Seconds())
-			}
+			rsrStatus = append(rsrStatus, status)
 		}
 		si, err := wr.ts.GetShard(ctx, keyspace, master.Shard)
 		if err != nil {


Test patch:
diff --git a/go/sqltypes/proto3_test.go b/go/sqltypes/proto3_test.go
index 5cb88ebe35..89c0c0427a 100644
--- a/go/sqltypes/proto3_test.go
+++ b/go/sqltypes/proto3_test.go
@@ -20,6 +20,7 @@ import (
 	"testing"
 
 	"github.com/golang/protobuf/proto"
+	"github.com/stretchr/testify/require"
 	querypb "vitess.io/vitess/go/vt/proto/query"
 	vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
 	"vitess.io/vitess/go/vt/vterrors"
@@ -244,3 +245,78 @@ func TestQueryReponses(t *testing.T) {
 		t.Errorf("reverse:\n%#v, want\n%#v", reverse, queryResponses)
 	}
 }
+
+func TestProto3ValuesEqual(t *testing.T) {
+	for _, tc := range []struct {
+		v1, v2   []*querypb.Value
+		expected bool
+	}{
+		{
+			v1: []*querypb.Value{
+				{
+					Type:  0,
+					Value: []byte{0, 1},
+				},
+			},
+			v2: []*querypb.Value{
+				{
+					Type:  0,
+					Value: []byte{0, 1},
+				},
+				{
+					Type:  1,
+					Value: []byte{0, 1, 2},
+				},
+			},
+			expected: false,
+		},
+		{
+			v1: []*querypb.Value{
+				{
+					Type:  0,
+					Value: []byte{0, 1},
+				},
+				{
+					Type:  1,
+					Value: []byte{0, 1, 2},
+				},
+			},
+			v2: []*querypb.Value{
+				{
+					Type:  0,
+					Value: []byte{0, 1},
+				},
+				{
+					Type:  1,
+					Value: []byte{0, 1, 2},
+				},
+			},
+			expected: true,
+		},
+		{
+			v1: []*querypb.Value{
+				{
+					Type:  0,
+					Value: []byte{0, 1},
+				},
+				{
+					Type:  1,
+					Value: []byte{0, 1},
+				},
+			},
+			v2: []*querypb.Value{
+				{
+					Type:  0,
+					Value: []byte{0, 1},
+				},
+				{
+					Type:  1,
+					Value: []byte{0, 1, 2},
+				},
+			},
+			expected: false,
+		},
+	} {
+		require.Equal(t, tc.expected, Proto3ValuesEqual(tc.v1, tc.v2))
+	}
+}
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/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/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/vttablet/tabletmanager/tm_init_test.go b/go/vt/vttablet/tabletmanager/tm_init_test.go
index 4ff49654c3..81ef2d5cf7 100644
--- a/go/vt/vttablet/tabletmanager/tm_init_test.go
+++ b/go/vt/vttablet/tabletmanager/tm_init_test.go
@@ -432,71 +432,6 @@ 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 680fa41e08..031c42c2c4 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()
+	tm.tmState.Open(context.Background())
 
 	tm.tmState.mu.Lock()
 	assert.Equal(t, savedCtx, tm.tmState.ctx)
diff --git a/go/vt/vttablet/tabletmanager/vreplication/framework_test.go b/go/vt/vttablet/tabletmanager/vreplication/framework_test.go
index 4ac5e3d808..e93ae5bdc4 100644
--- a/go/vt/vttablet/tabletmanager/vreplication/framework_test.go
+++ b/go/vt/vttablet/tabletmanager/vreplication/framework_test.go
@@ -458,16 +458,8 @@ func expectDBClientQueries(t *testing.T, queries []string) {
 			continue
 		}
 		var got string
-		heartbeatRe := regexp.MustCompile(`update _vt.vreplication set time_updated=\d+, transaction_timestamp=\d+ where id=\d+`)
-	retry:
 		select {
 		case got = <-globalDBQueries:
-			// We rule out heartbeat time update queries because otherwise our query list
-			// is indeterminable and varies with each test execution.
-			if heartbeatRe.MatchString(got) {
-				goto retry
-			}
-
 			var match bool
 			if query[0] == '/' {
 				result, err := regexp.MatchString(query[1:], got)
@@ -501,7 +493,6 @@ func expectDBClientQueries(t *testing.T, queries []string) {
 func expectNontxQueries(t *testing.T, queries []string) {
 	t.Helper()
 	failed := false
-	heartbeatRe := regexp.MustCompile(`update _vt.vreplication set time_updated=\d+, transaction_timestamp=\d+ where id=\d+`)
 	for i, query := range queries {
 		if failed {
 			t.Errorf("no query received, expecting %s", query)
@@ -512,7 +503,7 @@ func expectNontxQueries(t *testing.T, queries []string) {
 		select {
 		case got = <-globalDBQueries:
 
-			if got == "begin" || got == "commit" || got == "rollback" || strings.Contains(got, "update _vt.vreplication set pos") || heartbeatRe.MatchString(got) {
+			if got == "begin" || got == "commit" || got == "rollback" || strings.Contains(got, "update _vt.vreplication set pos") {
 				goto retry
 			}
 
diff --git a/go/vt/wrangler/vexec_test.go b/go/vt/wrangler/vexec_test.go
index 415158041c..cb38d1570a 100644
--- a/go/vt/wrangler/vexec_test.go
+++ b/go/vt/wrangler/vexec_test.go
@@ -19,14 +19,12 @@ package wrangler
 import (
 	"context"
 	"fmt"
-	"regexp"
 	"sort"
 	"strings"
 	"testing"
 	"time"
 
 	"github.com/stretchr/testify/require"
-
 	"vitess.io/vitess/go/sqltypes"
 	"vitess.io/vitess/go/test/utils"
 	"vitess.io/vitess/go/vt/logutil"
@@ -207,7 +205,6 @@ func TestWorkflowListStreams(t *testing.T) {
 			"80-"
 		]
 	},
-	"MaxVReplicationLag": 0,
 	"ShardStatuses": {
 		"-80/zone1-0000000200": {
 			"MasterReplicationStatuses": [
@@ -231,7 +228,6 @@ func TestWorkflowListStreams(t *testing.T) {
 					"State": "Copying",
 					"MaxReplicationLag": 0,
 					"DBName": "vt_target",
-					"TransactionTimestamp": 0,
 					"TimeUpdated": 1234,
 					"Message": "",
 					"CopyState": [
@@ -267,7 +263,6 @@ func TestWorkflowListStreams(t *testing.T) {
 					"State": "Copying",
 					"MaxReplicationLag": 0,
 					"DBName": "vt_target",
-					"TransactionTimestamp": 0,
 					"TimeUpdated": 1234,
 					"Message": "",
 					"CopyState": [
@@ -285,11 +280,7 @@ func TestWorkflowListStreams(t *testing.T) {
 }
 
 `
-	got := logger.String()
-	// MaxVReplicationLag needs to be reset. This can't be determinable in this kind of a test because time.Now() is constantly shifting.
-	re := regexp.MustCompile(`"MaxVReplicationLag": \d+`)
-	got = re.ReplaceAllLiteralString(got, `"MaxVReplicationLag": 0`)
-	require.Equal(t, want, got)
+	require.Equal(t, want, logger.String())
 
 	results, err := wr.execWorkflowAction(ctx, workflow, keyspace, "stop", false)
 	require.Nil(t, err)
diff --git a/go/vt/wrangler/wrangler_env_test.go b/go/vt/wrangler/wrangler_env_test.go
index 16116f8541..497af49f33 100644
--- a/go/vt/wrangler/wrangler_env_test.go
+++ b/go/vt/wrangler/wrangler_env_test.go
@@ -144,11 +144,11 @@ func newWranglerTestEnv(sourceShards, targetShards []string, query string, posit
 		env.tmc.setVRResults(master.tablet, "insert into _vt.vreplication(state, workflow, db_name) values ('Running', 'wk1', 'ks1'), ('Stopped', 'wk1', 'ks1')", &sqltypes.Result{RowsAffected: 2})
 
 		result := sqltypes.MakeTestResult(sqltypes.MakeTestFields(
-			"id|source|pos|stop_pos|max_replication_lag|state|db_name|time_updated|transaction_timestamp|message",
-			"int64|varchar|varchar|varchar|int64|varchar|varchar|int64|int64|varchar"),
-			fmt.Sprintf("1|%v|pos||0|Running|vt_target|1234|0|", bls),
+			"id|source|pos|stop_pos|max_replication_lag|state|db_name|time_updated|message",
+			"int64|varchar|varchar|varchar|int64|varchar|varchar|int64|varchar"),
+			fmt.Sprintf("1|%v|pos||0|Running|vt_target|1234|", bls),
 		)
-		env.tmc.setVRResults(master.tablet, "select id, source, pos, stop_pos, max_replication_lag, state, db_name, time_updated, transaction_timestamp, message from _vt.vreplication where db_name = 'vt_target' and workflow = 'wrWorkflow'", result)
+		env.tmc.setVRResults(master.tablet, "select id, source, pos, stop_pos, max_replication_lag, state, db_name, time_updated, message from _vt.vreplication where db_name = 'vt_target' and workflow = 'wrWorkflow'", result)
 		env.tmc.setVRResults(
 			master.tablet,
 			"select source, pos from _vt.vreplication where db_name='vt_target' and workflow='wrWorkflow'",