Base solution for your next web application
Open Closed

Entity Not Found exception - when the users connects to the site after a few days #5690


User avatar
0
[email protected] created

There is no such an entity. Entity type: <tenant>.<companyurl>Authorization.Roles.Role

On our Test site (Tenant testing) - the user seems to be getting this error almost everytime they connect after a day or so... I have tried reproducing the error but am unable to reproduce. Also not so sure if the may be related to user session or memory caching. Any assistance\ pointer will be appriciated.

See attached logs

2455 [ERROR] Abp.AspNetCore.Mvc.ExceptionHandling.AbpExceptionFilter
> There is no such an entity. Entity type: <tenant>.<companyurl>.Authorization.Roles.Role, id: 5
Abp.Domain.Entities.EntityNotFoundException: There is no such an entity. Entity type: <tenant>.<companyurl>.Authorization.Roles.Role, id: 5
at Abp.Domain.Repositories.AbpRepositoryBase`2.&lt;GetAsync&gt;d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Threading.InternalAsyncHelper.&lt;AwaitTaskWithPostActionAndFinallyAndGetResult&gt;d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Roles.AbpRoleManager`2.&lt;&gt;c__DisplayClass46_0.&lt;&lt;GetRolePermissionCacheItemAsync&gt;b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Runtime.Caching.CacheExtensions.&lt;&gt;c__DisplayClass5_0`2.<<GetAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Runtime.Caching.CacheBase.<GetAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Runtime.Caching.CacheExtensions.<GetAsync>d__5`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Roles.AbpRoleManager`2.<GetRolePermissionCacheItemAsync>d__46.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Roles.AbpRoleManager`2.&lt;IsGrantedAsync&gt;d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Users.AbpUserManager`2.<IsGrantedAsync>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Users.AbpUserManager`2.&lt;IsGrantedAsync&gt;d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.PermissionChecker`2.<IsGrantedAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.PermissionChecker`2.&lt;IsGrantedAsync&gt;d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Web.Configuration.AbpUserConfigurationBuilder.&lt;GetUserAuthConfig&gt;d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Web.Configuration.AbpUserConfigurationBuilder.&lt;GetAll&gt;d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.AspNetCore.Mvc.Controllers.AbpUserConfigurationController.&lt;GetAll&gt;d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at lambda_method(Closure , Object )
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.&lt;InvokeNextActionFilterAsync&gt;d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.&lt;InvokeInnerFilterAsync&gt;d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.&lt;InvokeNextExceptionFilterAsync&gt;d__23.MoveNext()
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

20 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Does role with Id = 5 exist in the table?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    [email protected] created

    Yes it does. Infact as soon as I clear the Cache from the Host Site... everything seems to be all good after until the next time.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    alper created
    Support Team

    hi,

    To clearify things, I have 2 questions

    1- Is there any other Host (behind load balancer etc...). I am asking because if any other instance of the backbone inserts into the database, the other instance might have problem. 2- Is there any custom code that you insert into the AbpRoles table?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    [email protected] created

    Sure. 1- This is just our test envrionment - so only one database host. 2 - No - there is no custom code around roles and or permissions tables.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ryancyq created
    Support Team

    which AspNetZero version you are using ?

    could you log the value of AbpSession.TenantId to see if it is the correct tenant (or host) that you want ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    [email protected] created

    AspNetZero - 5.4 AbpSession.TenantId was as expected and correct.

    I have a theory - may be one you could correct me if not correct.

    "If the application has not been accessed for 24 hours we would see this error appear and based on the log i think the cache still exist but the Cached objects (entity) are no longer present or corrupt. (I have only just been able to see the error my self for the first time today. hence the theory)"

    Hopefully my theory makes sense

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ryancyq created
    Support Team

    Do you see similar error outside of AbpUserConfigurationController.GetAll() ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    [email protected] created

    I can't be sure cause it has been hard to reproduce in dev but NO.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, can you check if both AbpSession.TenantId and TenantId of CurrentUnitOfWork are the same?

    TenantId of CurrentUnitOfWork can be obtained by the following:

    if (_unitOfWorkManager.Current != null)
    {
        var tenantId = _unitOfWorkManager.Current.GetTenantId();
    }
    
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @[email protected]

    Could you also share your AspNet Zero version ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    [email protected] created

    @ismcagdas

    • AspNet Zero Version - v5.4.1

    @ryancyq

    • it has been hard to reproduce but i am very sure the tenant id were the same...
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    alper created
    Support Team

    Are you still struggling with this issue?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    [email protected] created

    @alper Yes we are still seeing this pop up all the time - haven't got a fix yet.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @[email protected]

    Are you using PostgreSQL ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    [email protected] created

    @ismcagdas SQL Server Web Edition 14.00.3015.40.v1

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    [email protected] created

    @ismcagdas - that seems to be purely related to PostgreSQL - I have said above we are using SQL Server Web Edition 14.00.3015.40.v1?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, [email protected], can you try with [UnitOfWork(IsTransactional=false)] on TokenAuthController.Authenticate()? to check if the error still occurs?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    cangunaydin created

    Hello, I have exactly the same error, is there any solution for this problem? i am using AspNet Zero v5.6.2 I use Sql Server 2017. I also think that there is a problem when the site is not reached or somehow when the user keep the same browser session for a long time. But i am super sure that this is not related with database. Cause after i get this error from the client i tried to do impersonation and i get exactly the same error. And When you restart iis the problem is going away.

    and here is the stack trace for the error if you are curious.

    ERROR 2018-12-17 10:34:56,118 [136 ] Mvc.ExceptionHandling.AbpExceptionFilter - There is no such an entity. Entity type: ByteBrick.BookAndAd.Authorization.Roles.Role, id: 1 Abp.Domain.Entities.EntityNotFoundException: There is no such an entity. Entity type: ByteBrick.BookAndAd.Authorization.Roles.Role, id: 1 at Abp.Domain.Repositories.AbpRepositoryBase2.<GetAsync>d__21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Roles.AbpRoleManager2.<>c__DisplayClass50_0.<<GetRolePermissionCacheItemAsync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Runtime.Caching.CacheExtensions.<>c__DisplayClass5_02.<<GetAsync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Runtime.Caching.CacheBase.<GetAsync>d__19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Runtime.Caching.CacheExtensions.<GetAsync>d__52.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Roles.AbpRoleManager2.<GetRolePermissionCacheItemAsync>d__50.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Roles.AbpRoleManager2.<IsGrantedAsync>d__31.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Users.AbpUserManager2.<IsGrantedAsync>d__40.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Users.AbpUserManager2.<IsGrantedAsync>d__38.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.PermissionChecker2.<IsGrantedAsync>d__19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.PermissionChecker`2.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Please reopen if this issue is not fixed.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)