first of all thanks for your quick reply. Here the answers to your questions:
- NuGet MongoDB.Driver Version 2.13.2
- NuGet MongoDB.Bson Version 2.13.2
- NuGet MongoDB.Bson.NodaTime Version 3
Unfortunately I already removed that code. I have it in git, but the application itself is tremendous, so this wouldn’t help. What we basically do is we start an transaction in the DAL and every other part in the program reacts on events and uses the non-mongo-specific-functions of the DAL.
I was about to implement a part in the program which collected an exception and tried to write them as a document in the DB. Obviously, DB-exceptions telling me that the transaction was canceled for instance, resulted in an exception which I tried to store to the DB. Checking if an transaction is already active (using session.IsInTransaction) returns true even if the server session is not in transaction. I reported this “bug” before with code and the answer was that it “works as designed”: https://jira.mongodb.org/browse/CSHARP-3690
In other words: If the transactions is canceled server side the client has no chance to detect it apart from running into the next exception telling me that the transaction is not active or like in this case that I’m not able to start transaction x+1.
Back to this issue:
To be honest, later on I thought that I just faced this problem/exceptions when I was standing in the debugger holding the open transaction too long and the server canceled it. With this DB-timeout-exception I tried to insert another document with the following code:
Hope you can rebuild this case. Anyway I try to create an unit test example this weekend which reproduces the error. I’ll let you know here. If you are already aware of that behavior and you don’t need it let me know.
3.) With the unit test you should be able to see what’s happening on your system.
Thanks, cheers, Daniel