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

Opening with ReadOnly=true an already opened Connection=direct database fails on Dispose #2349

Open superware opened 1 year ago

superware commented 1 year ago

Hello,

On v5.0.16, I have a database opened with Connection=direct (default) in one process.

Another process opens with ReadOnly=true, successfully opening and reading (GetCollection), but as soon as Dispose is called:

System.NotSupportedException: Stream does not support writing.
   at System.IO.__Error.WriteNotSupported()
   at System.IO.FileStream.Write(Byte[] array, Int32 offset, Int32 count)
   at LiteDB.Engine.DiskService.Write(IEnumerable`1 pages, FileOrigin origin)
   at LiteDB.Engine.WalIndexService.CheckpointInternal()
   at LiteDB.Engine.WalIndexService.TryCheckpoint()
   at LiteDB.Engine.LiteEngine.Dispose(Boolean disposing)
   at LiteDB.Engine.LiteEngine.Dispose()
   at LiteDB.LiteDatabase.Dispose(Boolean disposing)
   at LiteDB.LiteDatabase.Dispose()

Guessing ReadOnly=true should NEVER write anything, am I doing something wrong? Can this be fixed please?

Thank you in advance.

superware commented 1 year ago

Anyone?