LiteDB
LiteDB copied to clipboard
[BUG] Error in parallel Insert (Also Upsert)
Version Which LiteDB version/OS/.NET framework version are you using. 5.0.11
Describe the bug
/**************/
Unhandled exception. System.Exception: LiteDB ENSURE: transaction must be active to rollback (current state: Disposed)
at LiteDB.Constants.ENSURE(Boolean conditional, String message)
at LiteDB.Engine.TransactionService.Rollback()
at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func2 fn) at LiteDB.LiteCollection
1.Insert(T entity)
at ALPRDesigned.Classes.IO.PlateSaveToLocation(CameraDetection _EE, Native native) in C:\Users\Rahmati-PC\source\repos\ALPRDesigned\Classes\IO.cs:line 72
at ALPRDesigned.Classes.Camera_PlateDetector.OnPlateDetectedForHighway(Native native, PlateResult result) in C:\Users\Rahmati-PC\source\repos\ALPRDesigned\Classes\Camera_PlateDetector\ForHighWay.cs:line 94
at ALPRDesigned.Classes.Camera_PlateDetector.<>c__DisplayClass13_0.<PlateFeatureExtract>b__0() in C:\Users\Rahmati-PC\source\repos\ALPRDesigned\Classes\Camera_PlateDetector\Main.cs:line 119
/*************/
Code to Reproduce Write a small snippet to isolate your bug and could be possible to our team test. in MultiThread insert, The above error occurs.
- Approximately 10 to 20 storage per second. The size of each storage is 500 bytes
Screenshots/Stacktrace
This happens very often. And the problem is it hides original Exception. Because it's in the catch clause, that Rollback() is called and without a new try/catch, so original Exception is lost forever and instead you get this RollBack in Diposed state Exception. I don't know which is more important one, original, or RollBack or maybe both with something like AggregateException? And maybe in catch clause one should check if it already Disposed and impossible to Rollback?