Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] "The process was terminated due to an unhandled exception." without any application trigger #2561

Open
kerenor23 opened this issue Nov 4, 2024 · 0 comments
Labels

Comments

@kerenor23
Copy link

Version
LiteDB 5.0.20, Windows 10, .NET8

Describe the bug
We suspect some background task running and eventually crashing the process. This is the stack trace that was available on Win Event viewer for the process crash:

Application: ILM.exe CoreCLR Version: 8.0.23.53103 .NET Version: 8.0.0
Description: The process was terminated due to an unhandled exception. 
Exception Info: 
LiteDB.LiteException: current thread must contains transaction parameter at 
LiteDB.Engine.TransactionMonitor.ReleaseTransaction(TransactionService transaction) 
at LiteDB.Engine.TransactionService.Dispose(Boolean dispose) 
at LiteDB.Engine.TransactionService.Finalize()

The process log doesn't show any access to the DB at this time (but a connection to the DB is still open)

There were errors that occurred 15 minutes before:

  1. 09:14:35.645 - ENSURE error in Update:
    LiteDB.LiteException: empty page must be defined as empty type
    at void LiteDB.Constants.ENSURE(bool conditional, string message)
    at T LiteDB.Engine.Snapshot.NewPage<T>()
    at DataPage LiteDB.Engine.Snapshot.GetFreeDataPage(int bytesLength)
    at void LiteDB.Engine.DataService.Update(CollectionPage col, PageAddress blockAddress, BsonDocument doc)+source()
    at bool LiteDB.Engine.BufferWriter.MoveForward(int count)
    at int LiteDB.Engine.BufferWriter.Write(byte[] buffer, int offset, int count)
    at void LiteDB.Engine.BufferWriter.WriteElement(string key, BsonValue value)
    at int LiteDB.Engine.BufferWriter.WriteDocument(BsonDocument value, bool recalc)
    at void LiteDB.Engine.DataService.Update(CollectionPage col, PageAddress blockAddress, BsonDocument doc)
    at bool LiteDB.Engine.LiteEngine.UpdateDocument(Snapshot snapshot, CollectionPage col, BsonDocument doc, IndexService indexer, DataService data)
    at int LiteDB.Engine.LiteEngine.Update(string collection, IEnumerable<BsonDocument> docs)+(TransactionService transaction) => { }
    at T LiteDB.Engine.LiteEngine.AutoTransaction<T>(Func<TransactionService, T> fn)
    at bool LiteDB.LiteCollection<T>.Update(T entity)
    
    
  2. 09:14:35.881 - When the above is caught, our app attempts to rebuild, which so far worked fine-ish. This time rebuild the DB failed with the error "The process cannot access the file because it is being used by another process.". This alone is incredibly strange because our app opens the DB in Mode=Exclusive;.
  3. The app then closes & opens the DB with Dispose() and recreation - this seemed to have gone without errors (again... with Mode=Exclusive;. ). Following calls to Update succeeded.
  4. 09:29:12.358 - 15 minutes after the errors - the process crashes with the above stack trace in event viewer. This doesn't seem to have happen during any application call to the DB, and every application call to the DB try-catches and would log this.

Code to Reproduce
We don't have code to reproduce. So far this happened once, unknown how.

Expected behavior
We'd like to not crash surprisingly

@kerenor23 kerenor23 added the bug label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant