mirror of https://github.com/tikv/client-go.git
Support postponed conflict check (#556)
* replace kvproto Signed-off-by: ekexium <eke@fastmail.com> * support NeedConflictCheck Signed-off-by: ekexium <eke@fastmail.com> * fix mutation encoding Signed-off-by: ekexium <eke@fastmail.com> * support temporary flag Signed-off-by: ekexium <eke@fastmail.com> * update kvproto Signed-off-by: ekexium <eke@fastmail.com> * fix style Signed-off-by: ekexium <eke@fastmail.com> * add an option to enable the behavior Signed-off-by: ekexium <eke@fastmail.com> * replace AfterCheckPoint with existing canModity Signed-off-by: ekexium <eke@fastmail.com> * UpdateFlag do not unset temporary flag Signed-off-by: ekexium <eke@fastmail.com> * remove unused function Signed-off-by: ekexium <eke@fastmail.com> * update tidb dependency Signed-off-by: ekexium <eke@fastmail.com> update tidb dependency Signed-off-by: ekexium <eke@fastmail.com> * fix test Signed-off-by: ekexium <eke@fastmail.com> * do no unset flag on read Signed-off-by: ekexium <eke@fastmail.com> * update tidb dependency Signed-off-by: ekexium <eke@fastmail.com> * update comment Signed-off-by: ekexium <eke@fastmail.com> Signed-off-by: ekexium <eke@fastmail.com>
This commit is contained in:
parent
389101f073
commit
0130f76738
2
go.mod
2
go.mod
|
|
@ -13,7 +13,7 @@ require (
|
|||
github.com/opentracing/opentracing-go v1.2.0
|
||||
github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00
|
||||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989
|
||||
github.com/pingcap/kvproto v0.0.0-20220705053936-aa9c2d20cd2a
|
||||
github.com/pingcap/kvproto v0.0.0-20220818023518-a0f02b6efcee
|
||||
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -155,8 +155,8 @@ github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00/go.mod h1:4qGtCB
|
|||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
|
||||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
|
||||
github.com/pingcap/kvproto v0.0.0-20220510035547-0e2f26c0a46a/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
||||
github.com/pingcap/kvproto v0.0.0-20220705053936-aa9c2d20cd2a h1:nP2wmyw9JTRsk5rm+tZtfAso6c/1FvuaFNbXTaYz3FE=
|
||||
github.com/pingcap/kvproto v0.0.0-20220705053936-aa9c2d20cd2a/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
||||
github.com/pingcap/kvproto v0.0.0-20220818023518-a0f02b6efcee h1:s1al2ci3MEj5VnNuUCGAfeqpbCxcMeZibOyxw8ClHLE=
|
||||
github.com/pingcap/kvproto v0.0.0-20220818023518-a0f02b6efcee/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
||||
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee h1:VO2t6IBpfvW34TdtD/G10VvnGqjLic1jzOuHjUb5VqM=
|
||||
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
|
|
|||
|
|
@ -653,7 +653,7 @@ func (s *testCommitterSuite) TestPessimisticPrewriteRequest() {
|
|||
s.Nil(err)
|
||||
committer.SetForUpdateTS(100)
|
||||
req := committer.BuildPrewriteRequest(1, 1, 1, committer.GetMutations().Slice(0, 1), 1)
|
||||
s.Greater(len(req.Prewrite().IsPessimisticLock), 0)
|
||||
s.Greater(len(req.Prewrite().PessimisticActions), 0)
|
||||
s.Equal(req.Prewrite().ForUpdateTs, uint64(100))
|
||||
}
|
||||
|
||||
|
|
@ -1261,7 +1261,7 @@ func (s *testCommitterSuite) TestResolveMixed() {
|
|||
// stop txn ttl manager and remove primary key, make the other keys left behind
|
||||
committer.CloseTTLManager()
|
||||
muts := transaction.NewPlainMutations(1)
|
||||
muts.Push(kvrpcpb.Op_Lock, pk, nil, true, false, false)
|
||||
muts.Push(kvrpcpb.Op_Lock, pk, nil, true, false, false, false)
|
||||
err = committer.PessimisticRollbackMutations(context.Background(), &muts)
|
||||
s.Nil(err)
|
||||
|
||||
|
|
@ -1731,7 +1731,7 @@ func (s *testCommitterSuite) TestFlagsInMemBufferMutations() {
|
|||
|
||||
forEachCase(func(op kvrpcpb.Op, key []byte, value []byte, i int, isPessimisticLock, assertExist, assertNotExist bool) {
|
||||
handle := db.IterWithFlags(key, nil).Handle()
|
||||
mutations.Push(op, isPessimisticLock, assertExist, assertNotExist, handle)
|
||||
mutations.Push(op, isPessimisticLock, assertExist, assertNotExist, false, handle)
|
||||
})
|
||||
|
||||
forEachCase(func(op kvrpcpb.Op, key []byte, value []byte, i int, isPessimisticLock, assertExist, assertNotExist bool) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ require (
|
|||
github.com/ninedraft/israce v0.0.3
|
||||
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c
|
||||
github.com/pingcap/failpoint v0.0.0-20220423142525-ae43b7f4e5c3
|
||||
github.com/pingcap/kvproto v0.0.0-20220804022843-f006036b1277
|
||||
github.com/pingcap/kvproto v0.0.0-20220818023518-a0f02b6efcee
|
||||
github.com/pingcap/tidb v1.1.0-beta.0.20220824151221-29b57e356929
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/stretchr/testify v1.8.0
|
||||
|
|
@ -49,7 +49,7 @@ require (
|
|||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 // indirect
|
||||
github.com/pingcap/log v1.1.0 // indirect
|
||||
github.com/pingcap/tidb/parser v0.0.0-20220724090709-5484002f1963 // indirect
|
||||
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e // indirect
|
||||
github.com/pingcap/tipb v0.0.0-20220824081009-0714a57aff1d // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
github.com/prometheus/client_golang v1.12.2 // indirect
|
||||
|
|
@ -87,3 +87,5 @@ require (
|
|||
)
|
||||
|
||||
replace github.com/tikv/client-go/v2 => ../
|
||||
|
||||
replace github.com/pingcap/tidb => github.com/ekexium/tidb v1.1.0-beta.0.20220829095709-87c0a7d42fbd
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 h1:VBvHGLJbaY0+c66NZHdS
|
|||
github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.2.0 h1:62Ew5xXg5UCGIXDOM7+y4IL5/6mQJq1nenhBCJAeGX8=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
|
|
@ -64,13 +62,11 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
|
|||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/blacktear23/go-proxyprotocol v1.0.0 h1:WmMmtZanGEfIHnJN9N3A4Pl6mM69D+GxEph2eOaCf7g=
|
||||
github.com/blacktear23/go-proxyprotocol v1.0.2 h1:zR7PZeoU0wAkElcIXenFiy3R56WB6A+UEVi4c6RH8wo=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cfzjywxk/tidb v1.1.0-beta.0.20220818072433-0272d5dcb987 h1:z2ZypM4JXhk/VkZBs1imXohUG2T/idrybVg4qXUJgUo=
|
||||
github.com/cfzjywxk/tidb v1.1.0-beta.0.20220818072433-0272d5dcb987/go.mod h1:Y9tgiWs/MeuGPUH4FRdoCKxdxRqnuoSmhHcoN//ekro=
|
||||
github.com/cheggaaa/pb/v3 v3.0.8 h1:bC8oemdChbke2FHIIGy9mn4DPJ2caZYQnfbRqwmdCoA=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
|
|
@ -103,8 +99,6 @@ github.com/danjacques/gofslock v0.0.0-20191023191349-0a45f885bc37/go.mod h1:DC3J
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/defined2014/tidb v1.1.0-beta.0.20220725074011-ee134690c221 h1:gMOaLHx497ItNTZUBOwxoJy0WD2TZgOWJSGF2VWyJsc=
|
||||
github.com/defined2014/tidb v1.1.0-beta.0.20220725074011-ee134690c221/go.mod h1:w4DiXW7PuKM/suqwNRtsBMvI71CHK7eFaFrUsLYI6Rs=
|
||||
github.com/dgraph-io/ristretto v0.1.1-0.20220403145359-8e850b710d6d h1:Wrc3UKTS+cffkOx0xRGFC+ZesNuTfn0ThvEC72N0krk=
|
||||
github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
|
|
@ -113,6 +107,8 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUn
|
|||
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/ekexium/tidb v1.1.0-beta.0.20220829095709-87c0a7d42fbd h1:mZyOX1kOYAh5iMdM1JndoUXzh7tVTwT2HxRBvAp2t6I=
|
||||
github.com/ekexium/tidb v1.1.0-beta.0.20220829095709-87c0a7d42fbd/go.mod h1:JmLv9+C4Kjxiudt+6HBcO5bBaequrermOpov2evReZ8=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
|
|
@ -192,8 +188,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
|
|
@ -308,21 +303,17 @@ github.com/pingcap/fn v0.0.0-20200306044125-d5540d389059 h1:Pe2LbxRmbTfAoKJ65bZL
|
|||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
|
||||
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
|
||||
github.com/pingcap/kvproto v0.0.0-20220510035547-0e2f26c0a46a/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
||||
github.com/pingcap/kvproto v0.0.0-20220711062932-08b02befd813 h1:PAXtUVMJnyQQS8t9GzihIFmh6FBXu0JziWbIVknLniA=
|
||||
github.com/pingcap/kvproto v0.0.0-20220711062932-08b02befd813/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
||||
github.com/pingcap/kvproto v0.0.0-20220804022843-f006036b1277 h1:4UQdx1acoUrQD0Q5Etz1ABd31duzSgp3XwEnb/cvV9I=
|
||||
github.com/pingcap/kvproto v0.0.0-20220804022843-f006036b1277/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
||||
github.com/pingcap/kvproto v0.0.0-20220818023518-a0f02b6efcee h1:s1al2ci3MEj5VnNuUCGAfeqpbCxcMeZibOyxw8ClHLE=
|
||||
github.com/pingcap/kvproto v0.0.0-20220818023518-a0f02b6efcee/go.mod h1:OYtxs0786qojVTmkVeufx93xe+jUgm56GUYRIKnmaGI=
|
||||
github.com/pingcap/log v0.0.0-20200511115504-543df19646ad/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
|
||||
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
||||
github.com/pingcap/log v1.1.0 h1:ELiPxACz7vdo1qAvvaWJg1NrYFoY6gqAh/+Uo6aXdD8=
|
||||
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
|
||||
github.com/pingcap/sysutil v0.0.0-20220114020952-ea68d2dbf5b4 h1:HYbcxtnkN3s5tqrZ/z3eJS4j3Db8wMphEm1q10lY/TM=
|
||||
github.com/pingcap/tidb v1.1.0-beta.0.20220824151221-29b57e356929 h1:QDwyoUCZuIiw1mHDrmbOykbzS8/lkEzLGeDJsnsU0BY=
|
||||
github.com/pingcap/tidb v1.1.0-beta.0.20220824151221-29b57e356929/go.mod h1:ibrqg2O6i98YbT6al8tpoz824bcHQlQKyV7VxpC1RH0=
|
||||
github.com/pingcap/tidb/parser v0.0.0-20220724090709-5484002f1963 h1:tklVQTGqsCkx531sxFNUQ8sFWicgPSczpESZbF9uEwE=
|
||||
github.com/pingcap/tidb/parser v0.0.0-20220724090709-5484002f1963/go.mod h1:wjvp+T3/T9XYt0nKqGX3Kc1AKuyUcfno6LTc6b2A6ew=
|
||||
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e h1:FBaTXU8C3xgt/drM58VHxojHo/QoG1oPsgWTGvaSpO4=
|
||||
github.com/pingcap/tipb v0.0.0-20220718022156-3e2483c20a9e/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
|
||||
github.com/pingcap/tipb v0.0.0-20220824081009-0714a57aff1d h1:kWYridgsn8xSKYJ2EkXp7uj5HwJnG5snpY3XP8oYmPU=
|
||||
github.com/pingcap/tipb v0.0.0-20220824081009-0714a57aff1d/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs=
|
||||
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
|
@ -364,21 +355,19 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
|
|||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/shirou/gopsutil/v3 v3.22.4 h1:srAQaiX6jX/cYL6q29aE0m8lOskT9CurZ9N61YR3yoI=
|
||||
github.com/shirou/gopsutil/v3 v3.22.4/go.mod h1:D01hZJ4pVHPpCTZ3m3T2+wDF2YAGfd+H4ifUguaQzHM=
|
||||
github.com/shirou/gopsutil/v3 v3.22.6 h1:FnHOFOh+cYAM0C30P+zysPISzlknLC5Z1G4EAElznfQ=
|
||||
github.com/shirou/gopsutil/v3 v3.22.6/go.mod h1:EdIubSnZhbAvBS1yJ7Xi+AShB/hxwLHOMz4MCYz7yMs=
|
||||
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk=
|
||||
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 h1:pXY9qYc/MP5zdvqWEUH6SjNiu7VhSjuVFTFiTcphaLU=
|
||||
github.com/shurcooL/vfsgen v0.0.0-20180711163814-62bca832be04 h1:y0cMJ0qjii33BnD6tMGcF/+gHYsoKQ6tbwQpy233OII=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
|
||||
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
|
|
@ -395,8 +384,6 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
|
|||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2-0.20220504104629-106ec21d14df h1:rh3VYpfvzXRbJ90ymx1yfhGl/wq8ac2m/cUbao61kwY=
|
||||
github.com/stretchr/testify v1.7.2-0.20220504104629-106ec21d14df/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
|
|
@ -500,8 +487,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
|
|||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/exp v0.0.0-20220428152302-39d4317da171 h1:TfdoLivD44QwvssI9Sv1xwa5DcL5XQr4au4sZ2F2NV4=
|
||||
golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
|
||||
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
|
|
@ -560,8 +545,6 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
|
|||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 h1:bRb386wvrE+oBNdF1d/Xh9mQrfQ4ecYhW5qJ5GvTGT4=
|
||||
golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
|
|
@ -582,8 +565,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4=
|
||||
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
|
@ -633,8 +614,6 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 h1:wEZYwx+kK+KlZ0hpvP2Ls1Xr4+RWnlzGFwPP0aiDjIU=
|
||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg=
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
|
|
@ -701,8 +680,6 @@ golang.org/x/tools v0.0.0-20201125231158-b5590deeca9b/go.mod h1:emZCQorbCU4vsT4f
|
|||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY=
|
||||
golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
|
||||
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
|
@ -823,7 +800,6 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
|||
|
|
@ -466,6 +466,10 @@ func (s *mockTikvGrpcServer) Compact(ctx context.Context, request *kvrpcpb.Compa
|
|||
return nil, errors.New("unreachable")
|
||||
}
|
||||
|
||||
func (s *mockTikvGrpcServer) GetLockWaitHistory(ctx context.Context, request *kvrpcpb.GetLockWaitHistoryRequest) (*kvrpcpb.GetLockWaitHistoryResponse, error) {
|
||||
return nil, errors.New("unreachable")
|
||||
}
|
||||
|
||||
func (s *testRegionRequestToSingleStoreSuite) TestNoReloadRegionForGrpcWhenCtxCanceled() {
|
||||
// prepare a mock tikv grpc server
|
||||
addr := "localhost:56341"
|
||||
|
|
|
|||
|
|
@ -739,8 +739,12 @@ func (mvcc *MVCCLevelDB) Prewrite(req *kvrpcpb.PrewriteRequest) []error {
|
|||
if op == kvrpcpb.Op_CheckNotExists {
|
||||
continue
|
||||
}
|
||||
isPessimisticLock := len(req.IsPessimisticLock) > 0 && req.IsPessimisticLock[i]
|
||||
err = prewriteMutation(mvcc.getDB(""), batch, m, startTS, primary, ttl, txnSize, isPessimisticLock, minCommitTS, req.AssertionLevel)
|
||||
|
||||
pessimisticAction := kvrpcpb.PrewriteRequest_SKIP_PESSIMISTIC_CHECK
|
||||
if len(req.PessimisticActions) > 0 {
|
||||
pessimisticAction = req.PessimisticActions[i]
|
||||
}
|
||||
err = prewriteMutation(mvcc.getDB(""), batch, m, startTS, primary, ttl, txnSize, pessimisticAction, minCommitTS, req.AssertionLevel)
|
||||
errs = append(errs, err)
|
||||
if err != nil {
|
||||
anyError = true
|
||||
|
|
@ -871,7 +875,7 @@ func checkConflictValue(iter *Iterator, m *kvrpcpb.Mutation, forUpdateTS uint64,
|
|||
func prewriteMutation(db *leveldb.DB, batch *leveldb.Batch,
|
||||
mutation *kvrpcpb.Mutation, startTS uint64,
|
||||
primary []byte, ttl uint64, txnSize uint64,
|
||||
isPessimisticLock bool, minCommitTS uint64,
|
||||
pessimisticAction kvrpcpb.PrewriteRequest_PessimisticAction, minCommitTS uint64,
|
||||
assertionLevel kvrpcpb.AssertionLevel) error {
|
||||
startKey := mvccEncode(mutation.Key, lockVer)
|
||||
iter := newIterator(db, &util.Range{
|
||||
|
|
@ -888,7 +892,7 @@ func prewriteMutation(db *leveldb.DB, batch *leveldb.Batch,
|
|||
}
|
||||
if ok {
|
||||
if dec.lock.startTS != startTS {
|
||||
if isPessimisticLock {
|
||||
if pessimisticAction == kvrpcpb.PrewriteRequest_DO_PESSIMISTIC_CHECK {
|
||||
// NOTE: A special handling.
|
||||
// When pessimistic txn prewrite meets lock, set the TTL = 0 means
|
||||
// telling TiDB to rollback the transaction **unconditionly**.
|
||||
|
|
@ -913,7 +917,7 @@ func prewriteMutation(db *leveldb.DB, batch *leveldb.Batch,
|
|||
return err
|
||||
}
|
||||
} else {
|
||||
if isPessimisticLock {
|
||||
if pessimisticAction == kvrpcpb.PrewriteRequest_DO_PESSIMISTIC_CHECK {
|
||||
return ErrAbort("pessimistic lock not found")
|
||||
}
|
||||
_, err = checkConflictValue(iter, mutation, startTS, startTS, false, assertionLevel)
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ func newMemDB() *MemDB {
|
|||
db.stages = make([]MemDBCheckpoint, 0, 2)
|
||||
db.entrySizeLimit = math.MaxUint64
|
||||
db.bufferSizeLimit = math.MaxUint64
|
||||
db.vlog.memdb = db
|
||||
return db
|
||||
}
|
||||
|
||||
|
|
@ -330,13 +331,20 @@ func (db *MemDB) set(key []byte, value []byte, ops ...kv.FlagsOp) error {
|
|||
}
|
||||
x := db.traverse(key, true)
|
||||
|
||||
if len(ops) != 0 {
|
||||
flags := kv.ApplyFlagsOps(x.getKeyFlags(), ops...)
|
||||
if flags.AndPersistent() != 0 {
|
||||
db.dirty = true
|
||||
}
|
||||
x.setKeyFlags(flags)
|
||||
// the NeedConstraintCheckInPrewrite flag is temporary,
|
||||
// every write to the node removes the flag unless it's explicitly set.
|
||||
// This set must be in the latest stage so no special processing is needed.
|
||||
var flags kv.KeyFlags
|
||||
if value != nil {
|
||||
flags = kv.ApplyFlagsOps(x.getKeyFlags(), append([]kv.FlagsOp{kv.DelNeedConstraintCheckInPrewrite}, ops...)...)
|
||||
} else {
|
||||
// an UpdateFlag operation, do not delete the NeedConstraintCheckInPrewrite flag.
|
||||
flags = kv.ApplyFlagsOps(x.getKeyFlags(), ops...)
|
||||
}
|
||||
if flags.AndPersistent() != 0 {
|
||||
db.dirty = true
|
||||
}
|
||||
x.setKeyFlags(flags)
|
||||
|
||||
if value == nil {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ func (a *nodeAllocator) reset() {
|
|||
|
||||
type memdbVlog struct {
|
||||
memdbArena
|
||||
memdb *MemDB
|
||||
}
|
||||
|
||||
const memdbVlogHdrSize = 8 + 8 + 4
|
||||
|
|
@ -320,6 +321,7 @@ func (l *memdbVlog) appendValue(nodeAddr memdbArenaAddr, oldValue memdbArenaAddr
|
|||
return addr
|
||||
}
|
||||
|
||||
// A pure function that gets a value.
|
||||
func (l *memdbVlog) getValue(addr memdbArenaAddr) []byte {
|
||||
lenOff := addr.off - memdbVlogHdrSize
|
||||
block := l.blocks[addr.idx].buf
|
||||
|
|
|
|||
|
|
@ -828,3 +828,15 @@ func TestBufferLimit(t *testing.T) {
|
|||
err = buffer.Delete(make([]byte, 500))
|
||||
assert.NotNil(err)
|
||||
}
|
||||
|
||||
func TestUnsetTemporaryFlag(t *testing.T) {
|
||||
require := require.New(t)
|
||||
db := newMemDB()
|
||||
key := []byte{1}
|
||||
value := []byte{2}
|
||||
db.SetWithFlags(key, value, kv.SetNeedConstraintCheckInPrewrite)
|
||||
db.Set(key, value)
|
||||
flags, err := db.GetFlags(key)
|
||||
require.Nil(err)
|
||||
require.False(flags.HasNeedConstraintCheckInPrewrite())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,13 @@ const (
|
|||
flagAssertExist
|
||||
flagAssertNotExist
|
||||
|
||||
persistentFlags = flagKeyLocked | flagKeyLockedValExist
|
||||
// It marks the conflict check of the key is postponed to prewrite. This is only used in pessimistic transactions.
|
||||
// When the key gets locked (and the existence is checked), the flag should be removed.
|
||||
// It should only be applied to keys with PresumeNotExist, so that an in-place constraint check becomes
|
||||
// (a conflict check + a constraint check) in prewrite.
|
||||
flagNeedConstraintCheckInPrewrite
|
||||
|
||||
persistentFlags = flagKeyLocked | flagKeyLockedValExist | flagNeedConstraintCheckInPrewrite
|
||||
)
|
||||
|
||||
// HasAssertExist returns whether the key need ensure exists in 2pc.
|
||||
|
|
@ -125,6 +131,11 @@ func (f KeyFlags) HasReadable() bool {
|
|||
return f&flagReadable != 0
|
||||
}
|
||||
|
||||
// HasNeedConstraintCheckInPrewrite returns whether the key needs to check conflict in prewrite.
|
||||
func (f KeyFlags) HasNeedConstraintCheckInPrewrite() bool {
|
||||
return f&flagNeedConstraintCheckInPrewrite != 0
|
||||
}
|
||||
|
||||
// AndPersistent returns the value of current flags&persistentFlags
|
||||
func (f KeyFlags) AndPersistent() KeyFlags {
|
||||
return f & persistentFlags
|
||||
|
|
@ -153,10 +164,12 @@ func ApplyFlagsOps(origin KeyFlags, ops ...FlagsOp) KeyFlags {
|
|||
origin &= ^flagNeedLocked
|
||||
case SetKeyLockedValueExists:
|
||||
origin |= flagKeyLockedValExist
|
||||
origin &= ^flagNeedConstraintCheckInPrewrite
|
||||
case DelNeedCheckExists:
|
||||
origin &= ^flagNeedCheckExists
|
||||
case SetKeyLockedValueNotExists:
|
||||
origin &= ^flagKeyLockedValExist
|
||||
origin &= ^flagNeedConstraintCheckInPrewrite
|
||||
case SetPrewriteOnly:
|
||||
origin |= flagPrewriteOnly
|
||||
case SetIgnoredIn2PC:
|
||||
|
|
@ -177,6 +190,10 @@ func ApplyFlagsOps(origin KeyFlags, ops ...FlagsOp) KeyFlags {
|
|||
case SetAssertNone:
|
||||
origin &= ^flagAssertExist
|
||||
origin &= ^flagAssertNotExist
|
||||
case SetNeedConstraintCheckInPrewrite:
|
||||
origin |= flagNeedConstraintCheckInPrewrite
|
||||
case DelNeedConstraintCheckInPrewrite:
|
||||
origin &= ^flagNeedConstraintCheckInPrewrite
|
||||
}
|
||||
}
|
||||
return origin
|
||||
|
|
@ -221,4 +238,9 @@ const (
|
|||
SetAssertUnknown
|
||||
// SetAssertNone cleans up the key's assert.
|
||||
SetAssertNone
|
||||
// SetNeedConstraintCheckInPrewrite marks the key needs to check conflict in prewrite.
|
||||
SetNeedConstraintCheckInPrewrite
|
||||
// DelNeedConstraintCheckInPrewrite reverts SetNeedConstraintCheckInPrewrite. This is required when we decide to
|
||||
// make up the pessimistic lock.
|
||||
DelNeedConstraintCheckInPrewrite
|
||||
)
|
||||
|
|
|
|||
|
|
@ -185,8 +185,8 @@ type memBufferMutations struct {
|
|||
storage *unionstore.MemDB
|
||||
|
||||
// The format to put to the UserData of the handles:
|
||||
// MSB LSB
|
||||
// [13 bits: Op][1 bit: assertNotExist][1 bit: assertExist][1 bit: isPessimisticLock]
|
||||
// MSB LSB
|
||||
// [12 bits: Op][1 bit: NeedConstraintCheckInPrewrite][1 bit: assertNotExist][1 bit: assertExist][1 bit: isPessimisticLock]
|
||||
handles []unionstore.MemKeyHandle
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ func (m *memBufferMutations) GetValue(i int) []byte {
|
|||
}
|
||||
|
||||
func (m *memBufferMutations) GetOp(i int) kvrpcpb.Op {
|
||||
return kvrpcpb.Op(m.handles[i].UserData >> 3)
|
||||
return kvrpcpb.Op(m.handles[i].UserData >> 4)
|
||||
}
|
||||
|
||||
func (m *memBufferMutations) IsPessimisticLock(i int) bool {
|
||||
|
|
@ -234,6 +234,10 @@ func (m *memBufferMutations) IsAssertNotExist(i int) bool {
|
|||
return m.handles[i].UserData&(1<<2) != 0
|
||||
}
|
||||
|
||||
func (m *memBufferMutations) NeedConstraintCheckInPrewrite(i int) bool {
|
||||
return m.handles[i].UserData&(1<<3) != 0
|
||||
}
|
||||
|
||||
func (m *memBufferMutations) Slice(from, to int) CommitterMutations {
|
||||
return &memBufferMutations{
|
||||
handles: m.handles[from:to],
|
||||
|
|
@ -241,9 +245,10 @@ func (m *memBufferMutations) Slice(from, to int) CommitterMutations {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *memBufferMutations) Push(op kvrpcpb.Op, isPessimisticLock, assertExist, assertNotExist bool, handle unionstore.MemKeyHandle) {
|
||||
func (m *memBufferMutations) Push(op kvrpcpb.Op, isPessimisticLock, assertExist, assertNotExist, NeedConstraintCheckInPrewrite bool,
|
||||
handle unionstore.MemKeyHandle) {
|
||||
// See comments of `m.handles` field about the format of the user data `aux`.
|
||||
aux := uint16(op) << 3
|
||||
aux := uint16(op) << 4
|
||||
if isPessimisticLock {
|
||||
aux |= 1
|
||||
}
|
||||
|
|
@ -253,6 +258,9 @@ func (m *memBufferMutations) Push(op kvrpcpb.Op, isPessimisticLock, assertExist,
|
|||
if assertNotExist {
|
||||
aux |= 1 << 2
|
||||
}
|
||||
if NeedConstraintCheckInPrewrite {
|
||||
aux |= 1 << 3
|
||||
}
|
||||
handle.UserData = aux
|
||||
m.handles = append(m.handles, handle)
|
||||
}
|
||||
|
|
@ -269,9 +277,12 @@ const (
|
|||
|
||||
// MutationFlagIsAssertNotExists is the flag that marks a mutation needs to be asserted to be not-existed when prewriting.
|
||||
MutationFlagIsAssertNotExists
|
||||
|
||||
// MutationFlagNeedConstraintCheckInPrewrite is the flag that marks a mutation needs to be checked for conflicts in prewrite.
|
||||
MutationFlagNeedConstraintCheckInPrewrite
|
||||
)
|
||||
|
||||
func makeMutationFlags(isPessimisticLock, assertExist, assertNotExist bool) CommitterMutationFlags {
|
||||
func makeMutationFlags(isPessimisticLock, assertExist, assertNotExist, NeedConstraintCheckInPrewrite bool) CommitterMutationFlags {
|
||||
var flags CommitterMutationFlags = 0
|
||||
if isPessimisticLock {
|
||||
flags |= MutationFlagIsPessimisticLock
|
||||
|
|
@ -282,6 +293,9 @@ func makeMutationFlags(isPessimisticLock, assertExist, assertNotExist bool) Comm
|
|||
if assertNotExist {
|
||||
flags |= MutationFlagIsAssertNotExists
|
||||
}
|
||||
if NeedConstraintCheckInPrewrite {
|
||||
flags |= MutationFlagNeedConstraintCheckInPrewrite
|
||||
}
|
||||
return flags
|
||||
}
|
||||
|
||||
|
|
@ -296,6 +310,7 @@ type CommitterMutations interface {
|
|||
Slice(from, to int) CommitterMutations
|
||||
IsAssertExists(i int) bool
|
||||
IsAssertNotExist(i int) bool
|
||||
NeedConstraintCheckInPrewrite(i int) bool
|
||||
}
|
||||
|
||||
// PlainMutations contains transaction operations.
|
||||
|
|
@ -333,11 +348,12 @@ func (c *PlainMutations) Slice(from, to int) CommitterMutations {
|
|||
}
|
||||
|
||||
// Push another mutation into mutations.
|
||||
func (c *PlainMutations) Push(op kvrpcpb.Op, key []byte, value []byte, isPessimisticLock, assertExist, assertNotExist bool) {
|
||||
func (c *PlainMutations) Push(op kvrpcpb.Op, key []byte, value []byte, isPessimisticLock, assertExist,
|
||||
assertNotExist, NeedConstraintCheckInPrewrite bool) {
|
||||
c.ops = append(c.ops, op)
|
||||
c.keys = append(c.keys, key)
|
||||
c.values = append(c.values, value)
|
||||
c.flags = append(c.flags, makeMutationFlags(isPessimisticLock, assertExist, assertNotExist))
|
||||
c.flags = append(c.flags, makeMutationFlags(isPessimisticLock, assertExist, assertNotExist, NeedConstraintCheckInPrewrite))
|
||||
}
|
||||
|
||||
// Len returns the count of mutations.
|
||||
|
|
@ -380,6 +396,11 @@ func (c *PlainMutations) IsAssertNotExist(i int) bool {
|
|||
return c.flags[i]&MutationFlagIsAssertNotExists != 0
|
||||
}
|
||||
|
||||
// NeedConstraintCheckInPrewrite returns the key NeedConstraintCheckInPrewrite flag at index.
|
||||
func (c *PlainMutations) NeedConstraintCheckInPrewrite(i int) bool {
|
||||
return c.flags[i]&MutationFlagNeedConstraintCheckInPrewrite != 0
|
||||
}
|
||||
|
||||
// GetOp returns the key op at index.
|
||||
func (c *PlainMutations) GetOp(i int) kvrpcpb.Op {
|
||||
return c.ops[i]
|
||||
|
|
@ -584,7 +605,7 @@ func (c *twoPhaseCommitter) initKeysAndMutations(ctx context.Context) error {
|
|||
if c.txn.schemaAmender != nil || c.txn.assertionLevel == kvrpcpb.AssertionLevel_Off {
|
||||
mustExist, mustNotExist, hasAssertUnknown = false, false, false
|
||||
}
|
||||
c.mutations.Push(op, isPessimistic, mustExist, mustNotExist, it.Handle())
|
||||
c.mutations.Push(op, isPessimistic, mustExist, mustNotExist, flags.HasNeedConstraintCheckInPrewrite(), it.Handle())
|
||||
size += len(key) + len(value)
|
||||
|
||||
if c.txn.assertionLevel != kvrpcpb.AssertionLevel_Off {
|
||||
|
|
@ -1690,7 +1711,7 @@ func (c *twoPhaseCommitter) amendPessimisticLock(ctx context.Context, addMutatio
|
|||
for i := 0; i < addMutations.Len(); i++ {
|
||||
if addMutations.IsPessimisticLock(i) {
|
||||
keysNeedToLock.Push(addMutations.GetOp(i), addMutations.GetKey(i), addMutations.GetValue(i), addMutations.IsPessimisticLock(i),
|
||||
addMutations.IsAssertExists(i), addMutations.IsAssertNotExist(i))
|
||||
addMutations.IsAssertExists(i), addMutations.IsAssertNotExist(i), addMutations.NeedConstraintCheckInPrewrite(i))
|
||||
}
|
||||
}
|
||||
// For unique index amend, we need to pessimistic lock the generated new index keys first.
|
||||
|
|
@ -1774,7 +1795,8 @@ func (c *twoPhaseCommitter) tryAmendTxn(ctx context.Context, startInfoSchema Sch
|
|||
return false, err
|
||||
}
|
||||
handle := c.txn.GetMemBuffer().IterWithFlags(key, nil).Handle()
|
||||
c.mutations.Push(op, addMutations.IsPessimisticLock(i), addMutations.IsAssertExists(i), addMutations.IsAssertNotExist(i), handle)
|
||||
c.mutations.Push(op, addMutations.IsPessimisticLock(i), addMutations.IsAssertExists(i),
|
||||
addMutations.IsAssertNotExist(i), addMutations.NeedConstraintCheckInPrewrite(i), handle)
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
|
|
@ -2128,7 +2150,7 @@ func (c *twoPhaseCommitter) mutationsOfKeys(keys [][]byte) CommitterMutations {
|
|||
for _, key := range keys {
|
||||
if bytes.Equal(c.mutations.GetKey(i), key) {
|
||||
res.Push(c.mutations.GetOp(i), c.mutations.GetKey(i), c.mutations.GetValue(i), c.mutations.IsPessimisticLock(i),
|
||||
c.mutations.IsAssertExists(i), c.mutations.IsAssertNotExist(i))
|
||||
c.mutations.IsAssertExists(i), c.mutations.IsAssertNotExist(i), c.mutations.NeedConstraintCheckInPrewrite(i))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func (actionPrewrite) tiKVTxnRegionsNumHistogram() prometheus.Observer {
|
|||
func (c *twoPhaseCommitter) buildPrewriteRequest(batch batchMutations, txnSize uint64) *tikvrpc.Request {
|
||||
m := batch.mutations
|
||||
mutations := make([]*kvrpcpb.Mutation, m.Len())
|
||||
isPessimisticLock := make([]bool, m.Len())
|
||||
pessimisticActions := make([]kvrpcpb.PrewriteRequest_PessimisticAction, m.Len())
|
||||
for i := 0; i < m.Len(); i++ {
|
||||
assertion := kvrpcpb.Assertion_None
|
||||
if m.IsAssertExists(i) {
|
||||
|
|
@ -89,7 +89,13 @@ func (c *twoPhaseCommitter) buildPrewriteRequest(batch batchMutations, txnSize u
|
|||
Value: m.GetValue(i),
|
||||
Assertion: assertion,
|
||||
}
|
||||
isPessimisticLock[i] = m.IsPessimisticLock(i)
|
||||
if m.IsPessimisticLock(i) {
|
||||
pessimisticActions[i] = kvrpcpb.PrewriteRequest_DO_PESSIMISTIC_CHECK
|
||||
} else if m.NeedConstraintCheckInPrewrite(i) {
|
||||
pessimisticActions[i] = kvrpcpb.PrewriteRequest_DO_CONSTRAINT_CHECK
|
||||
} else {
|
||||
pessimisticActions[i] = kvrpcpb.PrewriteRequest_SKIP_PESSIMISTIC_CHECK
|
||||
}
|
||||
}
|
||||
c.mu.Lock()
|
||||
minCommitTS := c.minCommitTS
|
||||
|
|
@ -141,16 +147,16 @@ func (c *twoPhaseCommitter) buildPrewriteRequest(batch batchMutations, txnSize u
|
|||
}
|
||||
|
||||
req := &kvrpcpb.PrewriteRequest{
|
||||
Mutations: mutations,
|
||||
PrimaryLock: c.primary(),
|
||||
StartVersion: c.startTS,
|
||||
LockTtl: ttl,
|
||||
IsPessimisticLock: isPessimisticLock,
|
||||
ForUpdateTs: c.forUpdateTS,
|
||||
TxnSize: txnSize,
|
||||
MinCommitTs: minCommitTS,
|
||||
MaxCommitTs: c.maxCommitTS,
|
||||
AssertionLevel: assertionLevel,
|
||||
Mutations: mutations,
|
||||
PrimaryLock: c.primary(),
|
||||
StartVersion: c.startTS,
|
||||
LockTtl: ttl,
|
||||
PessimisticActions: pessimisticActions,
|
||||
ForUpdateTs: c.forUpdateTS,
|
||||
TxnSize: txnSize,
|
||||
MinCommitTs: minCommitTS,
|
||||
MaxCommitTs: c.maxCommitTS,
|
||||
AssertionLevel: assertionLevel,
|
||||
}
|
||||
|
||||
if _, err := util.EvalFailpoint("invalidMaxCommitTS"); err == nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue