Skip to content

Commit

Permalink
Merge branch 'release-2.0' into release-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ngaut authored Oct 29, 2018
2 parents 067c965 + 3e53dfd commit 937f2bc
Show file tree
Hide file tree
Showing 79 changed files with 17,568 additions and 643 deletions.
43 changes: 36 additions & 7 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ ignored = ["github.com/coreos/etcd/etcdserver", "github.com/coreos/etcd/mvcc", "
name = "github.com/sirupsen/logrus"
revision = "3bcb09397d6d88e7676a9bc8433ca11ba5304837"


[[constraint]]
branch = "master"
name = "github.com/etcd-io/gofail"


[[constraint]]
name = "github.com/pingcap/tidb-tools"
revision = "8b1ff6f60738cf3fb5638684b3e74040ed87221f"
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ type PreparedPlanCache struct {

// OpenTracing is the opentracing section of the config.
type OpenTracing struct {
Enable bool `toml:"enable" json:"enbale"`
Enable bool `toml:"enable" json:"enable"`
Sampler OpenTracingSampler `toml:"sampler" json:"sampler"`
Reporter OpenTracingReporter `toml:"reporter" json:"reporter"`
RPCMetrics bool `toml:"rpc-metrics" json:"rpc-metrics"`
Expand Down Expand Up @@ -229,7 +229,7 @@ type TiKVClient struct {

// Binlog is the config for binlog.
type Binlog struct {
BinlogSocket string `toml:"binlog-socket" json:"binlog-socket"`
Enable bool `toml:"enable" json:"enable"`
WriteTimeout string `toml:"write-timeout" json:"write-timeout"`
// If IgnoreError is true, when writting binlog meets error, TiDB would
// ignore the error.
Expand Down
5 changes: 2 additions & 3 deletions config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@ grpc-keepalive-timeout = 3
commit-timeout = "41s"

[binlog]

# Socket file to write binlog.
binlog-socket = ""
# enable to write binlog.
enable = false

# WriteTimeout specifies how long it will wait for writing binlog to pump.
write-timeout = "15s"
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestT(t *testing.T) {

func (s *testConfigSuite) TestConfig(c *C) {
conf := new(Config)
conf.Binlog.BinlogSocket = "/tmp/socket"
conf.Binlog.Enable = true
conf.Binlog.IgnoreError = true
conf.Performance.RetryLimit = 20
conf.TiKVClient.CommitTimeout = "10s"
Expand All @@ -54,7 +54,7 @@ commit-timeout="41s"`)
c.Assert(conf.Load(configFile), IsNil)

// Test that the original value will not be clear by load the config file that does not contain the option.
c.Assert(conf.Binlog.BinlogSocket, Equals, "/tmp/socket")
c.Assert(conf.Binlog.Enable, Equals, true)

// Test that the value will be overwritten by the config file.
c.Assert(conf.Performance.RetryLimit, Equals, uint(10))
Expand Down
2 changes: 1 addition & 1 deletion ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func newDDL(ctx context.Context, etcdCli *clientv3.Client, store kv.Storage,
schemaSyncer: syncer,
workerVars: variable.NewSessionVars(),
}
d.workerVars.BinlogClient = binloginfo.GetPumpClient()
d.workerVars.BinlogClient = binloginfo.GetPumpsClient()

if ctxPool != nil {
supportDelRange := store.SupportDeleteRange()
Expand Down
4 changes: 2 additions & 2 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (s *session) doCommit(ctx context.Context) error {
Tp: binlog.BinlogType_Prewrite,
PrewriteValue: prewriteData,
},
Client: s.sessionVars.BinlogClient.(binlog.PumpClient),
Client: s.sessionVars.BinlogClient,
}
s.txn.SetOption(kv.BinlogInfo, info)
}
Expand Down Expand Up @@ -1202,7 +1202,7 @@ func createSession(store kv.Storage) (*session, error) {
domain.BindDomain(s, dom)
// session implements variable.GlobalVarAccessor. Bind it to ctx.
s.sessionVars.GlobalVarsAccessor = s
s.sessionVars.BinlogClient = binloginfo.GetPumpClient()
s.sessionVars.BinlogClient = binloginfo.GetPumpsClient()
s.txn.init()
return s, nil
}
Expand Down
3 changes: 2 additions & 1 deletion session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/pingcap/tidb/privilege/privileges"
"github.com/pingcap/tidb/session"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/sessionctx/binloginfo"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/store/mockstore"
"github.com/pingcap/tidb/store/mockstore/mocktikv"
Expand Down Expand Up @@ -130,7 +131,7 @@ func (s *testSessionSuite) TestForCoverage(c *C) {
tk.MustExec("admin check table t")

// Cover dirty table operations in StateTxn.
tk.Se.GetSessionVars().BinlogClient = &mockBinlogPump{}
tk.Se.GetSessionVars().BinlogClient = binloginfo.MockPumpsClient(&mockBinlogPump{})
tk.MustExec("begin")
tk.MustExec("truncate table t")
tk.MustExec("insert t values ()")
Expand Down
29 changes: 0 additions & 29 deletions session/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ import (
"github.com/pingcap/tidb/util/chunk"
log "github.com/sirupsen/logrus"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)

type domainMap struct {
Expand Down Expand Up @@ -283,33 +281,6 @@ func newStoreWithRetry(path string, maxRetries int) (kv.Storage, error) {
return s, errors.Trace(err)
}

// 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, 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
tlsConfig, err := config.GetGlobalConfig().Security.ToTLSConfig()
if err != nil {
log.Infof("error happen when setting binlog client: %s", errors.ErrorStack(err))
}

if tlsConfig != nil {
clientCon, err = grpc.Dial(binlogSocket, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)), dialerOpt)
} else {
clientCon, err = grpc.Dial(binlogSocket, grpc.WithInsecure(), dialerOpt)
}

if err != nil {
log.Infof("error happen when setting binlog client: %s", errors.ErrorStack(err))
}
return true, errors.Trace(err)
})
return clientCon, errors.Trace(err)
}

var queryStmtTable = []string{"explain", "select", "show", "execute", "describe", "desc", "admin"}

func trimSQL(sql string) string {
Expand Down
17 changes: 0 additions & 17 deletions session/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ import (
"github.com/pingcap/tidb/store/mockstore"
"github.com/pingcap/tidb/terror"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util"
"github.com/pingcap/tidb/util/auth"
"github.com/pingcap/tidb/util/logutil"
"github.com/pingcap/tidb/util/testleak"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

func TestT(t *testing.T) {
Expand Down Expand Up @@ -124,21 +122,6 @@ func (s *testMainSuite) TestRetryOpenStore(c *C) {
c.Assert(uint64(elapse), GreaterEqual, uint64(3*time.Second))
}

func (s *testMainSuite) TestRetryDialPumpClient(c *C) {
retryDialPumpClientMustFail := func(binlogSocket string, clientCon *grpc.ClientConn, maxRetries int, dialerOpt grpc.DialOption) (err error) {
return util.RunWithRetry(maxRetries, 10, func() (bool, error) {
// Assume that it'll always return an error.
return true, errors.New("must fail")
})
}
begin := time.Now()
err := retryDialPumpClientMustFail("", nil, 3, nil)
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "must fail")
elapse := time.Since(begin)
c.Assert(uint64(elapse), GreaterEqual, uint64(6*10*time.Millisecond))
}

func (s *testMainSuite) TestSysSessionPoolGoroutineLeak(c *C) {
c.Skip("make leak should check it")
// TODO: testleak package should be able to find this leak.
Expand Down
Loading

0 comments on commit 937f2bc

Please sign in to comment.