Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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