[CSHARP-2473] Multiple startTransaction: true for simultaneous operations Created: 08/Jan/19 Updated: 27/Oct/23 Resolved: 09/Jan/19 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Transactions |
| Affects Version/s: | 2.7.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ivan Artemov | Assignee: | Unassigned |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 10 |
||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
When we need to use code like this:
causes error: Cannot specify 'startTransaction' on transaction 1 since it is already in progress. All this operations go to Mongo with startTransaction: true argument, but only first operation must use this option. This very strange behaviour in Server API and looks like crutch. (as it looks now) Why we use session.StartTransaction() and operations must known about transaction ? Why this logic leaked from sessions to operations? This bug is not driver bug, but you need to fix it on your side. |
| Comments |
| Comment by Ivan Artemov [ 09/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I understand, but my questions is why 2 independent operations depend on it run order? Why session transaction logic leaked to operation layer? It normal code for many systems, i don't want change operation order, because MongoDB driver can't work with unordered method calling.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dmitry Lukyanov (Inactive) [ 09/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Session is not multi-thread safe. Using the same session in two parallel Tasks results in this error because both Tasks think they are the first operation in the transaction. So, this code works as designed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ivan Artemov [ 09/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ivan Artemov [ 09/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I attach 100% reproducable example for .NET Core 2.2 application (sorry, that not Github)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dmitry Lukyanov (Inactive) [ 09/Jan/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Dear ZOXEXIVO, I wasn't able to reproduce the behavior which you described. Could you please provide more details about this issue like where is the session started in your example, where is the transaction started? It would be really helpful if you could create a small Console application that reproduces this behavior. Thank you. |