Skip to content

Commit

Permalink
store/tikv: remove use of Enable1PC transaction option in store/tikv
Browse files Browse the repository at this point in the history
Signed-off-by: disksing <i@disksing.com>
  • Loading branch information
disksing committed Apr 28, 2021
1 parent 75be70c commit 9ac4918
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions store/driver/txn/txn_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func (txn *tikvTxn) SetOption(opt int, val interface{}) {
txn.KVTxn.GetSnapshot().SetIsolationLevel(level)
case tikvstore.Pessimistic:
txn.SetPessimistic(val.(bool))
case tikvstore.Enable1PC:
txn.SetEnable1PC(val.(bool))
default:
txn.KVTxn.SetOption(opt, val)
}
Expand Down
3 changes: 1 addition & 2 deletions store/tikv/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,7 @@ func (c *twoPhaseCommitter) checkOnePC() bool {
return false
}

enable1PCOption := c.txn.us.GetOption(kv.Enable1PC)
return c.sessionID > 0 && !c.shouldWriteBinlog() && enable1PCOption != nil && enable1PCOption.(bool)
return c.sessionID > 0 && !c.shouldWriteBinlog() && c.txn.enable1PC
}

func (c *twoPhaseCommitter) needLinearizability() bool {
Expand Down
2 changes: 1 addition & 1 deletion store/tikv/tests/1pc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
func (s *testAsyncCommitCommon) begin1PC(c *C) tikv.TxnProbe {
txn, err := s.store.Begin()
c.Assert(err, IsNil)
txn.SetOption(kv.Enable1PC, true)
txn.SetEnable1PC(true)
return tikv.TxnProbe{KVTxn: txn}
}

Expand Down
2 changes: 1 addition & 1 deletion store/tikv/tests/snapshot_fail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (s *testSnapshotFailSuite) TestRetryPointGetResolveTS(c *C) {
err = txn.Set([]byte("k2"), []byte("v2"))
c.Assert(err, IsNil)
txn.SetOption(kv.EnableAsyncCommit, false)
txn.SetOption(kv.Enable1PC, false)
txn.SetEnable1PC(false)
txn.SetOption(kv.GuaranteeLinearizability, false)

// Prewrite the lock without committing it
Expand Down
6 changes: 6 additions & 0 deletions store/tikv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type KVTxn struct {
binlog BinlogExecutor
schemaLeaseChecker SchemaLeaseChecker
isPessimistic bool
enable1PC bool
kvFilter KVFilter
}

Expand Down Expand Up @@ -211,6 +212,11 @@ func (txn *KVTxn) SetPessimistic(b bool) {
txn.isPessimistic = b
}

// SetEnable1PC indicates if the transaction will try to use 1 phase commit.
func (txn *KVTxn) SetEnable1PC(b bool) {
txn.enable1PC = b
}

// SetKVFilter sets the filter to ignore key-values in memory buffer.
func (txn *KVTxn) SetKVFilter(filter KVFilter) {
txn.kvFilter = filter
Expand Down

0 comments on commit 9ac4918

Please sign in to comment.