[GODRIVER-1609] ConnectionClosed events not published when pool is disconnecting Created: 08/May/20  Updated: 28/Oct/23  Resolved: 07/Jul/20

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.3.5

Type: Bug Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Divjot Arora (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In pool.go, ConnectionClosed events are published in the expiration-checking function and in disconnect for forcefully-closed connections. This doesn't cover all cases though, because connections closed gracefully during disconnect don't go through the expiration checker and connections that encounter network errors manually call pool.removeConnnection on themselves. We can move the event-firing to closeConnection and removeConnection because all cases go through one of those. We'll have to store the reason for closing (e.g. idle, pool closing, etc) on the connection so the event can be published correctly.

 

The timer variable in pool.disconnect is incorrect. It calculates the time to fire as now-contextDeadline, which will be negative if the deadline is in the future. I don't know why that timer is there at all. I think the ctx.Done() + ticker cases cover everything we need.



 Comments   
Comment by Githook User [ 07/Jul/20 ]

Author:

{'name': 'Divjot Arora', 'email': 'divjot.arora@10gen.com', 'username': 'divjotarora'}

Message: GODRIVER-1609 Ensure a single ConnectionClosed event is emitted per connection (#438)
Branch: release/1.3
https://github.com/mongodb/mongo-go-driver/commit/ccdbaf26f5ac897f996a45fe9780d3e9f253690e

Comment by Githook User [ 07/Jul/20 ]

Author:

{'name': 'Divjot Arora', 'email': 'divjot.arora@10gen.com', 'username': 'divjotarora'}

Message: GODRIVER-1609 Ensure a single ConnectionClosed event is emitted per connection (#438)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/5c8752d66d7841767c4c65fc57808f79abdfb1bb

Generated at Thu Feb 08 08:36:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.