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

listen 顺序问题 #157

Closed
cloverstd opened this issue Jan 8, 2021 · 5 comments · Fixed by #158
Closed

listen 顺序问题 #157

cloverstd opened this issue Jan 8, 2021 · 5 comments · Fixed by #158
Assignees
Milestone

Comments

@cloverstd
Copy link
Contributor

https://github.com/zouyx/agollo/blob/e35bcef3d07be7326e222fe8eab5b9a59c5697cd/storage/repository.go#L371-L387

由于异步的去触发 change,change 在这里没有保证顺序,在 listener 里没法知道 listen 到的一定是最新的一次

@cloverstd
Copy link
Contributor Author

最快的修改方式是在 baseChangeEvent 里加上时间戳,因为轮训是有序的,每次创建 Event 时是可以有序的

@zouyx
Copy link
Member

zouyx commented Jan 8, 2021

https://github.com/zouyx/agollo/blob/e35bcef3d07be7326e222fe8eab5b9a59c5697cd/storage/repository.go#L371-L387

由于异步的去触发 change,change 在这里没有保证顺序,在 listener 里没法知道 listen 到的一定是最新的一次

是遇到什么具体场景的问题吗?可以提供一下场景吗?

@cloverstd
Copy link
Contributor Author

https://github.com/zouyx/agollo/blob/e35bcef3d07be7326e222fe8eab5b9a59c5697cd/storage/repository.go#L371-L387

由于异步的去触发 change,change 在这里没有保证顺序,在 listener 里没法知道 listen 到的一定是最新的一次

是遇到什么具体场景的问题吗?可以提供一下场景吗?

比如说我 listen 了 OnNewestChange 期望获取最新的配置

我连续两次在 apollo 修改了配置,比如说,A,B 两次操作,B 是后一次

OnNewestChange 会收到两次回调

但是 OnNewestChange 是在 goroutine 里执行的,由于 goroutine 的执行是无序的,所以我不确定我实现的 OnNewestChange 的执行顺序,也不知道是不是当前就是最新的

那么就会存在这种可能性,B 的配置所在 goroutine 先执行了,然后 A 后执行了,导致我用了 A(老的)的配置

@cloverstd
Copy link
Contributor Author

https://github.com/zouyx/agollo/blob/e35bcef3d07be7326e222fe8eab5b9a59c5697cd/storage/repository.go#L246-L250

这里异步写文件存在顺序的问题,可能文件里不是最新的配置

@zouyx zouyx linked a pull request Jan 14, 2021 that will close this issue
@zouyx
Copy link
Member

zouyx commented Feb 23, 2021

v4.0.4 has released

@zouyx zouyx closed this as completed Feb 23, 2021
@zouyx zouyx self-assigned this Feb 23, 2021
@zouyx zouyx added this to the v4.0.4 milestone Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants