Commit 91f43d6
xds/resolver: drop field references on Close to prevent retention across ClientConn recycle (#9301)
Retention is via multiple field references off `*xdsResolver` that
survive `Close`:
- `r.cc` → the `ClientConn`, whose `ServiceConfig` still transitively
references the resolver
- `r.curConfigSelector` → captured by the `ClientConn`'s `ServiceConfig`
via `UpdateState`
- `r.dm` / `r.xdsClient` → watcher metadata held by the shared
`xdsclient.DefaultPool` singleton, which survives every ClientConn
lifetime
Individually each field is a benign back-reference; together they form
multiple independent retention chains through externally-anchored state.
Go's tracing GC handles cycles fine, but these aren't cycles — they're
chains rooted at package-global state (the shared xdsClient pool) and
other ClientConns that stay alive.
Explicitly dropping the field references at the end of `Close` leaves
the resolver struct with no outbound edges. The entire per-channel
resolver + CDS balancer subtree (roughly 40 `CallbackSerializer`s,
JSON-parsed service configs, `attributes.Attributes` chains, cloned
`[]resolver.Address` slices per channel) becomes GC-collectible.
RELEASE NOTES: None
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6d697e4 commit 91f43d6
3 files changed
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1212 | 1212 | | |
1213 | 1213 | | |
1214 | 1214 | | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
1215 | 1221 | | |
1216 | 1222 | | |
1217 | 1223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
305 | 320 | | |
306 | 321 | | |
307 | 322 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
206 | 212 | | |
207 | 213 | | |
208 | 214 | | |
| |||
999 | 1005 | | |
1000 | 1006 | | |
1001 | 1007 | | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
1002 | 1015 | | |
1003 | 1016 | | |
1004 | 1017 | | |
| |||
0 commit comments