yihao.dai 44d915a43b
fix: [2.5] Remove stale proxy clients on rewatch etcd (#46491)
### **User description**
AddProxyClients now removes clients not in the new snapshot before
adding new ones. This ensures proper cleanup when ProxyWatcher re-watche
etcd.

issue: https://github.com/milvus-io/milvus/issues/46397

pr: https://github.com/milvus-io/milvus/pull/46398


___

### **PR Type**
Bug fix


___

### **Description**
- Rename `AddProxyClients` to `SetProxyClients` for clearer semantics

- Implement stale client cleanup before adding new proxy clients

- Remove proxy clients not present in new etcd snapshot

- Update all callers in querycoord and rootcoord servers

- Regenerate mock files with mockery v2.53.3


___

### Diagram Walkthrough


```mermaid
flowchart LR
  A["ProxyWatcher detects<br/>etcd change"] -->|calls| B["SetProxyClients<br/>with new snapshot"]
  B -->|removes| C["Stale clients<br/>not in snapshot"]
  C -->|closes| D["Cleanup resources"]
  B -->|adds| E["New proxy clients<br/>from snapshot"]
```



<details><summary><h3>File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Bug
fix</strong></td><td><details><summary>3 files</summary><table>
<tr>
<td><strong>proxy_client_manager.go</strong><dd><code>Rename
AddProxyClients to SetProxyClients with cleanup</code>&nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-1a13e14654661bffe70ce626777d527871fcae62361a5fc18b7dca93e66afe1e">+22/-2</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>server.go</strong><dd><code>Update ProxyWatcher to use
SetProxyClients</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-87d7712e6df027656ba9d433fb77b702c185486130879be54204da2b8f092230">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>root_coord.go</strong><dd><code>Update ProxyWatcher
initialization to SetProxyClients</code>&nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-8fab0705c4ddb5f98e5955d3c3013fa795c87237a8525e189c3296d98dcce47f">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>1
files</summary><table>
<tr>
<td><strong>proxy_client_manager_test.go</strong><dd><code>Update test
for SetProxyClients stale removal</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-fb82a84e67ec187c1bfbdc4335c18b504b2f4392758d859e54115684ea8a526d">+26/-10</a>&nbsp;
</td>

</tr>

</table></details></td></tr><tr><td><strong>Miscellaneous</strong></td><td><details><summary>7
files</summary><table>
<tr>
<td><strong>mock_proxy_client_manager.go</strong><dd><code>Regenerate
mock with SetProxyClients method</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-8cc3cfe21d2694f58ebe7f2d44e12c467d9e83ac9edb37bcb6c7262e7b2ca09d">+78/-38</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>mock_proxy_watcher.go</strong><dd><code>Regenerate mock with
mockery v2.53.3</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-0c22e89cbee68c397abee52e797166fbac754b439eb1304baf53dd207e8f11d2">+9/-5</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mock_global_id_allocator.go</strong><dd><code>Regenerate
mock with mockery v2.53.3</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-1822c38f0a6c4225134bee554bf518d0b9184040ea5bb3d9e926515ae80655c8">+15/-3</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>mock_grpc_client.go</strong><dd><code>Regenerate mock with
mockery v2.53.3</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-6137f17eb7eef693d72c6181f519f7b1a87669a00f5268cbd7c3399567451e64">+33/-13</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>allocator.go</strong><dd><code>Regenerate mock with mockery
v2.53.3</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-e2482bb9748ad163ba57c65251355035f45c140f12214cd96cc5da88376fcc39">+26/-6</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>mock_factory.go</strong><dd><code>Regenerate mock with
mockery v2.53.3</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-bc91a5fcdc0bd52eaaaf805d15985fe578debbb2576eb0c97d08e0573d0132e6">+18/-2</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>mock_session.go</strong><dd><code>Regenerate mock with
mockery v2.53.3</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/milvus-io/milvus/pull/46491/files#diff-850f08ed9571fd6f3f84bd846fa29dab2d52be7c8f9d9b358fc667c6970a90e6">+79/-19</a>&nbsp;
</td>

</tr>
</table></details></td></tr></tbody></table>

</details>

___

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
2025-12-23 21:11:19 +08:00
..
2023-01-10 16:15:37 +08:00