Commit 8f57f68
authored
Shutdown quiesced conn managers when removed from pool (#2268)
Motivation:
In some rare situations the connection manager can leak a promise on
deinit. The connection pool maintains the refs to these managers and
they are only dropped in two situations:
1. when the pool is shutdown
2. when a quiescing connection is removed from the pool
When the pool is shutdown all conn managers are also shutdown (which
will complete all promises stored in its state).
When a conn is going away the conn manager relies on events from the
channel pipeline to inform it that it can close. When it closes the pool
will remove the ref to the conn manager and do a few bits of cleanup. If
the conn closes gracefully then all is well. However, if that isn't the
case then a reconnect may kick in (creating new promises). At this point
there is a conn manager attempting reconnects but which is no longer
managed by the pool: this is a bug in and of itself.
The conn manager is also kept alive by a ref from the channel it is
currently managing (via a channel handler), it's possible that at some
point during the connection lifecycle that that ref is dropped and
there's nothing keeping the conn manager alive, but this is speculative.
The fix for this is straightforward: for conn managers which are
quiescing shut them down when they are removed from the pool.
Modifications:
- Shutdown conn manager when its last connection is dropped
Result:
Fewer leaking promises1 parent a531ab9 commit 8f57f68
File tree
2 files changed
+6
-0
lines changed- Sources/GRPC
- ConnectionPool
2 files changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1218 | 1218 | | |
1219 | 1219 | | |
1220 | 1220 | | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
1221 | 1226 | | |
1222 | 1227 | | |
1223 | 1228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
| 763 | + | |
763 | 764 | | |
764 | 765 | | |
765 | 766 | | |
| |||
0 commit comments