7
测试用例添加到`periodicalexecutor_test.go
, 执行:
go test -v -count 100 -test.run TestPeriodicalExecutor_Deadlock
原因应该是:
- Add开始
- AddAndCheck() 结束
- backgroundFlush正好超时退出
- Add阻塞在<-pe.confirmChan
func TestPeriodicalExecutor_Deadlock(t *testing.T) {
executer := NewBulkExecutor(func(tasks []interface{}) {
}, WithBulkTasks(1), WithBulkInterval(time.Millisecond))
for i := 0; i < 1e6; i++ {
executer.Add(1)
}
}