litedb-org / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.66k stars 1.25k forks source link

[Bug] System.Exception: LiteDB ENSURE: get only index below highest index #2264

Open srinicrick65 opened 1 year ago

srinicrick65 commented 1 year ago

Version We used both 5.0.11 and 5.0.12

Describe the bug We are trying to read the data from the LiteDB Collection using GetEntityCollection and we are getting the below exception

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. System.Exception: LiteDB ENSURE: get only index below highest index at LiteDB.Constants.ENSURE(Boolean conditional, String message) at LiteDB.Engine.BasePage.Get(Byte index) at LiteDB.Engine.DataService.Read(PageAddress address)+MoveNext() at LiteDB.Engine.BufferReader..ctor(IEnumerable1 source, Boolean utcDate) at LiteDB.Engine.DatafileLookup.Load(PageAddress rawId) at LiteDB.Engine.BasePipe.LoadDocument(IEnumerable1 nodes)+MoveNext() at LiteDB.Engine.QueryPipe.Select(IEnumerable1 source, BsonExpression select)+MoveNext() at LiteDB.Engine.QueryExecutor.<>c__DisplayClass10_0.<<ExecuteQuery>g__RunQuery|0>d.MoveNext() at LiteDB.BsonDataReader.Read() at LiteDB.LiteQueryable1.ToDocuments()+MoveNext() at System.Linq.Enumerable.SelectEnumerableIterator2.ToList() at Cloud.IAMMiddleware.DataAccess.LiteDbService1.GetEntityCollection(Int32 pagenumber, Int32 pagesize, String sortParam, String queryParamFilter)

Expected behavior Ideal scenario is it should be fetching the data from the LiteDB.

Screenshots/Stacktrace image

srinicrick65 commented 1 year ago

Hi Team Can someone provide response this ?

ProKn1fe commented 1 year ago

Some sample code to reproduce? Or at least a data model.

srinicrick65 commented 1 year ago

Hi @ProKn1fe We are performing basic CRUD operation . Sample model looks as below .

{
    "_id" : "802d5b66-b35b-483d-ae2b-ac3b09c7de82",
    "tags" : [ ],
    "deletedAt" : 0,
    "ctd" : true,
    "lmd" : 1670658945379,
    "cid" : "eed86ec6-fd4e-4279-b7f2-d7f732b5d62a",
    "scope" : "region",
    "name" : "Ability admin",
    "permissions" : [
        "solution_create",
        "solution_read",
        "solution_write",
        "solution_delete",
        "app_create",
        "app_read",
        "app_write",
        "app_delete",
        "tenant_create",
        "tenant_read",
        "tenant_write",
        "tenant_delete",
        "contract_create",
        "contract_read",
        "contract_write",
        "contract_delete",
        "user_create",
        "user_read",
        "user_write",
        "user_delete",
        "group_create",
        "group_read",
        "group_write",
        "group_delete",
        "identity_provider_create",
        "identity_provider_read",
        "identity_provider_write",
        "identity_provider_delete",
        "connectivity_provider_create",
        "connectivity_provider_read",
        "connectivity_provider_write",
        "connectivity_provider_delete",
        "role_create",
        "role_read",
        "role_write",
        "role_delete",
        "grant_create",
        "grant_read",
        "grant_write",
        "grant_delete",
        "permission_create",
        "permission_read",
        "permission_write",
        "permission_delete",
        "resource_create",
        "resource_read",
        "resource_write",
        "resource_delete",
        "operation_create",
        "operation_read",
        "operation_write",
        "operation_delete",
        "audit_log_read"
    ],
    "solutionId" : "30304e0f-af6d-480c-ae94-1d6c136ec94d"
}
shubhiroy commented 1 year ago

Facing similar issue @mbdavid - This issue is a blocker for our release.

image

coooool commented 1 year ago

I made the same mistake.

shubhiroy commented 1 year ago

What mistake @coooool ?

hmi95 commented 1 month ago

Does anyone know how to get rid of the problem?

1834021502 commented 1 month ago

It seems that the database file I created on Windows, when directly uploaded to Linux, causes this issue.