How does the ABP supports mongodb's multi-document transactions? I encountered the following problem when I specified the mongodb's connection string with "readPreference=secondaryPreferred", is there any solution to this issue, e.g., auto switch to ".WithReadPreference(ReadPreference.Primary)" when encountering a multi-document transaction and the connection string was specified with "readPreference=secondaryPreferred". I noticed that adding a tenant and adding a tenant's admin user is a multi-document transaction in your tenant module.
* Unhandled exception. System.InvalidOperationException: **Read preference in a transaction must be primary**.
at MongoDB.Driver.MongoCollectionImpl`1.CreateReadBinding(IClientSessionHandle session, ReadPreference readPreference)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperationAsync[TResult](IClientSessionHandle session, IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.AggregateAsync[TResult](IClientSessionHandle session, PipelineDefinition`2 pipeline, AggregateOptions options, CancellationToken cancellationToken)
at MongoDB.Driver.IAsyncCursorSourceExtensions.ToListAsync[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
at Volo.Abp.SettingManagement.MongoDB.MongoSettingRepository.GetListAsync(String providerName, String providerKey, CancellationToken cancellationToken)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Volo.Abp.SettingManagement.SettingManagementStore.SetCacheItemsAsync(String providerName, String providerKey, String currentName, SettingCacheItem currentCacheItem)
at Volo.Abp.SettingManagement.SettingManagementStore.GetCacheItemAsync(String name, String providerName, String providerKey)
at Volo.Abp.SettingManagement.SettingManagementStore.GetOrNullAsync(String name, String providerName, String providerKey)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Volo.Abp.Settings.TenantSettingValueProvider.GetOrNullAsync(SettingDefinition setting)
at Volo.Abp.Settings.SettingProvider.GetOrNullValueFromProvidersAsync(IEnumerable`1 providers, SettingDefinition setting)
at Volo.Abp.Settings.SettingProvider.GetOrNullAsync(String name)
at Volo.Abp.Settings.SettingProviderExtensions.GetAsync[T](ISettingProvider settingProvider, String name, T defaultValue)
at Volo.Abp.Identity.AbpIdentityOptionsManager.OverrideOptionsAsync(String name, IdentityOptions options)
at Volo.Abp.Identity.IdentityDataSeeder.SeedAsync(String adminEmail, String adminPassword, Nullable`1 tenantId)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Volo.Abp.Data.DataSeeder.SeedAsync(DataSeedContext context)
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, Func`3 proceed)
at TechInvest.Chat.Data.ChatDbMigrationService.SeedDataAsync(Tenant tenant) in /src/src/TechInvest.Chat.Domain/Data/ChatDbMigrationService.cs:line 97
at TechInvest.Chat.Data.ChatDbMigrationService.MigrateAsync() in /src/src/TechInvest.Chat.Domain/Data/ChatDbMigrationService.cs:line 47
at TechInvest.Chat.DbMigrator.DbMigratorHostedService.StartAsync(CancellationToken cancellationToken) in /src/src/TechInvest.Chat.DbMigrator/DbMigratorHostedService.cs:line 44
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2021-05-13 10:20:36.630 +08:00 [ERR] An unhandled exception has occurred while executing the request.
AutoMapper.AutoMapperMappingException: Error mapping types.
Mapping types:
Object -> List`1
System.Object -> System.Collections.Generic.List`1[[IdentityServer4.Models.ApiResource, IdentityServer4.Storage, Version=4.1.1.0, Culture=neutral, PublicKeyToken=f294d0afe402bb2b]]
---> AutoMapper.AutoMapperMappingException: Error mapping types.
Mapping types:
ApiResource -> ApiResource
Volo.Abp.IdentityServer.ApiResources.ApiResource -> IdentityServer4.Models.ApiResource
Type Map configuration:
ApiResource -> ApiResource
Volo.Abp.IdentityServer.ApiResources.ApiResource -> IdentityServer4.Models.ApiResource
Destination Member:
Properties
---> AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.
Mapping types:
ApiResourceProperty -> KeyValuePair`2
Volo.Abp.IdentityServer.ApiResources.ApiResourceProperty -> System.Collections.Generic.KeyValuePair`2[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
at lambda_method864(Closure , ApiResourceProperty , KeyValuePair`2 , ResolutionContext )
at lambda_method863(Closure , Object , List`1 , ResolutionContext )
--- End of inner exception stack trace ---
at lambda_method863(Closure , Object , List`1 , ResolutionContext )
--- End of inner exception stack trace ---
at lambda_method863(Closure , Object , List`1 , ResolutionContext )
at Volo.Abp.AutoMapper.AutoMapperAutoObjectMappingProvider.Map[TSource,TDestination](Object source)
at Volo.Abp.ObjectMapping.DefaultObjectMapper.AutoMap[TSource,TDestination](Object source)
at Volo.Abp.ObjectMapping.DefaultObjectMapper.Map[TSource,TDestination](TSource source)
at Volo.Abp.IdentityServer.ResourceStore.GetAllResourcesAsync()
at IdentityServer4.Stores.IResourceStoreExtensions.GetAllEnabledResourcesAsync(IResourceStore store)
at IdentityServer4.ResponseHandling.DiscoveryResponseGenerator.CreateDiscoveryDocumentAsync(String baseUrl, String issuerUri)
at IdentityServer4.Endpoints.DiscoveryEndpoint.ProcessAsync(HttpContext context)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)
at IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
I found the type of the "Properties" property of class "Volo.Abp.IdentityServer.ApiResources.ApiResource" is "List<ApiResourceProperty>", but the type of the "Properties" property of class "IdentityServer4.Models.ApiResource" is "IDictionary<string, string>", is this a bug or i forgot some configs about some abp modules?
I tried to upload a file using IFormFile, but an error occurred when generating the proxy, See this:
Did I miss something? The API like this:
Found an issue on github: https://github.com/abpframework/abp/issues/6384
Currently we have a project which contains two sets of service packs. Amongst one is API project (one solution, let's call it Api1), another is a server project (another solution, let's call it Server1). For Server1 we plan not to have any database dependencies, only through HTTP requesting the necessary information from Api1. As a result, we delete the Database-related dependencies in Server1, but it will have follow problems:
In total, we want to use the tenant module, permission module & CurrentUser functions without depending on any database operations, is this possible? If so, how?