MCPcopy
hub / github.com/pingcap/tidb / TestIssue20692

Function TestIssue20692

pkg/planner/core/point_get_plan_test.go:177–215  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175}
176
177func TestIssue20692(t *testing.T) {
178 store := testkit.CreateMockStore(t)
179 tk := testkit.NewTestKit(t, store)
180 tk.MustExec("use test")
181 tk.MustExec("drop table if exists t")
182 tk.MustExec("create table t (id int primary key, v int, vv int, vvv int, unique key u0(id, v, vv));")
183 tk.MustExec("insert into t values(1, 1, 1, 1);")
184 tk1 := testkit.NewTestKit(t, store)
185 tk2 := testkit.NewTestKit(t, store)
186 tk3 := testkit.NewTestKit(t, store)
187 tk1.MustExec("begin pessimistic;")
188 tk1.MustExec("use test")
189 tk2.MustExec("begin pessimistic;")
190 tk2.MustExec("use test")
191 tk3.MustExec("begin pessimistic;")
192 tk3.MustExec("use test")
193 tk1.MustExec("delete from t where id = 1 and v = 1 and vv = 1;")
194 stop1, stop2 := make(chan struct{}), make(chan struct{})
195 go func() {
196 tk2.MustExec("insert into t values(1, 2, 3, 4);")
197 stop1 <- struct{}{}
198 tk3.MustExec("update t set id = 10, v = 20, vv = 30, vvv = 40 where id = 1 and v = 2 and vv = 3;")
199 stop2 <- struct{}{}
200 }()
201 tk1.MustExec("commit;")
202 <-stop1
203
204 // wait 50ms to ensure tk3 is blocked by tk2
205 select {
206 case <-stop2:
207 t.Fail()
208 case <-time.After(50 * time.Millisecond):
209 }
210
211 tk2.MustExec("commit;")
212 <-stop2
213 tk3.MustExec("commit;")
214 tk3.MustQuery("select * from t;").Check(testkit.Rows("10 20 30 40"))
215}
216
217func TestIssue18042(t *testing.T) {
218 store := testkit.CreateMockStore(t)

Callers

nothing calls this directly

Calls 6

MustExecMethod · 0.95
MustQueryMethod · 0.95
CreateMockStoreFunction · 0.92
NewTestKitFunction · 0.92
RowsFunction · 0.92
CheckMethod · 0.65

Tested by

no test coverage detected