LiteDB: LiteDatabase.Shrink throws 'System.Collections.Generic.KeyNotFoundException'

I get KeyNotFoundException upon any attempt to load/view database. Database file that raises KeyNotFoundException is generated by more than one process accessing one database, so this may be concurrency issue.

Snippet to reproduce:

using (var database = new LiteDatabase("sample.litedb"))
            {
                database.Shrink();
            }

or

            using (var database = new LiteDatabase("sample.litedb"))
            {
                database.Engine.FindAll(database.GetCollectionNames().FirstOrDefault()).ToArray();               
            }

etc.

Database file in question included: sample.zip

Please tell me what the possible cause is and how to avoid it in future.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @Bounz, this bug was fixed but it’s not on nuget… I forgot about him… 😨 I will release new version this weekend.