@@ -1336,14 +1336,32 @@ func TestGlobalIndexInsertInDropPartition(t *testing.T) {
1336
1336
partition p3 values less than (30)
1337
1337
);` )
1338
1338
tk .MustExec ("alter table test_global add unique index idx_b (b) global" )
1339
- tk .MustExec ("insert into test_global values (1, 1, 1), (8, 8, 8 ), (11, 11, 11), (12, 12, 12); " )
1339
+ tk .MustExec ("insert into test_global values (1, 1, 1), (2, 2, 2 ), (11, 11, 11), (12, 12, 12)" )
1340
1340
1341
+ doneMap := make (map [model.SchemaState ]struct {})
1341
1342
testfailpoint .EnableCall (t , "github.com/pingcap/tidb/pkg/ddl/onJobRunBefore" , func (job * model.Job ) {
1342
1343
assert .Equal (t , model .ActionDropTablePartition , job .Type )
1343
- if job .SchemaState == model .StateDeleteOnly {
1344
- tk2 := testkit .NewTestKit (t , store )
1345
- tk2 .MustExec ("use test" )
1346
- tk2 .MustExec ("insert into test_global values (9, 9, 9)" )
1344
+ if _ , ok := doneMap [job .SchemaState ]; ok {
1345
+ return
1346
+ }
1347
+ doneMap [job .SchemaState ] = struct {}{}
1348
+ tk2 := testkit .NewTestKit (t , store )
1349
+ tk2 .MustExec ("use test" )
1350
+ switch job .SchemaState {
1351
+ case model .StatePublic :
1352
+ tk2 .MustExec ("insert into test_global values (3, 3, 3)" )
1353
+ tk2 .MustExec ("insert into test_global values (13, 13, 13)" )
1354
+ case model .StateWriteOnly :
1355
+ tk2 .MustContainErrMsg ("insert into test_global values (4, 4, 4)" , "[table:1526]Table has no partition for value matching a partition being dropped, 'p1'" )
1356
+ tk2 .MustExec ("insert into test_global values (14, 14, 14)" )
1357
+ case model .StateDeleteOnly :
1358
+ tk2 .MustExec ("insert into test_global values (5, 5, 5)" )
1359
+ tk2 .MustExec ("insert into test_global values (15, 15, 15)" )
1360
+ case model .StateDeleteReorganization :
1361
+ tk2 .MustExec ("insert into test_global values (6, 6, 6)" )
1362
+ tk2 .MustExec ("insert into test_global values (16, 16, 16)" )
1363
+ default :
1364
+ require .Fail (t , "invalid schema state '%s'" , job .SchemaState .String ())
1347
1365
}
1348
1366
})
1349
1367
@@ -1352,7 +1370,7 @@ func TestGlobalIndexInsertInDropPartition(t *testing.T) {
1352
1370
tk1 .MustExec ("alter table test_global drop partition p1" )
1353
1371
1354
1372
tk .MustExec ("analyze table test_global" )
1355
- tk .MustQuery ("select * from test_global use index(idx_b) order by a" ).Check (testkit .Rows ("9 9 9 " , "11 11 11" , "12 12 12" ))
1373
+ tk .MustQuery ("select * from test_global use index(idx_b) order by a" ).Check (testkit .Rows ("5 5 5 " , "6 6 6" , " 11 11 11" , "12 12 12" , "13 13 13" , "14 14 14" , "15 15 15" , "16 16 16 " ))
1356
1374
}
1357
1375
1358
1376
func TestGlobalIndexUpdateInDropPartition (t * testing.T ) {
@@ -3168,10 +3186,10 @@ func TestRemovePartitioningAutoIDs(t *testing.T) {
3168
3186
tk3 .MustExec (`COMMIT` )
3169
3187
tk3 .MustQuery (`select _tidb_rowid, a, b from t` ).Sort ().Check (testkit .Rows (
3170
3188
"13 11 11" , "14 2 2" , "15 12 12" , "17 16 18" ,
3171
- "19 18 4" , "21 20 5" , "23 22 6" , "25 24 7" , "30 29 9" ))
3189
+ "19 18 4" , "21 20 5" , "23 22 6" , "25 24 7" , "29 28 9" ))
3172
3190
tk2 .MustQuery (`select _tidb_rowid, a, b from t` ).Sort ().Check (testkit .Rows (
3173
3191
"13 11 11" , "14 2 2" , "15 12 12" , "17 16 18" ,
3174
- "19 18 4" , "23 22 6" , "27 26 8" , "32 31 10" ))
3192
+ "19 18 4" , "23 22 6" , "27 26 8" , "31 30 10" ))
3175
3193
3176
3194
waitFor (4 , "t" , "write reorganization" )
3177
3195
tk3 .MustExec (`BEGIN` )
@@ -3181,30 +3199,66 @@ func TestRemovePartitioningAutoIDs(t *testing.T) {
3181
3199
tk3 .MustExec (`insert into t values (null, 23)` )
3182
3200
tk2 .MustExec (`COMMIT` )
3183
3201
3184
- /*
3185
- // Currently there is an duplicate entry issue, so it will rollback in WriteReorganization
3186
- // instead of continuing.
3187
- waitFor(4, "t", "delete reorganization")
3188
- tk2.MustExec(`BEGIN`)
3189
- tk2.MustExec(`insert into t values (null, 24)`)
3202
+ waitFor (4 , "t" , "delete reorganization" )
3203
+ tk2 .MustExec (`BEGIN` )
3204
+ tk2 .MustExec (`insert into t values (null, 24)` )
3190
3205
3191
- tk3.MustExec(`insert into t values (null, 25)`)
3192
- tk2.MustExec(`insert into t values (null, 26)`)
3193
- */
3206
+ tk3 .MustExec (`insert into t values (null, 25)` )
3207
+ tk2 .MustExec (`insert into t values (null, 26)` )
3194
3208
tk3 .MustExec (`COMMIT` )
3209
+ tk2 .MustQuery (`select _tidb_rowid, a, b from t` ).Sort ().Check (testkit .Rows (
3210
+ "27 26 8" ,
3211
+ "30012 12 12" ,
3212
+ "30013 18 4" ,
3213
+ "30014 24 7" ,
3214
+ "30015 16 18" ,
3215
+ "30016 22 6" ,
3216
+ "30017 28 9" ,
3217
+ "30018 11 11" ,
3218
+ "30019 2 2" ,
3219
+ "30020 20 5" ,
3220
+ "31 30 10" ,
3221
+ "35 34 22" ,
3222
+ "39 38 24" ,
3223
+ "43 42 26" ))
3195
3224
tk3 .MustQuery (`select _tidb_rowid, a, b from t` ).Sort ().Check (testkit .Rows (
3196
- "13 11 11" , "14 2 2" , "15 12 12" , "17 16 18" ,
3197
- "19 18 4" , "21 20 5" , "23 22 6" , "25 24 7" , "27 26 8" , "30 29 9" ,
3198
- "32 31 10" , "35 34 21" , "38 37 22" , "41 40 23" ))
3199
-
3200
- //waitFor(4, "t", "public")
3201
- //tk2.MustExec(`commit`)
3202
- // TODO: Investigate and fix, but it is also related to https://github.com/pingcap/tidb/issues/46904
3203
- require .ErrorContains (t , <- alterChan , "[kv:1062]Duplicate entry '31' for key 't.PRIMARY'" )
3225
+ "27 26 8" ,
3226
+ "30012 12 12" ,
3227
+ "30013 18 4" ,
3228
+ "30014 24 7" ,
3229
+ "30015 16 18" ,
3230
+ "30016 22 6" ,
3231
+ "30017 28 9" ,
3232
+ "30018 11 11" ,
3233
+ "30019 2 2" ,
3234
+ "30020 20 5" ,
3235
+ "31 30 10" ,
3236
+ "33 32 21" ,
3237
+ "35 34 22" ,
3238
+ "37 36 23" ,
3239
+ "41 40 25" ))
3240
+
3241
+ waitFor (4 , "t" , "public" )
3242
+ tk2 .MustExec (`commit` )
3204
3243
tk3 .MustQuery (`select _tidb_rowid, a, b from t` ).Sort ().Check (testkit .Rows (
3205
- "13 11 11" , "14 2 2" , "15 12 12" , "17 16 18" ,
3206
- "19 18 4" , "21 20 5" , "23 22 6" , "25 24 7" , "27 26 8" , "30 29 9" ,
3207
- "32 31 10" , "35 34 21" , "38 37 22" , "41 40 23" ))
3244
+ "27 26 8" ,
3245
+ "30012 12 12" ,
3246
+ "30013 18 4" ,
3247
+ "30014 24 7" ,
3248
+ "30015 16 18" ,
3249
+ "30016 22 6" ,
3250
+ "30017 28 9" ,
3251
+ "30018 11 11" ,
3252
+ "30019 2 2" ,
3253
+ "30020 20 5" ,
3254
+ "31 30 10" ,
3255
+ "33 32 21" ,
3256
+ "35 34 22" ,
3257
+ "37 36 23" ,
3258
+ "39 38 24" ,
3259
+ "41 40 25" ,
3260
+ "43 42 26" ))
3261
+ require .NoError (t , <- alterChan )
3208
3262
}
3209
3263
3210
3264
func TestAlterLastIntervalPartition (t * testing.T ) {
0 commit comments