зеркало из https://github.com/github/vitess-gh.git
add error as killable.Kill's return value
DBConn implements killable interface, it logs error but then ignores it. It is better to let Kill func has error as return value.
This commit is contained in:
Родитель
090830a29c
Коммит
703d954f2b
|
@ -122,20 +122,22 @@ func (dbc *DBConn) Recycle() {
|
|||
// Kill kills the currently executing query both on MySQL side
|
||||
// and on the connection side. If no query is executing, it's a no-op.
|
||||
// Kill will also not kill a query more than once.
|
||||
func (dbc *DBConn) Kill() {
|
||||
func (dbc *DBConn) Kill() error {
|
||||
killStats.Add("Queries", 1)
|
||||
log.Infof("killing query %s", dbc.Current())
|
||||
killConn, err := dbc.pool.dbaPool.Get(0)
|
||||
if err != nil {
|
||||
log.Warningf("Failed to get conn from dba pool: %v", err)
|
||||
return
|
||||
return NewTabletError(ErrFail, "Failed to get conn from dba pool: %v", err)
|
||||
}
|
||||
defer killConn.Recycle()
|
||||
sql := fmt.Sprintf("kill %d", dbc.conn.ID())
|
||||
_, err = killConn.ExecuteFetch(sql, 10000, false)
|
||||
if err != nil {
|
||||
log.Errorf("Could not kill query %s: %v", dbc.Current(), err)
|
||||
return NewTabletError(ErrFail, "Could not kill query %s: %v", dbc.Current(), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Current returns the currently executing query.
|
||||
|
|
|
@ -22,7 +22,7 @@ type QueryDetail struct {
|
|||
type killable interface {
|
||||
Current() string
|
||||
ID() int64
|
||||
Kill()
|
||||
Kill() error
|
||||
}
|
||||
|
||||
// NewQueryDetail creates a new QueryDetail
|
||||
|
|
|
@ -16,7 +16,10 @@ func (tc *testConn) Current() string { return tc.query }
|
|||
|
||||
func (tc *testConn) ID() int64 { return tc.id }
|
||||
|
||||
func (tc *testConn) Kill() { tc.killed = true }
|
||||
func (tc *testConn) Kill() error {
|
||||
tc.killed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tc *testConn) IsKilled() bool {
|
||||
return tc.killed
|
||||
|
|
Загрузка…
Ссылка в новой задаче