-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ddl: avoid commit conflicts when updating/delete from mysql.tidb_ddl_reorg. #38738
Changes from 73 commits
e2e3b5c
eb69cab
841b5fa
51174b0
cbd0981
17c28f3
65c84d9
f432276
31a8165
93ec6ce
f392e91
270a640
c56449d
f8b2d62
4de5504
2015061
d673abc
f9ed823
9672513
4f667f9
7908ee8
88a891e
9f9a4ca
b7fda44
64f2925
a713d57
d968d4e
6a0e0c3
e13c332
fe65fa9
5614b30
ab0087a
6186476
7257bd0
6eb65d3
143f889
3f6dcc5
5473f2f
250717d
641f89b
eda7cc9
0598ed7
13c3d56
54e0b24
1d55510
cf478ea
ee44b65
0ed2f47
8cee684
0164c1a
d8483ab
d05b1af
10cddb7
751a54a
83894b3
d0340d8
7f18011
0db4bb3
5153f09
86bc31a
445d84c
79e52b9
b0b5084
c35d853
f1543d5
bfb5f52
0ec2512
78281b3
7214e31
f9983e9
51bacd3
389ad4d
f04df45
076be10
022d951
43b6946
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -806,7 +806,13 @@ func doReorgWorkForModifyColumnMultiSchema(w *worker, d *ddlCtx, t *meta.Meta, j | |
func doReorgWorkForModifyColumn(w *worker, d *ddlCtx, t *meta.Meta, job *model.Job, tbl table.Table, | ||
oldCol, changingCol *model.ColumnInfo, changingIdxs []*model.IndexInfo) (done bool, ver int64, err error) { | ||
job.ReorgMeta.ReorgTp = model.ReorgTypeTxn | ||
rh := newReorgHandler(t, w.sess) | ||
sctx, err1 := w.sessPool.get() | ||
if err1 != nil { | ||
err = errors.Trace(err1) | ||
return | ||
} | ||
defer w.sessPool.put(sctx) | ||
rh := newReorgHandler(newSession(sctx)) | ||
dbInfo, err := t.GetDatabase(job.SchemaID) | ||
if err != nil { | ||
return false, ver, errors.Trace(err) | ||
|
@@ -1291,8 +1297,8 @@ func (w *updateColumnWorker) getRowRecord(handle kv.Handle, recordKey []byte, ra | |
if err != nil { | ||
return w.reformatErrors(err) | ||
} | ||
if w.sessCtx.GetSessionVars().StmtCtx.GetWarnings() != nil && len(w.sessCtx.GetSessionVars().StmtCtx.GetWarnings()) != 0 { | ||
warn := w.sessCtx.GetSessionVars().StmtCtx.GetWarnings() | ||
warn := w.sessCtx.GetSessionVars().StmtCtx.GetWarnings() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since GetWarnings takes a mutex and copies the data, it is better to only do it once instead of up to three times. |
||
if len(warn) != 0 { | ||
//nolint:forcetypeassert | ||
recordWarning = errors.Cause(w.reformatErrors(warn[0].Err)).(*terror.Error) | ||
} | ||
|
@@ -1376,8 +1382,9 @@ func (w *updateColumnWorker) BackfillDataInTxn(handleRange reorgBackfillTask) (t | |
taskCtx.nextKey = nextKey | ||
taskCtx.done = taskDone | ||
|
||
warningsMap := make(map[errors.ErrorID]*terror.Error, len(rowRecords)) | ||
warningsCountMap := make(map[errors.ErrorID]int64, len(rowRecords)) | ||
// Optimize for few warnings! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is better to avoid reserving too much memory that may not be needed. |
||
warningsMap := make(map[errors.ErrorID]*terror.Error, 2) | ||
warningsCountMap := make(map[errors.ErrorID]int64, 2) | ||
for _, rowRecord := range rowRecords { | ||
taskCtx.scanCount++ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the
updateDDLReorgStartHandle
fromrunReorgJob
on timeout and added it here instead.It may change the number of transactions, but I think it is better to always save the state here, right after each batch is done (also still ignoring the error).