LiteDB: [BUG] System.Exception: LiteDB ENSURE: empty page must be defined as empty type
Version LiteDB v5.0.10 .NET Standard 2.1 Xamarin.Forms v5.0.0.2012
Describe the bug The database seems to get corrupted when I insert data. Here are multiple examples:
System.Exception: LiteDB ENSURE: empty page must be defined as empty type
at LiteDB.Constants.ENSURE (System.Boolean conditional, System.String message) [0x0002a] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.NewPage[T] () [0x000a3] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.GetFreeDataPage (System.Int32 bytesLength) [0x00081] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService+<>c__DisplayClass3_0+<<Insert>g__source|0>d.MoveNext () [0x00052] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.BufferWriter..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x00029] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService.Insert (LiteDB.BsonDocument doc) [0x0005d] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.InsertDocument (LiteDB.Engine.Snapshot snapshot, LiteDB.BsonDocument doc, LiteDB.BsonAutoId autoId, LiteDB.Engine.IndexService indexer, LiteDB.Engine.DataService data) [0x00094] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine+<>c__DisplayClass7_0.<Insert>b__0 (LiteDB.Engine.TransactionService transaction) [0x00076] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.AutoTransaction[T] (System.Func`2[T,TResult] fn) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.Insert (System.String collection, System.Collections.Generic.IEnumerable`1[T] docs, LiteDB.BsonAutoId autoId) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.LiteCollection`1[T].Insert (System.Collections.Generic.IEnumerable`1[T] entities) [0x00027] in <8e1f39e9bcf3452cab277acc385e2e12>:0
System.Exception: LiteDB ENSURE: empty page must be defined as empty type
at LiteDB.Constants.ENSURE (System.Boolean conditional, System.String message) [0x0002a] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.NewPage[T] () [0x000a3] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.GetFreeDataPage (System.Int32 bytesLength) [0x00081] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService+<>c__DisplayClass3_0+<<Insert>g__source|0>d.MoveNext () [0x00052] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.BufferWriter..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x00029] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService.Insert (LiteDB.BsonDocument doc) [0x0005d] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.InsertDocument (LiteDB.Engine.Snapshot snapshot, LiteDB.BsonDocument doc, LiteDB.BsonAutoId autoId, LiteDB.Engine.IndexService indexer, LiteDB.Engine.DataService data) [0x00094] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine+<>c__DisplayClass7_0.<Insert>b__0 (LiteDB.Engine.TransactionService transaction) [0x00076] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.AutoTransaction[T] (System.Func`2[T,TResult] fn) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.Insert (System.String collection, System.Collections.Generic.IEnumerable`1[T] docs, LiteDB.BsonAutoId autoId) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.LiteCollection`1[T].Insert (System.Collections.Generic.IEnumerable`1[T] entities) [0x00027] in <8e1f39e9bcf3452cab277acc385e2e12>:0
System.Exception: LiteDB ENSURE: empty page must be defined as empty type
at LiteDB.Constants.ENSURE (System.Boolean conditional, System.String message) [0x0002a] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.NewPage[T] () [0x000a3] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.GetFreeDataPage (System.Int32 bytesLength) [0x00081] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService+<>c__DisplayClass3_0+<<Insert>g__source|0>d.MoveNext () [0x00052] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.BufferWriter..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x00029] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService.Insert (LiteDB.BsonDocument doc) [0x0005d] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.InsertDocument (LiteDB.Engine.Snapshot snapshot, LiteDB.BsonDocument doc, LiteDB.BsonAutoId autoId, LiteDB.Engine.IndexService indexer, LiteDB.Engine.DataService data) [0x00094] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine+<>c__DisplayClass7_0.<Insert>b__0 (LiteDB.Engine.TransactionService transaction) [0x00076] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.AutoTransaction[T] (System.Func`2[T,TResult] fn) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.Insert (System.String collection, System.Collections.Generic.IEnumerable`1[T] docs, LiteDB.BsonAutoId autoId) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.LiteCollection`1[T].Insert (T entity) [0x0002e] in <8e1f39e9bcf3452cab277acc385e2e12>:0
System.AggregateException: One or more errors occurred. (LiteDB ENSURE: empty page must be defined as empty type) ---> System.Exception: LiteDB ENSURE: empty page must be defined as empty type
at LiteDB.Constants.ENSURE (System.Boolean conditional, System.String message) [0x0002a] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.NewPage[T] () [0x000a3] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.GetFreeDataPage (System.Int32 bytesLength) [0x00081] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService+<>c__DisplayClass3_0+<<Insert>g__source|0>d.MoveNext () [0x00052] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.BufferWriter..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x00029] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService.Insert (LiteDB.BsonDocument doc) [0x0005d] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.InsertDocument (LiteDB.Engine.Snapshot snapshot, LiteDB.BsonDocument doc, LiteDB.BsonAutoId autoId, LiteDB.Engine.IndexService indexer, LiteDB.Engine.DataService data) [0x00094] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine+<>c__DisplayClass7_0.<Insert>b__0 (LiteDB.Engine.TransactionService transaction) [0x00076] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.AutoTransaction[T] (System.Func`2[T,TResult] fn) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.Insert (System.String collection, System.Collections.Generic.IEnumerable`1[T] docs, LiteDB.BsonAutoId autoId) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.LiteCollection`1[T].Insert (T entity) [0x0002e] in <8e1f39e9bcf3452cab277acc385e2e12>:0
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.Exception: LiteDB ENSURE: empty page must be defined as empty type
at LiteDB.Constants.ENSURE (System.Boolean conditional, System.String message) [0x0002a] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.NewPage[T] () [0x000a3] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.Snapshot.GetFreeDataPage (System.Int32 bytesLength) [0x00081] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService+<>c__DisplayClass3_0+<<Insert>g__source|0>d.MoveNext () [0x00052] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.BufferWriter..ctor (System.Collections.Generic.IEnumerable`1[T] source) [0x00029] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.DataService.Insert (LiteDB.BsonDocument doc) [0x0005d] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.InsertDocument (LiteDB.Engine.Snapshot snapshot, LiteDB.BsonDocument doc, LiteDB.BsonAutoId autoId, LiteDB.Engine.IndexService indexer, LiteDB.Engine.DataService data) [0x00094] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine+<>c__DisplayClass7_0.<Insert>b__0 (LiteDB.Engine.TransactionService transaction) [0x00076] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.AutoTransaction[T] (System.Func`2[T,TResult] fn) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.Engine.LiteEngine.Insert (System.String collection, System.Collections.Generic.IEnumerable`1[T] docs, LiteDB.BsonAutoId autoId) [0x00055] in <8e1f39e9bcf3452cab277acc385e2e12>:0
at LiteDB.LiteCollection`1[T].Insert (T entity) [0x0002e] in <8e1f39e9bcf3452cab277acc385e2e12>:0
Code to Reproduce Unfortunately I cannot share code, since I could not reproduce it easily in a test project and I cannot share my business work. I can just say that I’m pretty sure I’m not doing any kind of magic with LiteDB; I’m using it basically just to store data (delete all, re insert, get all)
Expected behavior No exception.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 3
- Comments: 39 (7 by maintainers)
Hi guys, this ensure error avoid/detect corruption state. I will review this operations to try reproduce this error.
Hi, I also have this problem. It’s very important to us to arrive to solution. I can share my db file. and also my code.
When using
DeleteAll()
we gotLiteDB ENSURE: page type must be data page
error.One more thing :
if I try to delete by raw query from the LiteDbStudio - so it works ! BUT, same raw query, from code, using
Execute
- failed.Can you help please ?
I’m getting this issue when using Library with Hangfire.LiteDb. It seems that some entries end-up on the wrong page since the row 2 is the server status entry, not lock table entry