AlexStocks commented on code in PR #3482:
URL: https://github.com/apache/dubbo-go/pull/3482#discussion_r3563426611


##########
registry/polaris/core.go:
##########
@@ -72,6 +76,76 @@ func (watcher *PolarisServiceWatcher) lazyRun() {
        })
 }
 
+// setInitialSnapshot stores synchronously loaded instances as the baseline for
+// reconciling the first successful watcher full snapshot.
+func (watcher *PolarisServiceWatcher) setInitialSnapshot(instances 
[]model.Instance) {
+       watcher.initialSnapshotLock.Lock()
+       defer watcher.initialSnapshotLock.Unlock()
+
+       // A watcher is reused per service. Never re-arm reconciliation after 
its first successful snapshot.
+       if watcher.initialSnapshotConsumed {

Review Comment:
   [P0] 复用 watcher 时会漏掉新订阅者的删除事件
   
   同一 service 的 watcher 会被复用;第一次全量快照后 `initialSnapshotConsumed` 永久为 
true。后续另一个订阅者先通过 `LoadSubscribeInstances` 收到旧实例,再进入这里时基线会被直接丢弃,而该订阅者加入前 watcher 
已处理过的删除事件不会重放,最终会长期保留已下线地址。请把初始快照补偿绑定到每个新 subscriber(或在 AddSubscriber 时向该 
subscriber 重放当前全量状态),并补充“同 service 第二个订阅者在 load/subscribe 间发生删除”的测试。



-- 
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]

Reply via email to