Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: add missing update table delta for TxnCtx #20982

Merged
merged 20 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9cd935a
executor: add missing update table delta for TxnCtx
blacktear23 Nov 11, 2020
d509a28
executor: fix typo
blacktear23 Nov 11, 2020
cb2ea6a
executor: fix for test
blacktear23 Nov 11, 2020
d4a45ec
Merge branch 'master' into issue-20975
blacktear23 Nov 11, 2020
c62a393
executor: fix missing UpdateDeltaForTable for SelectLockExec
blacktear23 Nov 11, 2020
4079141
Merge branch 'issue-20975' of github.com:blacktear23/tidb into issue-…
blacktear23 Nov 11, 2020
9627f21
executor: refactor, move codes
blacktear23 Nov 11, 2020
c0f805a
Merge branch 'master' into issue-20975
AilinKid Nov 11, 2020
ec32bc4
executor: fix for point get and batch point get
blacktear23 Nov 11, 2020
fee7a5d
Merge branch 'issue-20975' of github.com:blacktear23/tidb into issue-…
blacktear23 Nov 11, 2020
a22e309
executor: refactor and add more unit test;
blacktear23 Nov 12, 2020
27b2e61
executor: Refactor, make updateDeltaForTableID call once after initia…
blacktear23 Nov 13, 2020
1e2e73a
Merge branch 'master' into issue-20975
blacktear23 Nov 13, 2020
f191c97
Merge branch 'master' into issue-20975
blacktear23 Nov 16, 2020
8c3ae1b
sessionctx: add lock for write TableDeltaMap
blacktear23 Nov 16, 2020
6124bf9
Merge branch 'issue-20975' of github.com:blacktear23/tidb into issue-…
blacktear23 Nov 16, 2020
dee9e78
Merge branch 'master' into issue-20975
blacktear23 Nov 17, 2020
7073ddd
executor: add partition table tests for issue 20975
blacktear23 Nov 18, 2020
bd78ed7
Merge branch 'master' into issue-20975
blacktear23 Nov 18, 2020
94c5206
Merge branch 'master' into issue-20975
blacktear23 Nov 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions executor/batch_point_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ func (e *BatchPointGetExec) Next(ctx context.Context, req *chunk.Chunk) error {
}
}

if e.lock {
e.updateDeltaForTableID(e.tblInfo.ID)
for _, pid := range e.physIDs {
e.updateDeltaForTableID(pid)
}
}

if e.index >= len(e.values) {
return nil
}
Expand Down
18 changes: 18 additions & 0 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ func (e *baseExecutor) Next(ctx context.Context, req *chunk.Chunk) error {
return nil
}

func (e *baseExecutor) updateDeltaForTableID(id int64) {
txnCtx := e.ctx.GetSessionVars().TxnCtx
udpp := e.ctx.GetSessionVars().UseDynamicPartitionPrune()
txnCtx.UpdateDeltaForTable(id, id, 0, 0, nil, udpp)
}

func newBaseExecutor(ctx sessionctx.Context, schema *expression.Schema, id int, children ...Executor) baseExecutor {
e := baseExecutor{
children: children,
Expand Down Expand Up @@ -943,6 +949,18 @@ func (e *SelectLockExec) Next(ctx context.Context, req *chunk.Chunk) error {
lockWaitTime = int64(e.Lock.WaitSec) * 1000
}

if len(e.tblID2Handle) > 0 {
for id := range e.tblID2Handle {
e.updateDeltaForTableID(id)
}
}
if len(e.partitionedTable) > 0 {
for _, p := range e.partitionedTable {
pid := p.Meta().ID
e.updateDeltaForTableID(pid)
}
}

return doLockKeys(ctx, e.ctx, newLockCtx(e.ctx.GetSessionVars(), lockWaitTime), e.keys...)
}

Expand Down
3 changes: 3 additions & 0 deletions executor/point_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ func (e *PointGetExecutor) Next(ctx context.Context, req *chunk.Chunk) error {
} else {
tblID = e.tblInfo.ID
}
if e.lock {
e.updateDeltaForTableID(tblID)
}
if e.idxInfo != nil {
if isCommonHandleRead(e.tblInfo, e.idxInfo) {
handleBytes, err := EncodeUniqueIndexValuesForKey(e.ctx, e.tblInfo, e.idxInfo, e.idxVals)
Expand Down
12 changes: 12 additions & 0 deletions executor/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ func updateRecord(ctx context.Context, sctx sessionctx.Context, h kv.Handle, old
txnCtx := sctx.GetSessionVars().TxnCtx
if txnCtx.IsPessimistic {
txnCtx.AddUnchangedRowKey(unchangedRowKey)
// Update DeltaForTable
colSize := make(map[int64]int64, len(newData))
for id, col := range t.Cols() {
_, err := codec.EstimateValueSize(sc, newData[id])
if err != nil {
continue
}
// Nothing changed so size should be 0
colSize[col.ID] = 0
}
udpp := sctx.GetSessionVars().UseDynamicPartitionPrune()
txnCtx.UpdateDeltaForTable(t.Meta().ID, physicalID, 0, 0, colSize, udpp)
}
return false, nil
}
Expand Down