Open Closed

Problem with dbContext.SessionHandle = null in DeleteDirectAsync method #6114


User avatar
0
dev3.advantiss created

Hello,
I use Identity Server...
After upgrade ABP from 5.3.3 to 7.3.1 I have a problem...
The repositories MongoDeviceFlowCodesRepository and MongoPersistentGrantRepository invoke method DeleteDirectAsync
{
....
await collection.DeleteManyAsync(
dbContext.SessionHandle,
Builders<PersistedGrant>.Filter.Where(predicate),
cancellationToken: cancellationToken
);
....
}

but dbContext.SessionHandle = null and that method is crashed

I replaced these Repositories, so I will not use dbContext.SessionHandle if it is null.

this code appeared in 7.3.1,

  1. why you start using dbContext.SessionHandle?

  2. what is best decision for solve this problem?

  • ABP Framework version: v7.3.1

  • UI Type: Angular

  • Database System: MongoDB

  • Exception message and full stack trace:
    2023-11-01 03:10:13.137 +00:00 [ERR] Job DEFAULT.Volo.Abp.IdentityServer.Tokens.TokenCleanupBackgroundWorker threw an unhandled Exception:
    System.ArgumentNullException: Value cannot be null. (Parameter 'session')
    at MongoDB.Driver.Core.Misc.Ensure.IsNotNull[T](T value, String paramName)
    at MongoDB.Driver.MongoCollectionImpl1.BulkWriteAsync(IClientSessionHandle session, IEnumerable1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
    at MongoDB.Driver.MongoCollectionBase1.DeleteManyAsync(FilterDefinition1 filter, DeleteOptions options, Func3 bulkWriteFuncAsync) at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository2.DeleteDirectAsync(Expression1 predicate, CancellationToken cancellationToken) at Volo.Abp.IdentityServer.MongoDB.MongoPersistentGrantRepository.DeleteExpirationAsync(DateTime maxExpirationDate, CancellationToken cancellationToken) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupService.RemoveGrantsAsync() at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupService.CleanAsync() at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupBackgroundWorker.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) at Volo.Abp.BackgroundWorkers.Quartz.QuartzPeriodicBackgroundWorkerAdapter1.Execute(IJobExecutionContext context)
    at Quartz.Core.JobRunShell.Run(CancellationToken cancellationToken)
    2023-11-01 03:10:13.226 +00:00 [ERR] Job DEFAULT.Volo.Abp.IdentityServer.Tokens.TokenCleanupBackgroundWorker threw an exception.
    Quartz.SchedulerException: Job threw an unhandled exception.
    ---> System.ArgumentNullException: Value cannot be null. (Parameter 'session')
    at MongoDB.Driver.Core.Misc.Ensure.IsNotNull[T](T value, String paramName)
    at MongoDB.Driver.MongoCollectionImpl1.BulkWriteAsync(IClientSessionHandle session, IEnumerable1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
    at MongoDB.Driver.MongoCollectionBase1.DeleteManyAsync(FilterDefinition1 filter, DeleteOptions options, Func3 bulkWriteFuncAsync) at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository2.DeleteDirectAsync(Expression1 predicate, CancellationToken cancellationToken) at Volo.Abp.IdentityServer.MongoDB.MongoPersistentGrantRepository.DeleteExpirationAsync(DateTime maxExpirationDate, CancellationToken cancellationToken) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupService.RemoveGrantsAsync() at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupService.CleanAsync() at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupBackgroundWorker.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) at Volo.Abp.BackgroundWorkers.Quartz.QuartzPeriodicBackgroundWorkerAdapter1.Execute(IJobExecutionContext context)
    at Quartz.Core.JobRunShell.Run(CancellationToken cancellationToken)
    --- End of inner exception stack trace --- [See nested exception: System.ArgumentNullException: Value cannot be null. (Parameter 'session')
    at MongoDB.Driver.Core.Misc.Ensure.IsNotNull[T](T value, String paramName)
    at MongoDB.Driver.MongoCollectionImpl1.BulkWriteAsync(IClientSessionHandle session, IEnumerable1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
    at MongoDB.Driver.MongoCollectionBase1.DeleteManyAsync(FilterDefinition1 filter, DeleteOptions options, Func3 bulkWriteFuncAsync) at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository2.DeleteDirectAsync(Expression1 predicate, CancellationToken cancellationToken) at Volo.Abp.IdentityServer.MongoDB.MongoPersistentGrantRepository.DeleteExpirationAsync(DateTime maxExpirationDate, CancellationToken cancellationToken) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupService.RemoveGrantsAsync() at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupService.CleanAsync() at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupBackgroundWorker.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) at Volo.Abp.BackgroundWorkers.Quartz.QuartzPeriodicBackgroundWorkerAdapter1.Execute(IJobExecutionContext context)
    at Quartz.Core.JobRunShell.Run(CancellationToken cancellationToken)]


3 Answer(s)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 18, 2025, 10:42