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,
- why you start using dbContext.SessionHandle?
- 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.MongoCollectionImpl
1.BulkWriteAsync(IClientSessionHandle session, IEnumerable
1 requests, BulkWriteOptions options, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionBase1.DeleteManyAsync(FilterDefinition
1 filter, DeleteOptions options, Func3 bulkWriteFuncAsync) at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository
2.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.CastleAsyncAbpInterceptorAdapter
1.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.CastleAsyncAbpInterceptorAdapter
1.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.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupBackgroundWorker.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) at Volo.Abp.BackgroundWorkers.Quartz.QuartzPeriodicBackgroundWorkerAdapter
1.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, IEnumerable
1 requests, BulkWriteOptions options, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionBase1.DeleteManyAsync(FilterDefinition
1 filter, DeleteOptions options, Func3 bulkWriteFuncAsync) at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository
2.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.CastleAsyncAbpInterceptorAdapter
1.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.CastleAsyncAbpInterceptorAdapter
1.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.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupBackgroundWorker.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) at Volo.Abp.BackgroundWorkers.Quartz.QuartzPeriodicBackgroundWorkerAdapter
1.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, IEnumerable
1 requests, BulkWriteOptions options, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionBase1.DeleteManyAsync(FilterDefinition
1 filter, DeleteOptions options, Func3 bulkWriteFuncAsync) at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository
2.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.CastleAsyncAbpInterceptorAdapter
1.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.CastleAsyncAbpInterceptorAdapter
1.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.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Abp.IdentityServer.Tokens.TokenCleanupBackgroundWorker.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) at Volo.Abp.BackgroundWorkers.Quartz.QuartzPeriodicBackgroundWorkerAdapter
1.Execute(IJobExecutionContext context) at Quartz.Core.JobRunShell.Run(CancellationToken cancellationToken)]
3 Answer(s)
-
0
hi
why you start using dbContext.SessionHandle?
You can take a look at this PR https://github.com/abpframework/abp/pull/5174
what is best decision for solve this problem?
You should use the session as you can.
-
0
Hi
so, Is it normal "I replaced these Repositories, so I will not use dbContext.SessionHandle if it is null"?
-
0
Keep your repository the same as abp will be best.
https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs