[GODRIVER-1849] ErrWaitQueueTimeout should wrap context error Created: 22/Jan/21  Updated: 28/Oct/23  Resolved: 01/Feb/21

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

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


 Description   

When a request to acquire a semaphore in a connection pool returns an error, we return ErrWaitQueueTimeout here. However, this would only happen if the context has timed out or been cancelled, so the final user-facing error should wrap ctx.Err(). This would allow the user to do errors.Is(err, context.DeadlineExceeded) and also allow our mongo.IsTimeout() function to detect this case.

We can't do this while also keeping the sentinel ErrWaitQueueTimeout value, but this is private API and users are likely not checking for it directly, so I propose we remove that error and instead introduce a new error type that wraps ctx.Err(), has an Unwrap method, and keeps the same message as ErrWaitQueueTimeout in case users are checking for substrings.



 Comments   
Comment by Kevin Albertson [ 11/Feb/21 ]

Cherry-picked onto release/1.5 with https://github.com/mongodb/mongo-go-driver/commit/64d19e6d0fa964062883fa01441237c38ad7bf32

Comment by Githook User [ 01/Feb/21 ]

Author:

{'name': 'Benjamin Rewis', 'email': 'benji.rewis@mongodb.com', 'username': 'benjirewis'}

Message: GODRIVER-1849 Add new WaitQueueTimeoutError to wrap context error (#568)
Branch: release/1.4
https://github.com/mongodb/mongo-go-driver/commit/b04775266e304c96a13399e89129edbb15e8edb6

Comment by Githook User [ 01/Feb/21 ]

Author:

{'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}

Message: GODRIVER-1849 Add new WaitQueueTimeoutError to wrap context error (#568)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/54681e1af6f3c0ea4761ae8a998034bcbd4e7a43

Comment by Benji Rewis (Inactive) [ 28/Jan/21 ]

https://github.com/mongodb/mongo-go-driver/pull/568

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