question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] LiteDB ENSURE: stored slot must be same as called

See original GitHub issue

Version 5.0.10 .NET 4.7 Windows 2016

Describe the bug

I have a database in version 5.0.10. When upserting I got this error => “LiteDB ENSURE: stored slot must be same as called” and then it keet doing it If I reopen the database i got this error : LiteDB ENSURE: invalid segment position and then when inserting the previous errors is coming back.

Code to Reproduce

I can send the database (73MO)

Screenshots/Stacktrace

System.Exception: LiteDB ENSURE: stored slot must be same as called at LiteDB.Constants.ENSURE(Boolean conditional, String message) at LiteDB.Engine.Snapshot.GetFreeDataPage(Int32 bytesLength) at LiteDB.Engine.DataService.<>c__DisplayClass3_0.<<Insert>g__source|0>d.MoveNext() at LiteDB.Engine.BufferWriter…ctor(IEnumerable1 source) at LiteDB.Engine.DataService.Insert(BsonDocument doc) at LiteDB.Engine.LiteEngine.InsertDocument(Snapshot snapshot, BsonDocument doc, BsonAutoId autoId, IndexService indexer, DataService data) at LiteDB.Engine.LiteEngine.<>c__DisplayClass31_0.<Upsert>b__0(TransactionService transaction) at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func2 fn) at LiteDB.LiteCollection`1.Upsert(T entity)

Thanks in advance for the help.

Regards

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
BenWoodfordcommented, Nov 18, 2022

FYI for all: I managed to make a system for detecting this and repairing the DB by running .Rebuild() which failed due to trying to insert a duplicate ID, so I catch the exception, get all the data out of the DB by just using FindAll, and then create a new one fresh and insert the data into that one, then for the sake of cleanliness my application closes and re-opens to ensure a clean slate.

1reaction
honorewcommented, May 25, 2021

Is there a solution? Me too

Read more comments on GitHub >

github_iconTop Results From Across the Web

LiteDB
When trying to call OrderBy while reading data from the collection, an error occurs with the message LiteDB ENSURE: buffer size must be...
Read more >
LiteDB.xml 0.4.2
This expression must return a new document that will be replaced over current document (according with predicate). Eg: col.UpdateMany("{ Name: UPPER($.Name), ...
Read more >
LiteDB
LiteDB is a small, fast and lightweight .NET NoSQL embedded database. Serverless NoSQL Document Store; Simple API, similar to MongoDB; 100% C# code...
Read more >
Versions - Eco - English Wiki
Strange Loop Games regularly releases updates to Eco. New versions are available for download at Strange Loop Games' website and are ...
Read more >
LiteDb collection returns invalid data when searching by id
I try to find entity by its id in liteDb. But the wrong entity returns as a result (with another id). It's reproduced...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found