Skip to content

Commit

Permalink
Merge branch 'master' into privilege
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Apr 29, 2021
2 parents 772180e + 64938b8 commit 830b6d6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type Meta struct {
// If the current Meta needs to handle a job, jobListKey is the type of the job's list.
func NewMeta(txn kv.Transaction, jobListKeys ...JobListKeyType) *Meta {
txn.SetOption(tikvstore.Priority, kv.PriorityHigh)
txn.SetOption(tikvstore.SyncLog, true)
txn.SetOption(tikvstore.SyncLog, struct{}{})
t := structure.NewStructure(txn, txn, mMetaPrefix)
listKey := DefaultJobListKey
if len(jobListKeys) != 0 {
Expand Down
2 changes: 2 additions & 0 deletions store/driver/txn/txn_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) {
case tikvstore.IsolationLevel:
level := getTiKVIsolationLevel(val.(kv.IsoLevel))
txn.KVTxn.GetSnapshot().SetIsolationLevel(level)
case tikvstore.SyncLog:
txn.EnableForceSyncLog()
case tikvstore.Priority:
txn.KVTxn.SetPriority(getTiKVPriority(val.(int)))
case tikvstore.Pessimistic:
Expand Down
9 changes: 1 addition & 8 deletions store/tikv/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func (c *twoPhaseCommitter) initKeysAndMutations() error {
c.hasNoNeedCommitKeys = checkCnt > 0
c.lockTTL = txnLockTTL(txn.startTime, size)
c.priority = txn.priority.ToPB()
c.syncLog = getTxnSyncLog(txn)
c.syncLog = txn.syncLog
c.setDetail(commitDetail)
return nil
}
Expand Down Expand Up @@ -1649,13 +1649,6 @@ func (batchExe *batchExecutor) process(batches []batchMutations) error {
return err
}

func getTxnSyncLog(txn *KVTxn) bool {
if syncOption := txn.us.GetOption(kv.SyncLog); syncOption != nil {
return syncOption.(bool)
}
return false
}

func (c *twoPhaseCommitter) setDetail(d *util.CommitDetails) {
atomic.StorePointer(&c.detail, unsafe.Pointer(d))
}
Expand Down
3 changes: 0 additions & 3 deletions store/tikv/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ type KVSnapshot struct {
isolationLevel IsoLevel
priority Priority
notFillCache bool
syncLog bool
keyOnly bool
vars *kv.Variables
replicaReadSeed uint32
Expand Down Expand Up @@ -568,8 +567,6 @@ func (s *KVSnapshot) SetOption(opt int, val interface{}) {
switch opt {
case kv.NotFillCache:
s.notFillCache = val.(bool)
case kv.SyncLog:
s.syncLog = val.(bool)
case kv.SnapshotTS:
s.setSnapshotTS(val.(uint64))
case kv.ReplicaRead:
Expand Down
6 changes: 6 additions & 0 deletions store/tikv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type KVTxn struct {

binlog BinlogExecutor
schemaLeaseChecker SchemaLeaseChecker
syncLog bool
priority Priority
isPessimistic bool
kvFilter KVFilter
Expand Down Expand Up @@ -207,6 +208,11 @@ func (txn *KVTxn) SetSchemaLeaseChecker(checker SchemaLeaseChecker) {
txn.schemaLeaseChecker = checker
}

// EnableForceSyncLog indicates tikv to always sync log for the transaction.
func (txn *KVTxn) EnableForceSyncLog() {
txn.syncLog = true
}

// SetPessimistic indicates if the transaction should use pessimictic lock.
func (txn *KVTxn) SetPessimistic(b bool) {
txn.isPessimistic = b
Expand Down

0 comments on commit 830b6d6

Please sign in to comment.