Vanillaxi opened a new pull request, #3482:
URL: https://github.com/apache/dubbo-go/pull/3482

   ### Description
   Fixes #3480
   
   This PR fixes a potential stale provider issue in the Polaris 
interface-level registry path.
   
   `LoadSubscribeInstances` synchronously loads the initial provider instances 
and notifies `RegistryDirectory` with incremental `ADD` events. Later, the 
first successful `WatchService` response contains the current full instance 
snapshot, but the existing implementation also forwards it only as incremental 
`ADD` events.
   
   If provider A is loaded synchronously and disappears or is replaced by 
provider B before the watcher is established, the directory receives:
   
   ```
   LoadSubscribeInstances: [A] -> ADD(A)
   WatchService snapshot:  [B] -> ADD(B)
   ```
   
   The fix stores the valid instances notified by `LoadSubscribeInstances` as a 
per-service initial snapshot and transfers it to the corresponding 
`PolarisServiceWatcher` before listener creation can start the watcher.
   
   When the first successful `WatchService` full snapshot arrives, the watcher 
compares it with the initial snapshot using `model.InstanceKey`. Instances 
present in the initial snapshot but absent from the current snapshot emit `DEL` 
events first, after which the current instances continue to be published as 
`ADD` events.
   
   For example:
   ```
   Initial snapshot: [A]
   First watcher snapshot: [B]
   Emitted events: DEL(A), ADD(B)
   ```
   
   The initial snapshot is consumed only once. Failed `WatchService` attempts 
do not consume it, and the existing add, update, delete, and reconnect behavior 
after the first successful snapshot remains unchanged.
   
   This change is limited to the Polaris interface-level registry path and does 
not affect the application-level service discovery path.
   
   This PR also adds regression tests covering:
   
   - the initial provider A being replaced by B;
   - an empty first watcher snapshot removing the initial provider;
   - the production snapshot-transfer path before listener creation;
   - identical instance keys with different Polaris instance IDs;
   - one-time snapshot consumption;
   - invalid instances not entering the initial baseline;
   - empty loads clearing stale baselines;
   - defensive copying of registry and watcher snapshots;
   - stable ordering of generated delete events.
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] Code has passed local testing
   - [x] I have added tests that prove my fix is effective or that my feature 
works
   


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