tikv: fix pessimistic txn not write binlog in master (#24192)

This commit is contained in:
lysu
2021-04-22 13:01:53 +08:00
committed by GitHub
parent feea6d6424
commit cabeda21e6
2 changed files with 16 additions and 0 deletions

View File

@ -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")

View File

@ -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.