-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Go Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Detailed steps to reproduce the problem?
Mongosync ran into a "transaction already in progress" error. Looking at the code, mongosync only ever calls session.WithTransaction() a second time with the same session as the first call if the first returned an error. From this convo https://mongodb.slack.com/archives/C7WJZNUTA/p1715012926709339 and this comment in WithTransaction it looks like the driver doesn't abort the transaction after a CommitTransaction error. Therefore, the TransactionState doesn't get updated, resulting in ErrTransactInProgress.
These are the series of steps:
- mongosync called sessionA.WithTransaction()
- an error was returned (likely from a CommitTransaction error)
- mongosync called sessionA.WithTransaction() again
- it saw ErrTransactInProgress
Definition of done: what must be done to consider the task complete?
It seems like aborting a txn after a failed CommitTransaction is dangerous. Another implementation could be to introduce a new TransactionState, but I'll defer to y'alls judgement.
The expected external behavior after this change would look like this:
- call WithTransaction() with sessionA
- see an error
- call WithTransaction() with sessionA again
- don't see ErrTransactInProgress
The exact Go version used, with patch level:
$ go version
1.20
The exact version of the Go driver used:
$ go list -m go.mongodb.org/mongo-driver
1.11.9
Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.
N/A
The operating system and version (e.g. Windows 7, OSX 10.8, ...)
Linux (redhat8)
Security Vulnerabilities
N/A