Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[misc] Delete more unused functions, tidy up dupe imports #13878

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 14 additions & 15 deletions go/vt/mysqlctl/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"vitess.io/vitess/go/vt/topo/topoproto"
"vitess.io/vitess/go/vt/vterrors"

stats "vitess.io/vitess/go/vt/mysqlctl/backupstats"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)

Expand Down Expand Up @@ -122,7 +121,7 @@ func registerBackupFlags(fs *pflag.FlagSet) {
// - remember if we were replicating, restore the exact same state
func Backup(ctx context.Context, params BackupParams) error {
if params.Stats == nil {
params.Stats = stats.NoStats()
params.Stats = backupstats.NoStats()
}

startTs := time.Now()
Expand All @@ -137,8 +136,8 @@ func Backup(ctx context.Context, params BackupParams) error {

// Scope bsStats to selected storage engine.
bsStats := params.Stats.Scope(
stats.Component(stats.BackupStorage),
stats.Implementation(
backupstats.Component(backupstats.BackupStorage),
backupstats.Implementation(
titleCase(backupstorage.BackupStorageImplementation),
),
)
Expand All @@ -156,8 +155,8 @@ func Backup(ctx context.Context, params BackupParams) error {
// Scope stats to selected backup engine.
beParams := params.Copy()
beParams.Stats = params.Stats.Scope(
stats.Component(stats.BackupEngine),
stats.Implementation(titleCase(backupEngineImplementation)),
backupstats.Component(backupstats.BackupEngine),
backupstats.Implementation(titleCase(backupEngineImplementation)),
)
var be BackupEngine
if isIncrementalBackup(beParams) {
Expand Down Expand Up @@ -192,8 +191,8 @@ func Backup(ctx context.Context, params BackupParams) error {
}

// The backup worked, so just return the finish error, if any.
stats.DeprecatedBackupDurationS.Set(int64(time.Since(startTs).Seconds()))
params.Stats.Scope(stats.Operation("Backup")).TimedIncrement(time.Since(startTs))
backupstats.DeprecatedBackupDurationS.Set(int64(time.Since(startTs).Seconds()))
params.Stats.Scope(backupstats.Operation("Backup")).TimedIncrement(time.Since(startTs))
return finishErr
}

Expand Down Expand Up @@ -359,7 +358,7 @@ func ensureRestoredGTIDPurgedMatchesManifest(ctx context.Context, manifest *Back
// and returns ErrNoBackup. Any other error is returned.
func Restore(ctx context.Context, params RestoreParams) (*BackupManifest, error) {
if params.Stats == nil {
params.Stats = stats.NoStats()
params.Stats = backupstats.NoStats()
}

startTs := time.Now()
Expand All @@ -373,8 +372,8 @@ func Restore(ctx context.Context, params RestoreParams) (*BackupManifest, error)

// Scope bsStats to selected storage engine.
bsStats := params.Stats.Scope(
stats.Component(backupstats.BackupStorage),
stats.Implementation(
backupstats.Component(backupstats.BackupStorage),
backupstats.Implementation(
titleCase(backupstorage.BackupStorageImplementation),
),
)
Expand Down Expand Up @@ -428,8 +427,8 @@ func Restore(ctx context.Context, params RestoreParams) (*BackupManifest, error)
// Scope stats to selected backup engine.
reParams := params.Copy()
reParams.Stats = params.Stats.Scope(
stats.Component(backupstats.BackupEngine),
stats.Implementation(titleCase(backupEngineImplementation)),
backupstats.Component(backupstats.BackupEngine),
backupstats.Implementation(titleCase(backupEngineImplementation)),
)
manifest, err := re.ExecuteRestore(ctx, reParams, bh)
if err != nil {
Expand Down Expand Up @@ -487,8 +486,8 @@ func Restore(ctx context.Context, params RestoreParams) (*BackupManifest, error)
return nil, err
}

stats.DeprecatedRestoreDurationS.Set(int64(time.Since(startTs).Seconds()))
params.Stats.Scope(stats.Operation("Restore")).TimedIncrement(time.Since(startTs))
backupstats.DeprecatedRestoreDurationS.Set(int64(time.Since(startTs).Seconds()))
params.Stats.Scope(backupstats.Operation("Restore")).TimedIncrement(time.Since(startTs))
params.Logger.Infof("Restore: complete")
return manifest, nil
}
7 changes: 3 additions & 4 deletions go/vt/mysqlctl/backupstats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"time"

"vitess.io/vitess/go/stats"
vtstats "vitess.io/vitess/go/stats"
)

// Stats is a reporting interface meant to be shared among backup and restore
Expand Down Expand Up @@ -52,9 +51,9 @@ type Stats interface {
type noStats struct{}

type scopedStats struct {
bytes *vtstats.CountersWithMultiLabels
count *vtstats.CountersWithMultiLabels
durationNs *vtstats.CountersWithMultiLabels
bytes *stats.CountersWithMultiLabels
count *stats.CountersWithMultiLabels
durationNs *stats.CountersWithMultiLabels
labelValues []string
}

Expand Down
10 changes: 5 additions & 5 deletions go/vt/mysqlctl/builtinbackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ import (
"vitess.io/vitess/go/vt/logutil"
stats "vitess.io/vitess/go/vt/mysqlctl/backupstats"
"vitess.io/vitess/go/vt/mysqlctl/backupstorage"
"vitess.io/vitess/go/vt/proto/mysqlctl"
mysqlctlpb "vitess.io/vitess/go/vt/proto/mysqlctl"
tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
"vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/topo/topoproto"
"vitess.io/vitess/go/vt/vterrors"
"vitess.io/vitess/go/vt/vttablet/tmclient"

mysqlctlpb "vitess.io/vitess/go/vt/proto/mysqlctl"
tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
"vitess.io/vitess/go/vt/proto/vtrpc"
)

const (
Expand Down Expand Up @@ -331,7 +331,7 @@ func (be *BuiltinBackupEngine) executeIncrementalBackup(ctx context.Context, par
// It's also nice for incremental backups that are taken on _other_ tablets, so that they don't need to understand what exactly was purged
// on _this_ tablet. They don't care, all they want to know is "what GTIDSet can we get from this".
incrementalBackupToPosition.GTIDSet = incrementalBackupToPosition.GTIDSet.Union(gtidPurged.GTIDSet)
req := &mysqlctl.ReadBinlogFilesTimestampsRequest{}
req := &mysqlctlpb.ReadBinlogFilesTimestampsRequest{}
for _, binlogFile := range binaryLogsToBackup {
fe := FileEntry{Base: backupBinlogDir, Name: binlogFile}
fullPath, err := fe.fullPath(params.Cnf)
Expand Down
8 changes: 0 additions & 8 deletions go/vt/schema/online_ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,6 @@ func TestNewOnlineDDLs(t *testing.T) {
}

func TestNewOnlineDDLsForeignKeys(t *testing.T) {
type expect struct {
sqls []string
notDDL bool
parseError bool
isError bool
expectErrorText string
isView bool
}
queries := []string{
"alter table corder add FOREIGN KEY my_fk(customer_id) references customer(customer_id)",
"create table t1 (id int primary key, i int, foreign key (i) references parent(id))",
Expand Down
24 changes: 0 additions & 24 deletions go/vt/sqlparser/ast_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1996,17 +1996,6 @@ func (node *ColName) CompliantName() string {
return node.Name.CompliantName()
}

// isExprAliasForCurrentTimeStamp returns true if the Expr provided is an alias for CURRENT_TIMESTAMP
func isExprAliasForCurrentTimeStamp(expr Expr) bool {
switch node := expr.(type) {
case *FuncExpr:
return node.Name.EqualString("current_timestamp") || node.Name.EqualString("now") || node.Name.EqualString("localtimestamp") || node.Name.EqualString("localtime")
case *CurTimeFuncExpr:
return node.Name.EqualString("current_timestamp") || node.Name.EqualString("now") || node.Name.EqualString("localtimestamp") || node.Name.EqualString("localtime")
}
return false
}

// AtCount represents the '@' count in IdentifierCI
type AtCount int

Expand Down Expand Up @@ -2171,19 +2160,6 @@ func (s SelectExprs) AllAggregation() bool {
return true
}

func isExprLiteral(expr Expr) bool {
switch expr := expr.(type) {
case *Literal:
return true
case BoolVal:
return true
case *UnaryExpr:
return isExprLiteral(expr.Expr)
default:
return false
}
}

// RemoveKeyspaceFromColName removes the Qualifier.Qualifier on all ColNames in the expression tree
func RemoveKeyspaceFromColName(expr Expr) {
RemoveKeyspace(expr)
Expand Down
1 change: 0 additions & 1 deletion go/vt/sqlparser/ast_rewriting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type myTestCase struct {
udv int
autocommit, clientFoundRows, skipQueryPlanCache, socket, queryTimeout bool
sqlSelectLimit, transactionMode, workload, version, versionComment bool
txIsolation bool
}

func TestRewrites(in *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion go/vt/topo/memorytopo/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ func (c *Conn) Delete(ctx context.Context, filePath string, version topo.Version

// Check if it's a directory.
if n.isDirectory() {
//lint:ignore ST1005 Delete is a function name
return fmt.Errorf("delete(%v, %v) failed: it's a directory", c.cell, filePath)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/vt/proto/vtadmin"
vtadminpb "vitess.io/vitess/go/vt/proto/vtadmin"
)

Expand Down Expand Up @@ -54,7 +53,7 @@ func TestDiscoverVTGate(t *testing.T) {
}]
}
`),
expected: &vtadmin.VTGate{
expected: &vtadminpb.VTGate{
Hostname: "127.0.0.1:12345",
},
},
Expand Down Expand Up @@ -292,7 +291,7 @@ func TestDiscoverVtctld(t *testing.T) {
}]
}
`),
expected: &vtadmin.Vtctld{
expected: &vtadminpb.Vtctld{
Hostname: "127.0.0.1:12345",
},
},
Expand Down
3 changes: 0 additions & 3 deletions go/vt/vtctl/vdiff2.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ func commandVDiff2(ctx context.Context, wr *wrangler.Wrangler, subFlags *pflag.F
return fmt.Errorf("invalid action '%s'; %s", action, usage)
}

type ErrorResponse struct {
Error string
}
output, err := wr.VDiff2(ctx, keyspace, workflowName, action, actionArg, vdiffUUID.String(), options)
if err != nil {
log.Errorf("vdiff2 returning with error: %v", err)
Expand Down
39 changes: 0 additions & 39 deletions go/vt/vtgate/buffer/shard_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ type shardBuffer struct {
state bufferState
// queue is the list of buffered requests (ordered by arrival).
queue []*entry
// externallyReparented is the maximum value of all seen
// "StreamHealthResponse.TabletexternallyReparentedTimestamp" values across
// all PRIMARY tablets of this shard.
// In practice, it is a) the last time the shard was reparented or b) the last
// time the TabletExternallyReparented RPC was called on the tablet to confirm
// that the tablet is the current PRIMARY.
// We assume the value is a Unix timestamp in seconds.
externallyReparented int64
// lastStart is the last time we saw the start of a failover.
lastStart time.Time
// lastEnd is the last time we saw the end of a failover.
Expand Down Expand Up @@ -513,37 +505,6 @@ func (sb *shardBuffer) recordKeyspaceEvent(alias *topodatapb.TabletAlias, stillS
sb.stopBufferingLocked(reason, msg)
}

func (sb *shardBuffer) recordExternallyReparentedTimestamp(timestamp int64, alias *topodatapb.TabletAlias) {
// Fast path (read lock): Check if new timestamp is higher.
sb.mu.RLock()
if timestamp <= sb.externallyReparented {
// Do nothing. Equal values are reported if the primary has not changed.
// Smaller values can be reported during the failover by the old primary
// after the new primary already took over.
sb.mu.RUnlock()
return
}
sb.mu.RUnlock()

// New timestamp is higher. Stop buffering if running.
sb.mu.Lock()
defer sb.mu.Unlock()

// Re-check value after acquiring write lock.
if timestamp <= sb.externallyReparented {
return
}

sb.externallyReparented = timestamp
if !topoproto.TabletAliasEqual(alias, sb.currentPrimary) {
if sb.currentPrimary != nil {
sb.lastReparent = sb.timeNow()
}
sb.currentPrimary = alias
}
sb.stopBufferingLocked(stopFailoverEndDetected, "failover end detected")
}

func (sb *shardBuffer) stopBufferingDueToMaxDuration() {
sb.mu.Lock()
defer sb.mu.Unlock()
Expand Down
15 changes: 7 additions & 8 deletions go/vt/vtgate/endtoend/vstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@ import (
"sync"
"testing"

"vitess.io/vitess/go/mysql/collations"
vtgatepb "vitess.io/vitess/go/vt/proto/vtgate"

"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/vtgate/vtgateconn"

binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
"vitess.io/vitess/go/vt/proto/query"
querypb "vitess.io/vitess/go/vt/proto/query"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
"vitess.io/vitess/go/vt/vtgate/vtgateconn"
vtgatepb "vitess.io/vitess/go/vt/proto/vtgate"
)

func initialize(ctx context.Context, t *testing.T) (*vtgateconn.VTGateConn, *mysql.Conn, *mysql.Conn, func()) {
Expand Down Expand Up @@ -151,7 +150,7 @@ func TestVStream(t *testing.T) {
Keyspace: "ks",
Shard: "-80",
RowChanges: []*binlogdatapb.RowChange{{
After: &query.Row{
After: &querypb.Row{
Lengths: []int64{1, 1},
Values: []byte("11"),
},
Expand All @@ -177,7 +176,7 @@ func TestVStreamCopyBasic(t *testing.T) {
}

lastPK := sqltypes.Result{
Fields: []*query.Field{{Name: "id1", Type: query.Type_INT32}},
Fields: []*querypb.Field{{Name: "id1", Type: querypb.Type_INT32}},
Rows: [][]sqltypes.Value{{sqltypes.NewInt32(4)}},
}
qr := sqltypes.ResultToProto3(&lastPK)
Expand Down Expand Up @@ -405,7 +404,7 @@ func TestVStreamCopyResume(t *testing.T) {

// lastPK is id1=4, meaning we should only copy rows for id1 IN(5,6,7,8,9)
lastPK := sqltypes.Result{
Fields: []*query.Field{{Name: "id1", Type: query.Type_INT64, Charset: collations.CollationBinaryID, Flags: uint32(query.MySqlFlag_NUM_FLAG | query.MySqlFlag_BINARY_FLAG)}},
Fields: []*querypb.Field{{Name: "id1", Type: querypb.Type_INT64, Charset: collations.CollationBinaryID, Flags: uint32(querypb.MySqlFlag_NUM_FLAG | querypb.MySqlFlag_BINARY_FLAG)}},
Rows: [][]sqltypes.Value{{sqltypes.NewInt64(4)}},
}
tableLastPK := []*binlogdatapb.TableLastPK{{
Expand Down
13 changes: 0 additions & 13 deletions go/vt/vtgate/evalengine/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,6 @@ func TestCompilerReference(t *testing.T) {
t.Logf("\n%s", track.String())
}

type debugCompiler struct {
t testing.TB
}

func (d *debugCompiler) Instruction(ins string, args ...any) {
ins = fmt.Sprintf(ins, args...)
d.t.Logf("> %s", ins)
}

func (d *debugCompiler) Stack(old, new int) {
d.t.Logf("\tsp = %d -> %d", old, new)
}

func TestCompilerSingle(t *testing.T) {
var testCases = []struct {
expression string
Expand Down
6 changes: 0 additions & 6 deletions go/vt/vtgate/evalengine/eval_temporal.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package evalengine

import (
"time"

"vitess.io/vitess/go/hack"
"vitess.io/vitess/go/mysql/collations"
"vitess.io/vitess/go/mysql/datetime"
Expand Down Expand Up @@ -140,10 +138,6 @@ func (e *evalTemporal) isZero() bool {
return e.dt.IsZero()
}

func (e *evalTemporal) toStdTime(loc *time.Location) time.Time {
return e.dt.ToStdTime(loc)
}

func (e *evalTemporal) addInterval(interval *datetime.Interval, strcoll collations.TypedCollation) eval {
var tmp *evalTemporal
var ok bool
Expand Down
Loading
Loading