-
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
*: add system variable to turn on/off the large transaction feature #13299
Changes from all commits
9905b95
d52518d
7de9574
18520b6
6f5eb07
c3b53c6
6dcd81a
a253129
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 |
---|---|---|
|
@@ -702,6 +702,8 @@ var defaultSysVars = []*SysVar{ | |
{ScopeGlobal | ScopeSession, TiDBEnableVectorizedExpression, BoolToIntStr(DefEnableVectorizedExpression)}, | ||
{ScopeGlobal | ScopeSession, TiDBEnableFastAnalyze, BoolToIntStr(DefTiDBUseFastAnalyze)}, | ||
{ScopeGlobal | ScopeSession, TiDBSkipIsolationLevelCheck, BoolToIntStr(DefTiDBSkipIsolationLevelCheck)}, | ||
{ScopeGlobal | ScopeSession, TiDBEnableLargeTxn, BoolToIntStr(DefTiDBEnableLargeTxn)}, | ||
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 we can use a config file option, so we can deprecate it later. |
||
{ScopeGlobal | ScopeSession, TiDBLargeTxnSize, strconv.Itoa(DefTiDBLargeTxnSize)}, | ||
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 we can use a constant for it instead of a session variable. 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. Constant for |
||
/* The following variable is defined as session scope but is actually server scope. */ | ||
{ScopeSession, TiDBGeneralLog, strconv.Itoa(DefTiDBGeneralLog)}, | ||
{ScopeSession, TiDBSlowLogThreshold, strconv.Itoa(logutil.DefaultSlowThreshold)}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -489,6 +489,10 @@ func (c *twoPhaseCommitter) buildPrewriteRequest(batch batchKeys, txnSize uint64 | |
isPessimisticLock[i] = true | ||
} | ||
} | ||
var minCommitTS uint64 | ||
if c.txn.IsLargeTxn() { | ||
minCommitTS = c.startTS + 1 | ||
} | ||
req := &pb.PrewriteRequest{ | ||
Mutations: mutations, | ||
PrimaryLock: c.primary(), | ||
|
@@ -497,11 +501,12 @@ func (c *twoPhaseCommitter) buildPrewriteRequest(batch batchKeys, txnSize uint64 | |
IsPessimisticLock: isPessimisticLock, | ||
ForUpdateTs: c.forUpdateTS, | ||
TxnSize: txnSize, | ||
MinCommitTs: minCommitTS, | ||
} | ||
return tikvrpc.NewRequest(tikvrpc.CmdPrewrite, req, pb.Context{Priority: c.priority, SyncLog: c.syncLog}) | ||
} | ||
|
||
func (actionPrewrite) handleSingleBatch(c *twoPhaseCommitter, bo *Backoffer, batch batchKeys) error { | ||
func (action actionPrewrite) handleSingleBatch(c *twoPhaseCommitter, bo *Backoffer, batch batchKeys) error { | ||
txnSize := uint64(c.regionTxnSize[batch.region.id]) | ||
// When we retry because of a region miss, we don't know the transaction size. We set the transaction size here | ||
// to MaxUint64 to avoid unexpected "resolve lock lite". | ||
|
@@ -510,6 +515,14 @@ func (actionPrewrite) handleSingleBatch(c *twoPhaseCommitter, bo *Backoffer, bat | |
} | ||
|
||
req := c.buildPrewriteRequest(batch, txnSize) | ||
if x := bo.ctx.Value("checkLargeTxnEnable"); x != nil { | ||
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. This has some extra cost, can we avoid it? 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 tried failpoint but the concurrent test is a problem. 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. The test doesn't make much sense. |
||
codeRun := x.(*bool) | ||
*codeRun = true | ||
if req.Prewrite().MinCommitTs == 0 { | ||
return errors.New("minCommitTS should greater then 0 in the large txn") | ||
} | ||
} | ||
|
||
for { | ||
resp, err := c.store.SendReq(bo, req, batch.region, readTimeoutShort) | ||
if err != nil { | ||
|
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.
maybe we need to add
TiDBLargeTxnSize
set value check inValidateSetSystemVar