Skip to content

Commit 876f027

Browse files
authored
GODRIVER-1996 Send ConnectionPoolReady before resuming the maintain goroutine. (#1184)
1 parent c29474b commit 876f027

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

x/mongo/driver/topology/pool.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,21 @@ func (p *pool) ready() error {
239239
p.state = poolReady
240240
p.stateMu.Unlock()
241241

242-
// Signal maintain() to wake up immediately when marking the pool "ready".
243-
select {
244-
case p.maintainReady <- struct{}{}:
245-
default:
246-
}
247-
242+
// Send event.PoolReady before resuming the maintain() goroutine to guarantee that the
243+
// "pool ready" event is always sent before maintain() starts creating connections.
248244
if p.monitor != nil {
249245
p.monitor.Event(&event.PoolEvent{
250246
Type: event.PoolReady,
251247
Address: p.address.String(),
252248
})
253249
}
254250

251+
// Signal maintain() to wake up immediately when marking the pool "ready".
252+
select {
253+
case p.maintainReady <- struct{}{}:
254+
default:
255+
}
256+
255257
return nil
256258
}
257259

0 commit comments

Comments
 (0)