diff --git a/go/vt/mysqlctl/query.go b/go/vt/mysqlctl/query.go index b4b9ac0bd79..723e9773d57 100644 --- a/go/vt/mysqlctl/query.go +++ b/go/vt/mysqlctl/query.go @@ -31,8 +31,8 @@ import ( // getPoolReconnect gets a connection from a pool, tests it, and reconnects if // the connection is lost. -func (mysqld *Mysqld) getPoolReconnect(ctx context.Context) (*dbconnpool.PooledDBConnection, error) { - conn, err := mysqld.dbaPool.Get(ctx) +func (mysqld *Mysqld) getPoolReconnect(ctx context.Context, pool *dbconnpool.ConnectionPool) (*dbconnpool.PooledDBConnection, error) { + conn, err := pool.Get(ctx) if err != nil { return conn, err } @@ -59,7 +59,7 @@ func (mysqld *Mysqld) ExecuteSuperQuery(ctx context.Context, query string) error // ExecuteSuperQueryList alows the user to execute queries as a super user. func (mysqld *Mysqld) ExecuteSuperQueryList(ctx context.Context, queryList []string) error { - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -89,7 +89,7 @@ func (mysqld *Mysqld) executeSuperQueryListConn(ctx context.Context, conn *dbcon // FetchSuperQuery returns the results of executing a query as a super user. func (mysqld *Mysqld) FetchSuperQuery(ctx context.Context, query string) (*sqltypes.Result, error) { - conn, connErr := mysqld.getPoolReconnect(ctx) + conn, connErr := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if connErr != nil { return nil, connErr } @@ -171,7 +171,7 @@ func (mysqld *Mysqld) killConnection(connID int64) error { // which is the reason we're being asked to kill the connection. ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - if poolConn, connErr := mysqld.getPoolReconnect(ctx); connErr == nil { + if poolConn, connErr := mysqld.dbaPool.Get(ctx); connErr == nil { // We got a pool connection. defer poolConn.Recycle() killConn = poolConn diff --git a/go/vt/mysqlctl/reparent.go b/go/vt/mysqlctl/reparent.go index 0c69d5f935f..09b0c0fa39e 100644 --- a/go/vt/mysqlctl/reparent.go +++ b/go/vt/mysqlctl/reparent.go @@ -95,7 +95,7 @@ func (mysqld *Mysqld) WaitForReparentJournal(ctx context.Context, timeCreatedNS // Promote will promote this server to be the new primary. func (mysqld *Mysqld) Promote(hookExtraEnv map[string]string) (mysql.Position, error) { ctx := context.TODO() - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return mysql.Position{}, err } diff --git a/go/vt/mysqlctl/replication.go b/go/vt/mysqlctl/replication.go index 9f175144249..84e73e6d895 100644 --- a/go/vt/mysqlctl/replication.go +++ b/go/vt/mysqlctl/replication.go @@ -70,7 +70,7 @@ func WaitForReplicationStart(mysqld MysqlDaemon, replicaStartDeadline int) error // StartReplication starts replication. func (mysqld *Mysqld) StartReplication(hookExtraEnv map[string]string) error { ctx := context.TODO() - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -87,7 +87,7 @@ func (mysqld *Mysqld) StartReplication(hookExtraEnv map[string]string) error { // StartReplicationUntilAfter starts replication until replication has come to `targetPos`, then it stops replication func (mysqld *Mysqld) StartReplicationUntilAfter(ctx context.Context, targetPos mysql.Position) error { - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -106,7 +106,7 @@ func (mysqld *Mysqld) StopReplication(hookExtraEnv map[string]string) error { return err } ctx := context.TODO() - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -117,7 +117,7 @@ func (mysqld *Mysqld) StopReplication(hookExtraEnv map[string]string) error { // StopIOThread stops a replica's IO thread only. func (mysqld *Mysqld) StopIOThread(ctx context.Context) error { - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -134,7 +134,7 @@ func (mysqld *Mysqld) RestartReplication(hookExtraEnv map[string]string) error { return err } ctx := context.TODO() - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -205,7 +205,7 @@ func (mysqld *Mysqld) SetSuperReadOnly(on bool) error { // WaitSourcePos lets replicas wait to given replication position func (mysqld *Mysqld) WaitSourcePos(ctx context.Context, targetPos mysql.Position) error { // Get a connection. - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -272,7 +272,7 @@ func (mysqld *Mysqld) WaitSourcePos(ctx context.Context, targetPos mysql.Positio // ReplicationStatus returns the server replication status func (mysqld *Mysqld) ReplicationStatus(ctx context.Context) (mysql.ReplicationStatus, error) { - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return mysql.ReplicationStatus{}, err } @@ -283,7 +283,7 @@ func (mysqld *Mysqld) ReplicationStatus(ctx context.Context) (mysql.ReplicationS // PrimaryStatus returns the primary replication statuses func (mysqld *Mysqld) PrimaryStatus(ctx context.Context) (mysql.PrimaryStatus, error) { - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return mysql.PrimaryStatus{}, err } @@ -295,7 +295,7 @@ func (mysqld *Mysqld) PrimaryStatus(ctx context.Context) (mysql.PrimaryStatus, e // PrimaryPosition returns the primary replication position. func (mysqld *Mysqld) PrimaryPosition() (mysql.Position, error) { ctx := context.TODO() - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return mysql.Position{}, err } @@ -307,7 +307,7 @@ func (mysqld *Mysqld) PrimaryPosition() (mysql.Position, error) { // SetReplicationPosition sets the replication position at which the replica will resume // when its replication is started. func (mysqld *Mysqld) SetReplicationPosition(ctx context.Context, pos mysql.Position) error { - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -325,7 +325,7 @@ func (mysqld *Mysqld) SetReplicationSource(ctx context.Context, host string, por if err != nil { return err } - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -349,7 +349,7 @@ func (mysqld *Mysqld) SetReplicationSource(ctx context.Context, host string, por // ResetReplication resets all replication for this host. func (mysqld *Mysqld) ResetReplication(ctx context.Context) error { - conn, connErr := mysqld.getPoolReconnect(ctx) + conn, connErr := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if connErr != nil { return connErr } @@ -419,7 +419,7 @@ func FindReplicas(mysqld MysqlDaemon) ([]string, error) { func (mysqld *Mysqld) EnableBinlogPlayback() error { // Get a connection. ctx := context.TODO() - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } @@ -444,7 +444,7 @@ func (mysqld *Mysqld) EnableBinlogPlayback() error { func (mysqld *Mysqld) DisableBinlogPlayback() error { // Get a connection. ctx := context.TODO() - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return err } diff --git a/go/vt/mysqlctl/schema.go b/go/vt/mysqlctl/schema.go index 48cdd6711d6..518c4bfacbe 100644 --- a/go/vt/mysqlctl/schema.go +++ b/go/vt/mysqlctl/schema.go @@ -268,7 +268,7 @@ func ResolveTables(ctx context.Context, mysqld MysqlDaemon, dbName string, table // GetColumns returns the columns of table. func (mysqld *Mysqld) GetColumns(ctx context.Context, dbName, table string) ([]*querypb.Field, []string, error) { - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return nil, nil, err } @@ -298,7 +298,7 @@ func (mysqld *Mysqld) GetPrimaryKeyColumns(ctx context.Context, dbName, table st } func (mysqld *Mysqld) getPrimaryKeyColumns(ctx context.Context, dbName string, tables ...string) (map[string][]string, error) { - conn, err := mysqld.getPoolReconnect(ctx) + conn, err := mysqld.getPoolReconnect(ctx, mysqld.dbaPool) if err != nil { return nil, err }