@@ -1240,3 +1240,38 @@ func TestGlobalIndexStatistics(t *testing.T) {
1240
1240
"└─IndexRangeScan_11 4.00 cop[tikv] table:t, index:idx(b) range:[-inf,16), keep order:true" ))
1241
1241
}
1242
1242
}
1243
+
1244
+ func TestIssues24349 (t * testing.T ) {
1245
+ store := testkit .CreateMockStore (t )
1246
+ testKit := testkit .NewTestKit (t , store )
1247
+ testKit .MustExec ("use test" )
1248
+ testKit .MustExec ("set @@tidb_partition_prune_mode='dynamic'" )
1249
+ testKit .MustExec ("set @@tidb_analyze_version=2" )
1250
+ defer testKit .MustExec ("set @@tidb_analyze_version=1" )
1251
+ defer testKit .MustExec ("set @@tidb_partition_prune_mode='static'" )
1252
+ testIssues24349 (testKit )
1253
+ }
1254
+
1255
+ func TestIssues24349WithConcurrency (t * testing.T ) {
1256
+ store := testkit .CreateMockStore (t )
1257
+ testKit := testkit .NewTestKit (t , store )
1258
+ testKit .MustExec ("use test" )
1259
+ testKit .MustExec ("set @@tidb_partition_prune_mode='dynamic'" )
1260
+ testKit .MustExec ("set @@tidb_analyze_version=2" )
1261
+ testKit .MustExec ("set global tidb_merge_partition_stats_concurrency=2" )
1262
+ defer testKit .MustExec ("set @@tidb_analyze_version=1" )
1263
+ defer testKit .MustExec ("set @@tidb_partition_prune_mode='static'" )
1264
+ defer testKit .MustExec ("set global tidb_merge_partition_stats_concurrency=1" )
1265
+ testIssues24349 (testKit )
1266
+ }
1267
+
1268
+ func testIssues24349 (testKit * testkit.TestKit ) {
1269
+ testKit .MustExec ("create table t (a int, b int) partition by hash(a) partitions 3" )
1270
+ testKit .MustExec ("insert into t values (0, 3), (0, 3), (0, 3), (0, 2), (1, 1), (1, 2), (1, 2), (1, 2), (1, 3), (1, 4), (2, 1), (2, 1)" )
1271
+ testKit .MustExec ("analyze table t with 1 topn, 3 buckets" )
1272
+ testKit .MustQuery ("show stats_buckets where partition_name='global'" ).Check (testkit .Rows (
1273
+ "test t global a 0 0 2 2 0 2 0" ,
1274
+ "test t global b 0 0 3 1 1 2 0" ,
1275
+ "test t global b 0 1 10 1 4 4 0" ,
1276
+ ))
1277
+ }
0 commit comments