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

System.NotImplementedException: The method or operation is not implemented #1392

Open webteamby opened 4 years ago

webteamby commented 4 years ago

Got this error in v.5.0.0-beta:

_System.NotImplementedException: The method or operation is not implemented. at LiteDB.BufferSliceExtensions.ReadIndexKey(BufferSlice buffer, Int32 offset) at LiteDB.Engine.IndexNode..ctor(IndexPage page, Byte index, BufferSlice segment) at LiteDB.Engine.IndexService.AddNode(CollectionIndex index, BsonValue key, PageAddress dataBlock, Byte level, IndexNode last) at LiteDB.Engine.IndexService.AddNode(CollectionIndex index, BsonValue key, PageAddress dataBlock, IndexNode last) at LiteDB.Engine.LiteEngine.InsertDocument(Snapshot snapshot, BsonDocument doc, BsonAutoId autoId, IndexService indexer, DataService data) at LiteDB.Engine.LiteEngine.<>c__DisplayClass29_0.b_0(TransactionService transaction) at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func2 fn) at MigrationLibrary.DAL.Repository.Implementation.UserRepoLiteDb.Upsert(IEnumerable1 listEntities) in C:\src\UserRepoLiteDb.cs:line 86

webteamby commented 4 years ago

Another one error in v.5.0.0-beta:

System.NotImplementedException: The method or operation is not implemented. at LiteDB.BufferSliceExtensions.ReadIndexKey(BufferSlice buffer, Int32 offset) at LiteDB.Engine.IndexNode..ctor(IndexPage page, Byte index, BufferSlice segment) at LiteDB.Engine.IndexService.Find(CollectionIndex index, BsonValue value, Boolean sibling, Int32 order) at LiteDB.Engine.IndexEquals.Execute(IndexService indexer, CollectionIndex index)+MoveNext() at LiteDB.Engine.BasePipe.LoadDocument(IEnumerable1 nodes)+MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found) at LiteDB.BsonExpression.Execute(IEnumerable1 source) at LiteDB.Engine.QueryPipe.SelectAll(IEnumerable1 source, BsonExpression select)+MoveNext() at LiteDB.Engine.QueryExecutor.<>c__DisplayClass9_0.<g__RunQuery|0>d.MoveNext() at LiteDB.BsonDataReader..ctor(IEnumerable1 values, String collection) at LiteDB.Engine.QueryExecutor.ExecuteQuery(Boolean executionPlan) at LiteDB.Engine.LiteEngine.Query(String collection, Query query) at LiteDB.LiteQueryable1.ToDocuments()+MoveNext() at System.Linq.Enumerable.Single[TSource](IEnumerable1 source) at LiteDB.LiteQueryable1.Exists() at MigrationLibrary.DAL.Repository.Implementation.UserRepoLiteDb.Exists(Expression`1 filter)

JensSchadron commented 4 years ago

Hi @webteamby ,

Thanks for reporting both exceptions. I don't know if you had a way to reproduce those errors, but if so, could you please try doing it again using the latest v5 RC? Keep in mind though, that a change has been made between the beta and RC versions and are thus incompatible, so you'll need to recreate your database.

DennisAMenace commented 4 years ago

I am getting this error with 5.0.9 that is similar to OP's error.

---> System.NotImplementedException: The method or operation is not implemented.
   at LiteDB.BufferSliceExtensions.ReadIndexKey(BufferSlice buffer, Int32 offset)
   at LiteDB.Engine.IndexNode..ctor(IndexPage page, Byte index, BufferSlice segment)
   at LiteDB.Engine.IndexService.GetNodeList(PageAddress nodeAddress)+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToArray()
   at LiteDB.Engine.LiteEngine.UpdateDocument(Snapshot snapshot, CollectionPage col, BsonDocument doc, IndexService indexer, DataService data)
   at LiteDB.Engine.LiteEngine.<>c__DisplayClass30_0.<Upsert>b__0(TransactionService transaction)
   at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)

My database size is 38.2 MB

My litedb file opens fine in LiteDB Studio.

This error occured when .Upsert was called on my ILiteCollection<MyClass> object.

sondreb commented 3 years ago

This error still happens in the latest main repo source. The helper that get the Bson Type returns the value of 59 (in my instance here), which does not parse to any known type in the enum.

image

This is the method call that returns 59:

ExtendedLengthHelper.ReadLength(buffer[offset++], buffer[offset], out var type, out var len);

The offset value is 13:

image

This probably doesn't say much but:

image

sondreb commented 3 years ago

This still happens with the latest code from master, which includes an corruption fix that was added recently (https://github.com/mbdavid/LiteDB/commit/26bdeb673d95ca6078a4ed12a0f7ffc8d22e50a9)