Skip to content

Commit

Permalink
txn: fix false assertion error caused by loss of pessimistic locks (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ekexium authored Oct 31, 2022
1 parent a151383 commit b7aae15
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3429,8 +3429,8 @@ def go_deps():
name = "com_github_tikv_client_go_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sum = "h1:5KLqhDGLc/mtemdS/odfOP717rn8ttsTj3jzZ8TZn9A=",
version = "v2.0.1-0.20221017092635-91be9c6ce6c0",
sum = "h1:s8eJEGI4p/fxFwMBkoJ+4FAEQNQhHR47TZmVW+EEtOE=",
version = "v2.0.1-0.20221026083454-6c9c7c7c5815",
)
go_repository(
name = "com_github_tikv_pd_client",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ require (
github.com/stretchr/testify v1.8.0
github.com/tdakkota/asciicheck v0.1.1
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tikv/client-go/v2 v2.0.1-0.20221017092635-91be9c6ce6c0
github.com/tikv/client-go/v2 v2.0.1-0.20221026083454-6c9c7c7c5815
github.com/tikv/pd/client v0.0.0-20221010134149-d50e5fe43f14
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144
github.com/twmb/murmur3 v1.1.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,8 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2 h1:mbAskLJ0oJfDRtkanvQPiooDH8HvJ2FBh+iKT/OmiQQ=
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU=
github.com/tikv/client-go/v2 v2.0.1-0.20221017092635-91be9c6ce6c0 h1:5KLqhDGLc/mtemdS/odfOP717rn8ttsTj3jzZ8TZn9A=
github.com/tikv/client-go/v2 v2.0.1-0.20221017092635-91be9c6ce6c0/go.mod h1:9hmGJFrWdehClHg0lv2cYgzvCUEhwLZkH67/PHl75tg=
github.com/tikv/client-go/v2 v2.0.1-0.20221026083454-6c9c7c7c5815 h1:s8eJEGI4p/fxFwMBkoJ+4FAEQNQhHR47TZmVW+EEtOE=
github.com/tikv/client-go/v2 v2.0.1-0.20221026083454-6c9c7c7c5815/go.mod h1:9hmGJFrWdehClHg0lv2cYgzvCUEhwLZkH67/PHl75tg=
github.com/tikv/pd/client v0.0.0-20221010134149-d50e5fe43f14 h1:REQOR1XraH1fT9BCoNBPZs1CAe+w7VPLU+d+si7DLYo=
github.com/tikv/pd/client v0.0.0-20221010134149-d50e5fe43f14/go.mod h1:E/7+Fkqzwsrp4duzJ2gLPqFl6awU7QG+5yFRXaQwimM=
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 h1:kl4KhGNsJIbDHS9/4U9yQo1UcPQM0kOMJHn29EoH/Ro=
Expand Down
23 changes: 23 additions & 0 deletions tests/realtikvtest/txntest/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,26 @@ func TestDuplicateErrorMessage(t *testing.T) {
tk2.MustExec("insert into t4 values (1, 2)")
tk.MustContainErrMsg("update t3 set c = c + 1 where v = 1", "Duplicate entry '1' for key 't3.i1'")
}

func TestAssertionWhenPessimisticLockLost(t *testing.T) {
store := realtikvtest.CreateMockStoreAndSetup(t)
tk1 := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
tk1.MustExec("set @@tidb_constraint_check_in_place_pessimistic=0")
tk1.MustExec("set @@tidb_txn_assertion_level=strict")
tk2.MustExec("set @@tidb_constraint_check_in_place_pessimistic=0")
tk2.MustExec("set @@tidb_txn_assertion_level=strict")
tk1.MustExec("use test")
tk2.MustExec("use test")
tk1.MustExec("create table t (id int primary key, val text)")
tk1.MustExec("begin pessimistic")
tk1.MustExec("select * from t where id = 1 for update")
tk2.MustExec("begin pessimistic")
tk2.MustExec("insert into t values (1, 'b')")
tk2.MustExec("insert into t values (2, 'b')")
tk2.MustExec("commit")
tk1.MustExec("select * from t where id = 2 for update")
tk1.MustExec("insert into t values (1, 'a') on duplicate key update val = concat(val, 'a')")
err := tk1.ExecToErr("commit")
require.NotContains(t, err.Error(), "assertion")
}

0 comments on commit b7aae15

Please sign in to comment.