(t *testing.T)
| 175 | } |
| 176 | |
| 177 | func 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 | |
| 217 | func TestIssue18042(t *testing.T) { |
| 218 | store := testkit.CreateMockStore(t) |
nothing calls this directly
no test coverage detected