Skip to content

Commit

Permalink
Skip getPoolReconnect() in killConnection()
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Mar 8, 2023
1 parent b143c38 commit a5cec34
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions go/vt/mysqlctl/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/reparent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
28 changes: 14 additions & 14 deletions go/vt/mysqlctl/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions go/vt/mysqlctl/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a5cec34

Please sign in to comment.