LiteDB icon indicating copy to clipboard operation
LiteDB copied to clipboard

[BUG] Dispose can throw Exception (some Writing options problem)

Open ArsenijK opened this issue 2 years ago • 0 comments

Version LiteDB 5.0.11 .NET Framework 4.7.2

Describe the bug Sometimes Dispose() can throw exception, which is not recommended. Exception arises probably because you create files with some advanced flags, and during Dispose, you try to write something there, which probably isn't aligned like it should be with those flags. Maybe something like described here: https://devblogs.microsoft.com/oldnewthing/20100414-00/?p=14333

Expected behavior First, Dispose shouldn't throw Exceptions. Second, probably there is some bug, I did not dig that deep into code. But either flags are too aggressive or your writing during dispose does not adhere to those aggressive strategies and writes in wrong chunks at CheckpointInternal()

Stacktrace Caused By: System.IO.IOException · IO operation will not work. Most likely the file will become too long or the handle was not opened to support synchronous IO operations.unknown System.IO.FileStream.WriteCore(byte[] buffer, int offset, int count) LiteDB.Engine.DiskService.Write(IEnumerable<T> pages, FileOrigin origin) LiteDB.Engine.WalIndexService.CheckpointInternal() LiteDB.Engine.WalIndexService.TryCheckpoint() LiteDB.Engine.LiteEngine.Dispose(bool disposing) LiteDB.Engine.LiteEngine.Dispose() LiteDB.LiteDatabase.Dispose(bool disposing)

ArsenijK avatar May 12 '22 08:05 ArsenijK