tidb-server: fix binlog client is not initialized correctly (#4887)

This commit is contained in:
tiancaiamao
2017-10-25 00:46:37 -05:00
committed by Ewan Chou
parent b0d20c9d6b
commit b0d9e8dd87
2 changed files with 5 additions and 4 deletions

View File

@ -166,8 +166,7 @@ func setupBinlogClient() {
dialerOpt := grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
return net.DialTimeout("unix", addr, timeout)
})
var clientConn *grpc.ClientConn
err := tidb.DialPumpClientWithRetry(cfg.BinlogSocket, clientConn, util.DefaultMaxRetries, dialerOpt)
clientConn, err := tidb.DialPumpClientWithRetry(cfg.BinlogSocket, util.DefaultMaxRetries, dialerOpt)
terror.MustNil(err)
binloginfo.SetPumpClient(binlog.NewPumpClient(clientConn))
log.Infof("created binlog client at %s", cfg.BinlogSocket)

View File

@ -258,8 +258,9 @@ func newStoreWithRetry(path string, maxRetries int) (kv.Storage, error) {
// DialPumpClientWithRetry tries to dial to binlogSocket,
// if any error happens, it will try to re-dial,
// or return this error when timeout.
func DialPumpClientWithRetry(binlogSocket string, clientCon *grpc.ClientConn, maxRetries int, dialerOpt grpc.DialOption) error {
return util.RunWithRetry(maxRetries, util.RetryInterval, func() (bool, error) {
func DialPumpClientWithRetry(binlogSocket string, maxRetries int, dialerOpt grpc.DialOption) (*grpc.ClientConn, error) {
var clientCon *grpc.ClientConn
err := util.RunWithRetry(maxRetries, util.RetryInterval, func() (bool, error) {
log.Infof("setup binlog client")
var err error
clientCon, err = grpc.Dial(binlogSocket, grpc.WithInsecure(), dialerOpt)
@ -268,6 +269,7 @@ func DialPumpClientWithRetry(binlogSocket string, clientCon *grpc.ClientConn, ma
}
return true, errors.Trace(err)
})
return clientCon, errors.Trace(err)
}
var queryStmtTable = []string{"explain", "select", "show", "execute", "describe", "desc", "admin"}