Skip to content

Commit

Permalink
conn: close domain before closing storage (pingcap#98)
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Shen <overvenus@gmail.com>
  • Loading branch information
overvenus authored Dec 10, 2019
1 parent 719cac0 commit 89c1996
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/url"
"strings"
"sync"
"sync/atomic"
"time"

"github.com/pingcap/errors"
Expand Down Expand Up @@ -253,8 +254,6 @@ func (mgr *Mgr) GetDomain() *domain.Domain {

// Close closes all client in Mgr.
func (mgr *Mgr) Close() {
mgr.pdClient.Close()
mgr.storage.Close()
mgr.grpcClis.mu.Lock()
for _, cli := range mgr.grpcClis.clis {
err := cli.Close()
Expand All @@ -263,6 +262,12 @@ func (mgr *Mgr) Close() {
}
}
mgr.grpcClis.mu.Unlock()

// Gracefully shutdown domain so it does not affect other TiDB DDL.
// Must close domain before closing storage, otherwise it gets stuck forever.
mgr.dom.Close()

atomic.StoreUint32(&tikv.ShuttingDown, 1)
mgr.storage.Close()
mgr.pdClient.Close()
}

0 comments on commit 89c1996

Please sign in to comment.