We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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描述 在ego初始化后注册econf.OnChange回调会出现数据竞争 另外在ego初始化后操作组件也可能出现此情况(未验证)
BUG复现方法 1.代码
package main import ( "github.com/gotomicro/ego" "github.com/gotomicro/ego/core/econf" ) type Mysql struct { Dsn string } func main() { ego.New() econf.OnChange(func(c *econf.Configuration) {}) }
2.执行命令go run -race ./cmd/ego/main.go --config=./configs/main/config.toml 3.报错信息
================== WARNING: DATA RACE Write at 0x00c0001228a0 by main goroutine: github.com/gotomicro/ego/core/econf.(*Configuration).OnChange() /go/pkg/mod/github.com/gotomicro/ego@v1.1.9/core/econf/conf.go:72 +0xf3 github.com/gotomicro/ego/core/econf.OnChange() /go/pkg/mod/github.com/gotomicro/ego@v1.1.9/core/econf/api.go:36 +0x32 main.main() /workspaces/coreadmin/cmd/ego/main.go:15 +0x31 Previous read at 0x00c0001228a0 by goroutine 29: github.com/gotomicro/ego/core/econf.(*Configuration).LoadFromDataSource.func1() /go/pkg/mod/github.com/gotomicro/ego@v1.1.9/core/econf/conf.go:92 +0x64 Goroutine 29 (running) created at: github.com/gotomicro/ego/core/econf.(*Configuration).LoadFromDataSource() /go/pkg/mod/github.com/gotomicro/ego@v1.1.9/core/econf/conf.go:90 +0x316 github.com/gotomicro/ego/core/econf.LoadFromDataSource() /go/pkg/mod/github.com/gotomicro/ego@v1.1.9/core/econf/api.go:48 +0x4a6 github.com/gotomicro/ego.loadConfig() /go/pkg/mod/github.com/gotomicro/ego@v1.1.9/ego_function.go:171 +0x450 github.com/gotomicro/ego.runSerialFuncReturnError() /go/pkg/mod/github.com/gotomicro/ego@v1.1.9/ego_function.go:262 +0x16bd github.com/gotomicro/ego.New() /go/pkg/mod/github.com/gotomicro/ego@v1.1.9/ego.go:124 +0x1623 main.main() /workspaces/coreadmin/cmd/ego/main.go:13 +0x30 ================== Found 1 data race(s) exit status 66
3.ego中出现异常的代码行
The text was updated successfully, but these errors were encountered:
:
嗯。看了,这个应该之前也有问题。 之前考虑的时候,先注册后所有的监听配置,然后for循环在执行这些监听,所以不会有这个问题。
目前来看也可能,用户在for循环执行这些监听的同时,可能还会并发的注册一些监听配置。
所以要加个锁,更保险点,后面加上这个逻辑。
Sorry, something went wrong.
askuy
Successfully merging a pull request may close this issue.
BUG描述
在ego初始化后注册econf.OnChange回调会出现数据竞争
另外在ego初始化后操作组件也可能出现此情况(未验证)
BUG复现方法
1.代码
2.执行命令go run -race ./cmd/ego/main.go --config=./configs/main/config.toml
3.报错信息
3.ego中出现异常的代码行
The text was updated successfully, but these errors were encountered: