Skip to content

Commit b756fcd

Browse files
committed
polish use txn file
Signed-off-by: Ping Yu <[email protected]>
1 parent d3a510a commit b756fcd

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

kv/variables.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ type Variables struct {
5050
// When its value is not 0, it's killed, the value indicates concrete reason.
5151
Killed *uint32
5252

53-
// TxnFileMinMutationSize specifies the minimum size of mutations to use file-based txn.
54-
// <0: disabled.
55-
// 0: use defalut value specified by config item TiKVClient.TxnFileMinMutationSize.
56-
// >0: use the specified value.
57-
TxnFileMinMutationSize int64
53+
// EnableTxnFile specifies whether file-based txn is enabled.
54+
EnableTxnFile bool
5855
}
5956

6057
// NewVariables create a new Variables instance with default values.
@@ -63,6 +60,7 @@ func NewVariables(killed *uint32) *Variables {
6360
BackoffLockFast: DefBackoffLockFast,
6461
BackOffWeight: DefBackOffWeight,
6562
Killed: killed,
63+
EnableTxnFile: true,
6664
}
6765
}
6866

txnkv/transaction/txn_file.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -807,17 +807,16 @@ func (c *twoPhaseCommitter) buildTxnFiles(bo *retry.Backoffer, mutations Committ
807807
}
808808

809809
func (c *twoPhaseCommitter) useTxnFile() bool {
810-
if c.txn == nil || c.txn.isPessimistic || c.txn.isInternal() ||
811-
c.txn.vars.TxnFileMinMutationSize < 0 {
810+
if c.txn == nil || !c.txn.vars.EnableTxnFile {
812811
return false
813812
}
814813
conf := config.GetGlobalConfig()
815-
minMutationSize := uint64(c.txn.vars.TxnFileMinMutationSize)
816-
if minMutationSize == 0 {
817-
minMutationSize = conf.TiKVClient.TxnFileMinMutationSize
818-
}
819-
return len(conf.TiKVClient.TxnChunkWriterAddr) > 0 &&
820-
uint64(c.txn.GetMemBuffer().Size()) >= minMutationSize
814+
// Don't use txn file for internal request to avoid affect system tables or metadata before it is stable enough.
815+
// TODO: use txn file for internal TTL & DDL tasks.
816+
return !c.txn.isPessimistic &&
817+
!c.txn.isInternal() &&
818+
len(conf.TiKVClient.TxnChunkWriterAddr) > 0 &&
819+
uint64(c.txn.GetMemBuffer().Size()) >= conf.TiKVClient.TxnFileMinMutationSize
821820
}
822821

823822
func (c *twoPhaseCommitter) preSplitTxnFileRegions(bo *retry.Backoffer) error {

0 commit comments

Comments
 (0)