[GODRIVER-1653] Ensure AbortTransaction can run even if context expires during WithTransaction Created: 16/Jun/20  Updated: 28/Oct/23  Resolved: 19/Aug/20

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

Type: Improvement 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 the WithTransaction code, we use the context passed to WithTransaction to call AbortTransaction. This means that AbortTransaction would fail if the context timed out or was cancelled during the execution of the user-supplied callback and we'd leave an in-progress transaction running after returning.

I'm not sure how to best mitigate this. We could run AbortTransaction with context.Background() to ensure it can execute, but this is a deviation from the behavior of contexts because we shouldn't be doing blocking work once the context has expired.



 Comments   
Comment by Githook User [ 19/Aug/20 ]

Author:

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

Message: GODRIVER-1653 Use non-timeout context when aborting in WithTransaction (#484)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/d113e604b0cf11668667ca69d95931645eae8ed0

Comment by Divjot Arora (Inactive) [ 14/Aug/20 ]

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

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