-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
数据竞争bug #26
Comments
启动定时任务后立刻关闭产生的的竞争吧? |
这问题 不是立即关闭也会产生,如果有秒级别的定时任务 func (np *NodePool) tickerUpdatePool() 函数中的 for循环 频繁扫描 np.dcron.isRun,也很容易产生 |
|
@jinsuojinsuo 修复了 还没打tag ,你直接在 go.mod 里声明版本为 master 就可以用了。 |
好的感谢 |
轮训的时候只是读取,没有写入操作也不会产生竞争,不过频繁关闭启动的场景也确实需要修复。 |
Dcron.Start() //启动分布式定时任务
Dcron.Stop()//停止定时任务
会产生数据竞争
代码
`
//分布式定时任务路由
Dcron.Start() //启动分布式定时任务
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)
sign := <-quit //阻塞等待结束信号
utils.Logger().Info().Msgf("%v %v %v %+v", "SERVER_RUN", "server_close_sig", "", sign)
//停止定时任务
Dcron.Stop()
==================
WARNING: DATA RACE
Read at 0x00c000594038 by goroutine 46:
github.com/libi/dcron.(*NodePool).tickerUpdatePool()
C:/Users/yunwe/go/pkg/mod/github.com/libi/dcron@v0.2.2/node_pool.go:77 +0xfb
github.com/libi/dcron.(*NodePool).StartPool.func1()
C:/Users/yunwe/go/pkg/mod/github.com/libi/dcron@v0.2.2/node_pool.go:57 +0x39
Previous write at 0x00c000594038 by main goroutine:
github.com/libi/dcron.(*Dcron).Stop()
C:/Users/yunwe/go/pkg/mod/github.com/libi/dcron@v0.2.2/dcron.go:159 +0x39
main.main()
D:/code_qifan/jump_live/main.go:81 +0x486
Goroutine 46 (running) created at:
github.com/libi/dcron.(*NodePool).StartPool()
C:/Users/yunwe/go/pkg/mod/github.com/libi/dcron@v0.2.2/node_pool.go:57 +0x1e5
github.com/libi/dcron.(*Dcron).Start()
C:/Users/yunwe/go/pkg/mod/github.com/libi/dcron@v0.2.2/dcron.go:134 +0x84
main.main()
D:/code_qifan/jump_live/main.go:69 +0x271
`
The text was updated successfully, but these errors were encountered: