@@ -365,3 +365,43 @@ func TestRetry(t *testing.T) {
365
365
}
366
366
require .NoError (t , failpoint .Disable ("github.com/pingcap/tidb/pkg/statistics/handle/syncload/mockReadStatsForOneFail" ))
367
367
}
368
+
369
+ func TestSendWaitTooLong (t * testing.T ) {
370
+ originConfig := config .GetGlobalConfig ()
371
+ newConfig := config .NewConfig ()
372
+ newConfig .Performance .StatsLoadConcurrency = - 1 // no worker to consume channel
373
+ newConfig .Performance .StatsLoadQueueSize = 1
374
+ config .StoreGlobalConfig (newConfig )
375
+ defer config .StoreGlobalConfig (originConfig )
376
+ store , dom := testkit .CreateMockStoreAndDomain (t )
377
+
378
+ tk := testkit .NewTestKit (t , store )
379
+ tk .MustExec ("use test" )
380
+ tk .MustExec ("create table t(a int, b int, c int, primary key(a), key idx(b,c))" )
381
+ tk .MustExec ("insert into t values (1,1,1),(2,2,2),(3,3,3)" )
382
+
383
+ oriLease := dom .StatsHandle ().Lease ()
384
+ dom .StatsHandle ().SetLease (1 )
385
+ defer func () {
386
+ dom .StatsHandle ().SetLease (oriLease )
387
+ }()
388
+ tk .MustExec ("analyze table t all columns" )
389
+ h := dom .StatsHandle ()
390
+ is := dom .InfoSchema ()
391
+ tbl , err := is .TableByName (context .Background (), pmodel .NewCIStr ("test" ), pmodel .NewCIStr ("t" ))
392
+ require .NoError (t , err )
393
+ tableInfo := tbl .Meta ()
394
+ neededColumns := make ([]model.StatsLoadItem , 0 , len (tableInfo .Columns ))
395
+ for _ , col := range tableInfo .Columns {
396
+ neededColumns = append (neededColumns , model.StatsLoadItem {TableItemID : model.TableItemID {TableID : tableInfo .ID , ID : col .ID , IsIndex : false }, FullLoad : true })
397
+ }
398
+ stmtCtx := stmtctx .NewStmtCtx ()
399
+ timeout := time .Nanosecond * 100
400
+ require .NoError (t , h .SendLoadRequests (stmtCtx , neededColumns , timeout ))
401
+ stmtCtx1 := stmtctx .NewStmtCtx ()
402
+ require .NoError (t , h .SendLoadRequests (stmtCtx1 , neededColumns , timeout ))
403
+ for _ , resultCh := range stmtCtx1 .StatsLoad .ResultCh {
404
+ rs1 , _ := <- resultCh
405
+ require .Error (t , rs1 .Err )
406
+ }
407
+ }
0 commit comments