XnLemon commented on code in PR #1092:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1092#discussion_r4623975122
##########
admin/core/xds.go:
##########
@@ -101,8 +101,18 @@ func StartxDsServer(ctx context.Context) error {
)
// Establishing the watch before rebuilding closes the startup gap:
writes
- // that race with the full read remain queued on the watch channel.
- go watchConfigAndReload(ctx, publisher)
+ // that race with the full read remain queued on the watch channel.
Keep the
+ // watcher within this server's lifecycle so the etcd client stays alive
+ // until any in-flight snapshot build has finished.
+ watcherDone := make(chan struct{})
+ go func() {
+ defer close(watcherDone)
+ watchConfigAndReload(ctx, publisher)
+ }()
+ defer func() {
+ cancel()
+ <-watcherDone
Review Comment:
Fixed in `b0b8d1f7`. Snapshot building now carries the xDS lifecycle context
through listener and cluster etcd reads, so shutdown cancels in-flight reads
and lets the watcher exit before the etcd client is closed. I added regression
coverage for cancellation through the publisher and the etcd range read.
Validation passed: `go test -race -gcflags=-l ./admin/xds ./admin/logic
./admin/core ./cmd/admin -count=1 -timeout=5m`; `golangci-lint run
--new-from-rev=upstream/develop` (0 issues).
<details>
<summary>中文</summary>
已在 `b0b8d1f7` 修复。快照构建会把 xDS 生命周期 context 传递到 listeners 和 clusters 的 etcd
读取;关停时可以取消在途读取,并在关闭 etcd client 前让 watcher 退出。已补充 publisher 和 etcd range read
的取消回归测试。
验证通过:上述 race 测试;`golangci-lint run --new-from-rev=upstream/develop`(0
issues)。
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]