Skip to content

Commit

Permalink
Merge branch 'master' into pr0
Browse files Browse the repository at this point in the history
  • Loading branch information
js00070 committed Oct 23, 2019
2 parents 6c1a18f + 5d5497b commit 267ff56
Show file tree
Hide file tree
Showing 64 changed files with 843 additions and 775 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export PATH := $(path_to_add):$(PATH)
GO := GO111MODULE=on go
GOBUILD := $(GO) build $(BUILD_FLAG) -tags codes -trimpath
GOBUILDCOVERAGE := GOPATH=$(GOPATH) cd tidb-server; $(GO) test -coverpkg="../..." -c .
GOTEST := $(GO) test -p 4
GOTEST := $(GO) test -p 8
OVERALLS := GO111MODULE=on overalls

ARCH := "`uname -s`"
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ var defaultConf = Config{
Reporter: OpenTracingReporter{},
},
TiKVClient: TiKVClient{
GrpcConnectionCount: 16,
GrpcConnectionCount: 4,
GrpcKeepAliveTime: 10,
GrpcKeepAliveTimeout: 3,
CommitTimeout: "41s",
Expand Down
2 changes: 1 addition & 1 deletion config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ local-agent-host-port = ""

[tikv-client]
# Max gRPC connections that will be established with each tikv-server.
grpc-connection-count = 16
grpc-connection-count = 4

# After a duration of this time in seconds if the client doesn't see any activity it pings
# the server to see if the transport is still alive.
Expand Down
2 changes: 1 addition & 1 deletion domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func (do *Domain) topNSlowQueryLoop() {
func (do *Domain) infoSyncerKeeper() {
defer do.wg.Done()
defer recoverInDomain("infoSyncerKeeper", false)
ticker := time.NewTicker(time.Second * time.Duration(infosync.InfoSessionTTL) / 2)
ticker := time.NewTicker(infosync.ReportInterval)
defer ticker.Stop()
for {
select {
Expand Down
9 changes: 5 additions & 4 deletions domain/infosync/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ const (
// ServerMinStartTSPath store the server min start timestamp.
ServerMinStartTSPath = "/tidb/server/minstartts"
// keyOpDefaultRetryCnt is the default retry count for etcd store.
keyOpDefaultRetryCnt = 2
keyOpDefaultRetryCnt = 5
// keyOpDefaultTimeout is the default time out for etcd store.
keyOpDefaultTimeout = 1 * time.Second
// InfoSessionTTL is the ETCD session's TTL in seconds.
InfoSessionTTL = 10 * 60
// ReportInterval is interval of infoSyncerKeeper reporting min startTS.
ReportInterval = 30 * time.Second
)

// InfoSessionTTL is the etcd session's TTL in seconds. It's exported for testing.
var InfoSessionTTL = 1 * 60

// InfoSyncer stores server info to etcd when the tidb-server starts and delete when tidb-server shuts down.
type InfoSyncer struct {
etcdCli *clientv3.Client
Expand Down
2 changes: 1 addition & 1 deletion executor/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/pingcap/tidb/util/testkit"
)

func (s *testSuiteP1) TestQueryTime(c *C) {
func (s *testSuiteP2) TestQueryTime(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")

Expand Down
14 changes: 7 additions & 7 deletions executor/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *testSuite1) TestAdminCheckIndexRange(c *C) {
result.Check(testkit.Rows("-1 hi 4", "2 cd 2"))
}

func (s *testSuite2) TestAdminRecoverIndex(c *C) {
func (s *testSuite5) TestAdminRecoverIndex(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
Expand Down Expand Up @@ -158,7 +158,7 @@ func (s *testSuite2) TestAdminRecoverIndex(c *C) {
tk.MustExec("admin check table admin_test")
}

func (s *testSuite2) TestAdminRecoverIndex1(c *C) {
func (s *testSuite5) TestAdminRecoverIndex1(c *C) {
tk := testkit.NewTestKit(c, s.store)
s.ctx = mock.NewContext()
s.ctx.Store = s.store
Expand Down Expand Up @@ -209,7 +209,7 @@ func (s *testSuite2) TestAdminRecoverIndex1(c *C) {
tk.MustExec("admin check index admin_test `primary`")
}

func (s *testSuite2) TestAdminCleanupIndex(c *C) {
func (s *testSuite5) TestAdminCleanupIndex(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
Expand Down Expand Up @@ -288,7 +288,7 @@ func (s *testSuite2) TestAdminCleanupIndex(c *C) {
tk.MustExec("admin check table admin_test")
}

func (s *testSuite2) TestAdminCleanupIndexPKNotHandle(c *C) {
func (s *testSuite5) TestAdminCleanupIndexPKNotHandle(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
Expand Down Expand Up @@ -336,7 +336,7 @@ func (s *testSuite2) TestAdminCleanupIndexPKNotHandle(c *C) {
tk.MustExec("admin check table admin_test")
}

func (s *testSuite2) TestAdminCleanupIndexMore(c *C) {
func (s *testSuite5) TestAdminCleanupIndexMore(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
Expand Down Expand Up @@ -399,7 +399,7 @@ func (s *testSuite2) TestAdminCleanupIndexMore(c *C) {
tk.MustExec("admin check table admin_test")
}

func (s *testSuite2) TestAdminCheckTableFailed(c *C) {
func (s *testSuite5) TestAdminCheckTableFailed(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
Expand Down Expand Up @@ -631,7 +631,7 @@ func (s *testSuite1) TestAdminCheckPrimaryIndex(c *C) {
tk.MustExec("admin check index t idx;")
}

func (s *testSuite2) TestAdminCheckWithSnapshot(c *C) {
func (s *testSuite5) TestAdminCheckWithSnapshot(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_t_s")
Expand Down
5 changes: 3 additions & 2 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,9 @@ func (b *executorBuilder) buildUnionScanFromReader(reader Executor, v *plannerco
// GetDirtyDB() is safe here. If this table has been modified in the transaction, non-nil DirtyTable
// can be found in DirtyDB now, so GetDirtyTable is safe; if this table has not been modified in the
// transaction, empty DirtyTable would be inserted into DirtyDB, it does not matter when multiple
// goroutines write empty DirtyTable to DirtyDB for this table concurrently. Thus we don't use lock
// to synchronize here.
// goroutines write empty DirtyTable to DirtyDB for this table concurrently. Although the DirtyDB looks
// safe for data race in all the cases, the map of golang will throw panic when it's accessed in parallel.
// So we lock it when getting dirty table.
physicalTableID := getPhysicalTableID(x.table)
us.dirty = GetDirtyDB(b.ctx).GetDirtyTable(physicalTableID)
us.conditions = v.Conditions
Expand Down
50 changes: 25 additions & 25 deletions executor/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"github.com/pingcap/tidb/util/testutil"
)

func (s *testSuite3) TestTruncateTable(c *C) {
func (s *testSuite6) TestTruncateTable(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec(`drop table if exists truncate_test;`)
Expand All @@ -59,7 +59,7 @@ func (s *testSuite3) TestTruncateTable(c *C) {
// 1. Execute the SQL of "begin";
// 2. A SQL that will fail to execute;
// 3. Execute DDL.
func (s *testSuite3) TestInTxnExecDDLFail(c *C) {
func (s *testSuite6) TestInTxnExecDDLFail(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table t (i int key);")
Expand All @@ -72,7 +72,7 @@ func (s *testSuite3) TestInTxnExecDDLFail(c *C) {
result.Check(testkit.Rows("1"))
}

func (s *testSuite3) TestCreateTable(c *C) {
func (s *testSuite6) TestCreateTable(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
// Test create an exist database
Expand Down Expand Up @@ -173,7 +173,7 @@ func (s *testSuite3) TestCreateTable(c *C) {
r.Check(testkit.Rows("1000 aa"))
}

func (s *testSuite3) TestCreateView(c *C) {
func (s *testSuite6) TestCreateView(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
//create an source table
Expand Down Expand Up @@ -226,7 +226,7 @@ func (s *testSuite3) TestCreateView(c *C) {
tk.MustExec("execute stmt")
}

func (s *testSuite3) TestCreateDropDatabase(c *C) {
func (s *testSuite6) TestCreateDropDatabase(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("create database if not exists drop_test;")
tk.MustExec("drop database if exists drop_test;")
Expand All @@ -242,7 +242,7 @@ func (s *testSuite3) TestCreateDropDatabase(c *C) {
c.Assert(err, NotNil)
}

func (s *testSuite3) TestCreateDropTable(c *C) {
func (s *testSuite6) TestCreateDropTable(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table if not exists drop_test (a int)")
Expand All @@ -254,7 +254,7 @@ func (s *testSuite3) TestCreateDropTable(c *C) {
c.Assert(err, NotNil)
}

func (s *testSuite3) TestCreateDropView(c *C) {
func (s *testSuite6) TestCreateDropView(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create or replace view drop_test as select 1,2")
Expand All @@ -272,7 +272,7 @@ func (s *testSuite3) TestCreateDropView(c *C) {
c.Assert(err.Error(), Equals, "[ddl:1347]'test.t_v' is not VIEW")
}

func (s *testSuite3) TestCreateDropIndex(c *C) {
func (s *testSuite6) TestCreateDropIndex(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table if not exists drop_test (a int)")
Expand All @@ -281,7 +281,7 @@ func (s *testSuite3) TestCreateDropIndex(c *C) {
tk.MustExec("drop table drop_test")
}

func (s *testSuite3) TestAlterTableAddColumn(c *C) {
func (s *testSuite6) TestAlterTableAddColumn(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table if not exists alter_test (c1 int)")
Expand All @@ -306,7 +306,7 @@ func (s *testSuite3) TestAlterTableAddColumn(c *C) {
tk.MustExec("drop view alter_view")
}

func (s *testSuite3) TestAddNotNullColumnNoDefault(c *C) {
func (s *testSuite6) TestAddNotNullColumnNoDefault(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("create table nn (c1 int)")
Expand All @@ -327,7 +327,7 @@ func (s *testSuite3) TestAddNotNullColumnNoDefault(c *C) {
tk.MustQuery("select * from nn").Check(testkit.Rows("1 0", "2 0", "3 0"))
}

func (s *testSuite3) TestAlterTableModifyColumn(c *C) {
func (s *testSuite6) TestAlterTableModifyColumn(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists mc")
Expand Down Expand Up @@ -392,7 +392,7 @@ func (s *testSuite3) TestAlterTableModifyColumn(c *C) {

}

func (s *testSuite3) TestDefaultDBAfterDropCurDB(c *C) {
func (s *testSuite6) TestDefaultDBAfterDropCurDB(c *C) {
tk := testkit.NewTestKit(c, s.store)

testSQL := `create database if not exists test_db CHARACTER SET latin1 COLLATE latin1_swedish_ci;`
Expand All @@ -411,7 +411,7 @@ func (s *testSuite3) TestDefaultDBAfterDropCurDB(c *C) {
tk.MustQuery(`select @@collation_database;`).Check(testkit.Rows("utf8_unicode_ci"))
}

func (s *testSuite3) TestRenameTable(c *C) {
func (s *testSuite6) TestRenameTable(c *C) {
c.Assert(failpoint.Enable("github.com/pingcap/tidb/meta/autoid/mockAutoIDChange", `return(true)`), IsNil)
defer func() {
c.Assert(failpoint.Disable("github.com/pingcap/tidb/meta/autoid/mockAutoIDChange"), IsNil)
Expand Down Expand Up @@ -471,7 +471,7 @@ func (s *testSuite3) TestRenameTable(c *C) {
tk.MustExec("drop database rename2")
}

func (s *testSuite3) TestColumnCharsetAndCollate(c *C) {
func (s *testSuite6) TestColumnCharsetAndCollate(c *C) {
tk := testkit.NewTestKit(c, s.store)
dbName := "col_charset_collate"
tk.MustExec("create database " + dbName)
Expand Down Expand Up @@ -555,7 +555,7 @@ func (s *testSuite3) TestColumnCharsetAndCollate(c *C) {
tk.MustExec("drop database " + dbName)
}

func (s *testSuite3) TestTooLargeIdentifierLength(c *C) {
func (s *testSuite6) TestTooLargeIdentifierLength(c *C) {
tk := testkit.NewTestKit(c, s.store)

// for database.
Expand Down Expand Up @@ -590,7 +590,7 @@ func (s *testSuite3) TestTooLargeIdentifierLength(c *C) {
c.Assert(err.Error(), Equals, fmt.Sprintf("[ddl:1059]Identifier name '%s' is too long", indexName2))
}

func (s *testSuite3) TestShardRowIDBits(c *C) {
func (s *testSuite6) TestShardRowIDBits(c *C) {
tk := testkit.NewTestKit(c, s.store)

tk.MustExec("use test")
Expand Down Expand Up @@ -703,7 +703,7 @@ func (s *testSuite3) TestShardRowIDBits(c *C) {
c.Assert(autoid.ErrAutoincReadFailed.Equal(err), IsTrue, Commentf("err:%v", err))
}

func (s *testSuite3) TestMaxHandleAddIndex(c *C) {
func (s *testSuite6) TestMaxHandleAddIndex(c *C) {
tk := testkit.NewTestKit(c, s.store)

tk.MustExec("use test")
Expand All @@ -720,7 +720,7 @@ func (s *testSuite3) TestMaxHandleAddIndex(c *C) {
tk.MustExec("admin check table t1")
}

func (s *testSuite3) TestSetDDLReorgWorkerCnt(c *C) {
func (s *testSuite6) TestSetDDLReorgWorkerCnt(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
err := ddlutil.LoadDDLReorgVars(tk.Se)
Expand Down Expand Up @@ -754,7 +754,7 @@ func (s *testSuite3) TestSetDDLReorgWorkerCnt(c *C) {
res.Check(testkit.Rows("100"))
}

func (s *testSuite3) TestSetDDLReorgBatchSize(c *C) {
func (s *testSuite6) TestSetDDLReorgBatchSize(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
err := ddlutil.LoadDDLReorgVars(tk.Se)
Expand Down Expand Up @@ -791,7 +791,7 @@ func (s *testSuite3) TestSetDDLReorgBatchSize(c *C) {
res.Check(testkit.Rows("1000"))
}

func (s *testSuite3) TestIllegalFunctionCall4GeneratedColumns(c *C) {
func (s *testSuite6) TestIllegalFunctionCall4GeneratedColumns(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
// Test create an exist database
Expand Down Expand Up @@ -836,7 +836,7 @@ func (s *testSuite3) TestIllegalFunctionCall4GeneratedColumns(c *C) {
c.Assert(err.Error(), Equals, ddl.ErrGeneratedColumnFunctionIsNotAllowed.GenWithStackByArgs("cc").Error())
}

func (s *testSuite3) TestGeneratedColumnRelatedDDL(c *C) {
func (s *testSuite6) TestGeneratedColumnRelatedDDL(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
// Test create an exist database
Expand All @@ -862,7 +862,7 @@ func (s *testSuite3) TestGeneratedColumnRelatedDDL(c *C) {
tk.MustExec("drop table t1;")
}

func (s *testSuite3) TestSetDDLErrorCountLimit(c *C) {
func (s *testSuite6) TestSetDDLErrorCountLimit(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
err := ddlutil.LoadDDLVars(tk.Se)
Expand Down Expand Up @@ -891,7 +891,7 @@ func (s *testSuite3) TestSetDDLErrorCountLimit(c *C) {

// Test issue #9205, fix the precision problem for time type default values
// See https://github.com/pingcap/tidb/issues/9205 for details
func (s *testSuite3) TestIssue9205(c *C) {
func (s *testSuite6) TestIssue9205(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec(`drop table if exists t;`)
Expand Down Expand Up @@ -930,7 +930,7 @@ func (s *testSuite3) TestIssue9205(c *C) {
))
}

func (s *testSuite3) TestCheckDefaultFsp(c *C) {
func (s *testSuite6) TestCheckDefaultFsp(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec(`drop table if exists t;`)
Expand Down Expand Up @@ -970,7 +970,7 @@ func (s *testSuite3) TestCheckDefaultFsp(c *C) {
c.Assert(err.Error(), Equals, "[ddl:1067]Invalid default value for 'tttt'")
}

func (s *testSuite3) TestTimestampMinDefaultValue(c *C) {
func (s *testSuite6) TestTimestampMinDefaultValue(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists tdv;")
Expand Down
Loading

0 comments on commit 267ff56

Please sign in to comment.