mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.62k stars 1.25k forks source link

[BUG] There is no more active transaction for this cursor xxx (5.0.16/5.0.17) #2351

Closed mw911 closed 5 months ago

mw911 commented 1 year ago

Version Windows 10, >=5.0.16 (was working fine in 5.0.15), .Net Framework 4.6

Describe the bug After updating to the new version I get the exception

LiteDB.LiteException: 'There is no more active transaction for this cursor: SELECT $ FROM Task WHERE ($.Enabled=@p0)'

Lets say I get 10 tasks and iterate through them then the exception comes on "Next" after processing the first Task object. I think it has to do with the update of the collection in between but it was always working in previous version.

Code to Reproduce Using db As New LiteDB.LiteDatabase(String.Format("Filename={0};connection=shared", DBLiteName)) Dim tasks = db.GetCollection(Of Task)("Task") For Each tsk As Task In tasks.Find(Function(t) t.Enabled = False) tsk.TaskHistory.Clear() tsk.HistoryList.Clear() tasks.Update(tsk) Next End Using

Expected behavior Code should iterate through all Tasks found as it was done in previous versions

Screenshots/Stacktrace at LiteDB.Engine.QueryExecutor.<>c__DisplayClass10_0.<gRunQuery|0>d.MoveNext() at LiteDB.BsonDataReader.Read() at LiteDB.SharedDataReader.Read() at LiteDB.LiteQueryable`1.d26.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at DBMonitor.DBMonitorServer.TimerExecutions_Tick(Object sender, EventArgs e) in

Additional context

mw911 commented 1 year ago

Additional comment: The same happens when I update another collection within For Each which has nothing to do with the "Task" collection

ejdre-vestas commented 1 year ago

We are facing a similar issue although it started happening on version 5.0.15 for us. We've recently updated to version 5.0.17 to see if it fixes the problem but it still fails at times.

In the short term, we'll likely revert to the version 5.0.11 which was stable and doesn't seem to have this error.

Edit: It actually started happening on version 5.0.16.

mw911 commented 1 year ago

@ejdre-vestas : Have you been able finding a workaround or the reason behind the problem?

JKamsker commented 5 months ago

Thank you for reporting this issue.

This issue should have been resolved in the latest version of LiteDB. Please update to the latest version of LiteDB to resolve this issue. If the issue persists, please let us know. But please provide a full repro (including data classes)