Skip to content

Commit

Permalink
Merge branch 'master' into master-3.0-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lovewin99 authored Jul 19, 2019
2 parents 563c36a + ddb6132 commit 1842158
Show file tree
Hide file tree
Showing 65 changed files with 1,814 additions and 1,021 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[![GitHub release date](https://img.shields.io/github/release-date/pingcap/tidb.svg)](https://github.com/pingcap/tidb/releases)
[![CircleCI Status](https://circleci.com/gh/pingcap/tidb.svg?style=shield)](https://circleci.com/gh/pingcap/tidb)
[![Coverage Status](https://codecov.io/gh/pingcap/tidb/branch/master/graph/badge.svg)](https://codecov.io/gh/pingcap/tidb)
[![GoDoc](https://img.shields.io/badge/Godoc-reference-blue.svg)](https://godoc.org/github.com/pingcap/tidb)

- [**Stack Overflow**](https://stackoverflow.com/questions/tagged/tidb)
- Community [**Slack Channel**](https://pingcap.com/tidbslack/)
Expand Down
2 changes: 1 addition & 1 deletion config/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ treat-old-version-utf8-as-utf8mb4 = true
# enable-table-lock is used to control table lock feature. Default is false, indicate the table lock feature is disabled.
enable-table-lock = false

# delay-clean-table-lock is used to control whether delayed-release the table lock in the abnormal situation. (Milliseconds)
# delay-clean-table-lock is used to control the time (Milliseconds) of delay before unlock the table in the abnormal situation.
delay-clean-table-lock = 0

[log]
Expand Down
3 changes: 2 additions & 1 deletion executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ func (a *ExecStmt) logAudit() {
audit := plugin.DeclareAuditManifest(p.Manifest)
if audit.OnGeneralEvent != nil {
cmd := mysql.Command2Str[byte(atomic.LoadUint32(&a.Ctx.GetSessionVars().CommandValue))]
audit.OnGeneralEvent(context.Background(), sessVars, plugin.Log, cmd)
ctx := context.WithValue(context.Background(), plugin.ExecStartTimeCtxKey, a.StartTime)
audit.OnGeneralEvent(ctx, sessVars, plugin.Log, cmd)
}
return nil
})
Expand Down
15 changes: 6 additions & 9 deletions executor/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,12 +620,9 @@ func (e *AnalyzeFastExec) getSampRegionsRowCount(bo *tikv.Backoffer, needRebuild
if !ok {
return
}
req := &tikvrpc.Request{
Type: tikvrpc.CmdDebugGetRegionProperties,
DebugGetRegionProperties: &debugpb.GetRegionPropertiesRequest{
RegionId: loc.Region.GetID(),
},
}
req := tikvrpc.NewRequest(tikvrpc.CmdDebugGetRegionProperties, &debugpb.GetRegionPropertiesRequest{
RegionId: loc.Region.GetID(),
})
var resp *tikvrpc.Response
var rpcCtx *tikv.RPCContext
rpcCtx, *err = e.cache.GetRPCContext(bo, loc.Region)
Expand All @@ -638,11 +635,11 @@ func (e *AnalyzeFastExec) getSampRegionsRowCount(bo *tikv.Backoffer, needRebuild
if *err != nil {
return
}
if resp.DebugGetRegionProperties == nil || len(resp.DebugGetRegionProperties.Props) == 0 {
if resp.Resp == nil || len(resp.Resp.(*debugpb.GetRegionPropertiesResponse).Props) == 0 {
*needRebuild = true
return
}
for _, prop := range resp.DebugGetRegionProperties.Props {
for _, prop := range resp.Resp.(*debugpb.GetRegionPropertiesResponse).Props {
if prop.Name == "mvcc.num_rows" {
var cnt uint64
cnt, *err = strconv.ParseUint(prop.Value, 10, 64)
Expand Down Expand Up @@ -1002,7 +999,7 @@ func (e *AnalyzeFastExec) buildColumnStats(ID int64, collector *statistics.Sampl
collector.NullCount++
continue
}
bytes, err := tablecodec.EncodeValue(e.ctx.GetSessionVars().StmtCtx, sample.Value)
bytes, err := tablecodec.EncodeValue(e.ctx.GetSessionVars().StmtCtx, nil, sample.Value)
if err != nil {
return nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion executor/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func (c *regionProperityClient) SendRequest(ctx context.Context, addr string, re
defer c.mu.Unlock()
c.mu.count++
// Mock failure once.
if req.DebugGetRegionProperties.RegionId == c.mu.regionID {
if req.DebugGetRegionProperties().RegionId == c.mu.regionID {
c.mu.regionID = 0
return &tikvrpc.Response{}, nil
}
Expand Down
44 changes: 32 additions & 12 deletions executor/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,27 +187,47 @@ func newChecksumContext(db *model.DBInfo, table *model.TableInfo, startTs uint64
}

func (c *checksumContext) BuildRequests(ctx sessionctx.Context) ([]*kv.Request, error) {
reqs := make([]*kv.Request, 0, len(c.TableInfo.Indices)+1)
req, err := c.buildTableRequest(ctx)
if err != nil {
var partDefs []model.PartitionDefinition
if part := c.TableInfo.Partition; part != nil {
partDefs = part.Definitions
}

reqs := make([]*kv.Request, 0, (len(c.TableInfo.Indices)+1)*(len(partDefs)+1))
if err := c.appendRequest(ctx, c.TableInfo.ID, &reqs); err != nil {
return nil, err
}
reqs = append(reqs, req)

for _, partDef := range partDefs {
if err := c.appendRequest(ctx, partDef.ID, &reqs); err != nil {
return nil, err
}
}

return reqs, nil
}

func (c *checksumContext) appendRequest(ctx sessionctx.Context, tableID int64, reqs *[]*kv.Request) error {
req, err := c.buildTableRequest(ctx, tableID)
if err != nil {
return err
}

*reqs = append(*reqs, req)
for _, indexInfo := range c.TableInfo.Indices {
if indexInfo.State != model.StatePublic {
continue
}
req, err = c.buildIndexRequest(ctx, indexInfo)
req, err = c.buildIndexRequest(ctx, tableID, indexInfo)
if err != nil {
return nil, err
return err
}
reqs = append(reqs, req)
*reqs = append(*reqs, req)
}

return reqs, nil
return nil
}

func (c *checksumContext) buildTableRequest(ctx sessionctx.Context) (*kv.Request, error) {
func (c *checksumContext) buildTableRequest(ctx sessionctx.Context, tableID int64) (*kv.Request, error) {
checksum := &tipb.ChecksumRequest{
StartTs: c.StartTs,
ScanOn: tipb.ChecksumScanOn_Table,
Expand All @@ -217,13 +237,13 @@ func (c *checksumContext) buildTableRequest(ctx sessionctx.Context) (*kv.Request
ranges := ranger.FullIntRange(false)

var builder distsql.RequestBuilder
return builder.SetTableRanges(c.TableInfo.ID, ranges, nil).
return builder.SetTableRanges(tableID, ranges, nil).
SetChecksumRequest(checksum).
SetConcurrency(ctx.GetSessionVars().DistSQLScanConcurrency).
Build()
}

func (c *checksumContext) buildIndexRequest(ctx sessionctx.Context, indexInfo *model.IndexInfo) (*kv.Request, error) {
func (c *checksumContext) buildIndexRequest(ctx sessionctx.Context, tableID int64, indexInfo *model.IndexInfo) (*kv.Request, error) {
checksum := &tipb.ChecksumRequest{
StartTs: c.StartTs,
ScanOn: tipb.ChecksumScanOn_Index,
Expand All @@ -233,7 +253,7 @@ func (c *checksumContext) buildIndexRequest(ctx sessionctx.Context, indexInfo *m
ranges := ranger.FullRange()

var builder distsql.RequestBuilder
return builder.SetIndexRanges(ctx.GetSessionVars().StmtCtx, c.TableInfo.ID, indexInfo.ID, ranges).
return builder.SetIndexRanges(ctx.GetSessionVars().StmtCtx, tableID, indexInfo.ID, ranges).
SetChecksumRequest(checksum).
SetConcurrency(ctx.GetSessionVars().DistSQLScanConcurrency).
Build()
Expand Down
Loading

0 comments on commit 1842158

Please sign in to comment.