Skip to content

Commit

Permalink
tikv: fix pessimistic txn not write binlog in master (#24192)
Browse files Browse the repository at this point in the history
  • Loading branch information
lysu authored Apr 22, 2021
1 parent feea6d6 commit cabeda2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sessionctx/binloginfo/binloginfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,19 @@ func (s *testBinlogSuite) TestPartitionedTable(c *C) {
}
}

func (s *testBinlogSuite) TestPessimisticLockThenCommit(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.Se.GetSessionVars().BinlogClient = s.client
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int)")
tk.MustExec("begin pessimistic")
tk.MustExec("insert into t select 1, 1")
tk.MustExec("commit")
prewriteVal := getLatestBinlogPrewriteValue(c, s.pump)
c.Assert(len(prewriteVal.Mutations), Equals, 1)
}

func (s *testBinlogSuite) TestDeleteSchema(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
Expand Down
3 changes: 3 additions & 0 deletions store/tikv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,9 @@ func (txn *KVTxn) GetSnapshot() *KVSnapshot {
// SetBinlogExecutor sets the method to perform binlong synchronization.
func (txn *KVTxn) SetBinlogExecutor(binlog BinlogExecutor) {
txn.binlog = binlog
if txn.committer != nil {
txn.committer.binlog = binlog
}
}

// GetClusterID returns store's cluster id.
Expand Down

0 comments on commit cabeda2

Please sign in to comment.