-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Not Needed
-
When running Session.WithTransaction, the BAAS team are seeing data being committed to the database despite a context cancelation.
The BAAS team is issuing the transaction with the code here: https://github.com/rukumar333/baas/blob/BAAS-24930/realm/sync/server/transactionbroker/registry.go#L414
The error being returned by the WithTransaction is
context canceled
The BAAS team uses this fork of the Go Driver in production: https://github.com/mongodb-forks/mongo-go-driver/tree/release/v1.10.7-baas
Edit:
Pairing with rushil.kumar@mongodb.com , we can re-create the issue by adding the following code above the "CommitLoop" on either the BAAS fork or the v1 Go Driver branch:
ctx, cancel := context.WithCancel(ctx) go func() { fmt.Println("timer started") timer := time.NewTimer(time.Duration(10 * time.Millisecond)) select { case <-timer.C: fmt.Println("cancel") cancel() } }()
This will result in errors such as the following:
canceled while checking out a connection from connection pool: context canceled; total connections: 0, maxPoolSize: 100, idle connections: 0, wait duration: 250ns
The Go Driver documentation for Session.WithTransaction notes that you should not use the method with a cancelable context:
Because this method must succeed to ensure that server-side resources are properly cleaned up, context deadlines and cancellations will not be respected during this call.
Open question for triage: Is this a Go Driver bug?
- is related to
-
GODRIVER-3060 Investigate updating documentation for CommitTransaction
- Closed
- related to
-
GODRIVER-2565 Context cancelation before transaction commit does not abort
- Closed