Skip to content
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

ConfigClient并发问题 #481

Closed
wcvb13 opened this issue Jun 30, 2022 · 1 comment · Fixed by #483
Closed

ConfigClient并发问题 #481

wcvb13 opened this issue Jun 30, 2022 · 1 comment · Fixed by #483
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@wcvb13
Copy link
Contributor

wcvb13 commented Jun 30, 2022

if remakeId < client.currentTaskCount {

client.currentTaskCount = taskCount

这里client.currentTaskCount在测试时出现了data race

@wcvb13
Copy link
Contributor Author

wcvb13 commented Jun 30, 2022

测试代码如下:

func main() {
	sc := []constant.ServerConfig{
		*constant.NewServerConfig("127.0.0.1", 8848),
	}

	cc := constant.ClientConfig{
		TimeoutMs:           5000,
		NotLoadCacheAtStart: true,
		LogDir:              "/tmp/nacos/log",
		CacheDir:            "/tmp/nacos/cache",
		LogLevel:            "debug",
	}

	client, err := clients.NewConfigClient(
		vo.NacosClientParam{
			ClientConfig:  &cc,
			ServerConfigs: sc,
		},
	)
	if err != nil {
		panic(err)
	}
	_, pErr := client.PublishConfig(vo.ConfigParam{DataId: "test.yaml", Group: "test", Content: "test: test"})
	if pErr != nil {
		fmt.Println(pErr)
		return
	}
	content := make(chan string, 100)
	e := client.ListenConfig(vo.ConfigParam{
		DataId: "test.yaml",
		Group:  "test",
		OnChange: func(_, group, dataId, data string) {
			if dataId == "test.yaml" && group == "test" {
				fmt.Println("input data: " + data)
				content <- data
			}
		},
	})
	if e != nil {
		fmt.Println(e)
		return
	}
	_, pErr = client.PublishConfig(vo.ConfigParam{DataId: "test.yaml", Group: "test", Content: "test: test"})
	if pErr != nil {
		fmt.Println(pErr)
		return
	}
	err = client.CancelListenConfig(vo.ConfigParam{DataId: "test.yaml", Group: "test"})
	if err != nil {
		fmt.Println(err)
		return
	}
}

@binbin0325 binbin0325 added bug Something isn't working good first issue Good for newcomers labels Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants