LiteDatabase.Shrink throws 'System.Collections.Generic.KeyNotFoundException'
See original GitHub issueI 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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
System.Collections.Generic.KeyNotFoundException upon ...
I'm building an contact manager application using .Net 5.0 in Visual Studio 2019 Community Edition. I am using MySql Connector (MySql.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Bounz, this bug was fixed but it’s not on nuget… I forgot about him… 😨 I will release new version this weekend.
Hi @md-zamolxis, I made a
Recovery
static method inLiteEngine
to recovery datafile with link-pointer missing (like your example). It’s not 100% but works fine in my first example.So, I recovery your data and works fine in master branch (with shrink too). You can get lastest version of LiteDB and run over your datafile to check. If you got any problem, please, open another issue about this.