Activities of "shijo"

Working... Thanks for your support

Hi, One more issue regarding this. Once I logged in with one User, The user validated across all tenants, How can I be forced to log out the user once a tenant is changed?

  • ABP Framework version: v7.0
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

We are experiencing delays in reading records from the table while heavy jobs are running. How can we read data from the table while ignoring locks without disabling UOW transaction?

isolationLevel

Hi, Do I need to set UOW isolation level in reading api logic ??

hi

If you just read and return to the frontend, I think there is generally no need to set this option. The default is enough.

Hi, Where should I do add this logic ? Is it in my background job ? After running the background job (which is a long-running process), there is a delay in data reading.

Hi,

Background job is simple distributted event which is doing CRUD operations by using entity methods. Inside this method we are not using _unitOfWorkManager instead using [UnitOfWork] attribute. Everythings are working fine, but delay to get data from the tables which is using inside this method.

  [UnitOfWork]
  public virtual async Task HandleEventAsync(APIBookEto eventData)
  {
      
      // Here using multiple table CRUD operations
  }

hi

You can use _unitOfWorkManager to begin a new uow in the HandleEventAsync method, and set the isolationLevel if necessary.

Hi, As I can see in the documentation, the default isolation level is ReadUncommitted, so why is this locking the table for reading?

hi

I'm not sure. You can check the https://learn.microsoft.com/en-us/dotnet/api/system.data.isolationlevel?view=net-8.0

We've encountered this issue in multiple places, such as during the functionality to import users from Excel data. While looping and inserting users, the user table is completely locked, loading the users listing API stuck. There have added this code, but still unable to list users while doing this job. Even when querying from SQL, it doesn't give me results unless **with(nolock) ** is added

  public virtual async Task HandleEventAsync(APIUserImportEto eventData)
  {
      using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: System.Data.IsolationLevel.ReadUncommitted))
      {
        foreach (var importData in userImportedData)
          {
                  // Logic to insert users
          }
        }
    
    }

Hi, Below is a sample code snippet. The 'userImportedData' table contains master data with user information, such as username, password, etc. Within this distributed event method, we run a loop through this data, performing data validation and creating identity users if the validation is successful. However, during this process, the 'UserImportData' table is completely locked, preventing any records from being read until the loop completes.

 public virtual async Task HandleEventAsync(APIUserImportEto eventData)
 {
     using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true, isolationLevel: System.Data.IsolationLevel.ReadUncommitted))
     {
         try
         {

             using (_currentTenant.Change(eventData.TenantId))
             {
                 var newPrincipal = new ClaimsPrincipal(
                                     new ClaimsIdentity(
                                         new Claim[]
                                         {
                                             new Claim(AbpClaimTypes.UserId, eventData.CreatorId.ToString()),
                                             new Claim(AbpClaimTypes.TenantId, eventData.TenantId.ToString()),
                                             new Claim(AbpClaimTypes.UserName, "admin")
                                         }
                                     )
                                  );
                 using (_currentPrincipalAccessor.Change(newPrincipal))
                 {
                     var userImport = (await _userImportRepository.GetQueryableAsync()).Where(x => x.Id == eventData.UserImportId).FirstOrDefault();
                     if (userImport != null)
                     {
                         userImport.Status = UserImportStatus.InProgress;
                         await _userImportRepository.UpdateAsync(userImport, true);
                         await _msgHubContext.Clients.User(eventData.CreatorId.ToString())
                             .SendAsync("UserImportInProgressMessage", userImport.Id);

                         SetIdentityOptions();
                         bool isAnyError = false;
                         var userImportedData = (await _userImportDataRepository.GetQueryableAsync()).Where(x => x.UserImportId == eventData.UserImportId).ToList();
                         foreach (var importData in userImportedData)
                         {
                             importData.Status = UserImportStatus.InProgress;
                             await _userImportDataRepository.UpdateAsync(importData, true);
                             await _msgHubContext.Clients.User(eventData.CreatorId.ToString())
                                 .SendAsync("UserImportDataInProgressMessage", userImport.Id);
                             try
                             {
                                 List<string> lsrErrors = new List<string>();
                                 if (string.IsNullOrWhiteSpace(importData.UserName))
                                 {
                                     lsrErrors.Add("User Name is empty");
                                 }
                                 if (string.IsNullOrWhiteSpace(importData.Name))
                                 {
                                     lsrErrors.Add("Name is empty");
                                 }

                                 if (!string.IsNullOrWhiteSpace(importData.Name) && importData.Name.Length > 64)
                                 {
                                     importData.Name = importData.Name.Substring(0, 63);
                                 }

                                 if (!string.IsNullOrWhiteSpace(importData.SurName) && importData.SurName.Length > 64)
                                 {
                                     importData.SurName = importData.SurName.Substring(0, 63);
                                 }

                                 if (string.IsNullOrWhiteSpace(importData.Password))
                                 {
                                     lsrErrors.Add("Password is empty");
                                 }
                                 else if (importData.Password.Trim().Length < UserImportDataConsts.PasswordMinLength || importData.Password.Trim().Length > UserImportDataConsts.PasswordMaxLength)
                                 {
                                     lsrErrors.Add("Password length is invalid (Max 20 Character allowed)");
                                 }
                                 if (lsrErrors.Count == 0)
                                 {

                                     var userRole = (await _identityRoleRepository.GetListAsync()).Where(x => x.Name == "user").FirstOrDefault();
                                     if (userRole == null)
                                     {
                                         userRole = new Volo.Abp.Identity.IdentityRole(_guidGenerator.Create(), "user", eventData.TenantId);
                                         await _identityRoleRepository.InsertAsync(userRole, true);
                                     }
                                     var identityUser = new Volo.Abp.Identity.IdentityUser(_guidGenerator.Create(), importData.UserName, importData.UserName, eventData.TenantId);
                                     if (identityUser != null)
                                     {
                                         identityUser.AddRole(userRole.Id);
                                     }
                                     identityUser.Name = importData.Name;
                                     identityUser.Surname = importData.SurName;
                                     var createdUser = await _identityUserManager.CreateAsync(identityUser, importData.Password, false);
                                     createdUser.CheckErrors();

                                     if (!string.IsNullOrEmpty(roles))
                                     {
                                         var rolesIds = roles.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                                         foreach (var roleId in rolesIds)
                                         {
                                             await _userRoleMappingRepository.InsertAsync(new UserRoleMapping(_guidGenerator.Create(), identityUser.Id, roleId, "", ""), true);
                                         }
                                     }

                                     if (!string.IsNullOrEmpty(grades))
                                     {
                                         var gradesIds = grades.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                                         foreach (var gradeId in gradesIds)
                                         {
                                             await _userGradeMappingRepository.InsertAsync(new UserGradeMapping(_guidGenerator.Create(), identityUser.Id, gradeId, gradeId, "", ""), true);
                                         }
                                     }

                                     if (!string.IsNullOrEmpty(subjects))
                                     {
                                         var subjectsIds = subjects.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                                         foreach (var subjectId in subjectsIds)
                                         {
                                             await _userSubjectMappingRepository.InsertAsync(new UserSubjectMapping(_guidGenerator.Create(), identityUser.Id, subjectId, "", ""), true);
                                         }
                                     }

                                     importData.Status = UserImportStatus.Success;
                                     await _userImportDataRepository.UpdateAsync(importData, true);

                                     await _msgHubContext.Clients.User(eventData.CreatorId.ToString())
                                     .SendAsync("UserImportDataSuccessMessage", importData.Id);
                                 }
                                 else
                                 {
                                     throw new UserFriendlyException(String.Join(",", lsrErrors.ToArray()));
                                 }
                             }
                             catch (UserFriendlyException ex)
                             {
                                 _logger.LogException(ex);
                                 isAnyError = true;
                                 importData.Status = UserImportStatus.Failed;
                                 importData.StatusDetails = ex.Message;
                                 await _userImportDataRepository.UpdateAsync(importData, true);
                                 await _msgHubContext.Clients.User(eventData.CreatorId.ToString())
                                  .SendAsync("UserImportDataFailedMessage", importData.Id, ex.Message);
                             }
                             catch (Exception ex)
                             {
                                 string excpetionMessage = ex.Message;
                                 if (excpetionMessage.Length > 100) excpetionMessage = excpetionMessage.Substring(0, 100);
                                 _logger.LogException(ex);
                                 isAnyError = true;
                                 importData.Status = UserImportStatus.Failed;
                                 importData.StatusDetails = excpetionMessage;
                                 await _userImportDataRepository.UpdateAsync(importData, true);
                                 await _msgHubContext.Clients.User(eventData.CreatorId.ToString())
                                  .SendAsync("UserImportDataFailedMessage", importData.Id, ex.Message);
                             }
                             finally
                             {
                                 await _msgHubContext.Clients.User(eventData.CreatorId.ToString())
                                         .SendAsync("UserImportInProgressMessage", userImport.Id);
                             }

                         }
                         if (isAnyError)
                         {
                             userImport.Status = UserImportStatus.Failed;
                             await _userImportRepository.UpdateAsync(userImport, true);
                             await _msgHubContext.Clients.User(eventData.CreatorId.ToString())
                                 .SendAsync("UserImportFailedMessage", userImport.Id);
                         }
                         else
                         {
                             userImport.Status = UserImportStatus.Success;
                             await _userImportRepository.UpdateAsync(userImport, true);
                             await _msgHubContext.Clients.User(eventData.CreatorId.ToString())
                                 .SendAsync("UserImportSuccessMessage", userImport.Id);
                         }
                     }
                 }
             }

         }
         catch (Exception exp)
         {
             try
             {
                 _logger.LogException(exp);
             }
             catch { }
         }

         await uow.CompleteAsync();
     }
 }

 private void SetIdentityOptions()
 {
     _identityUserManager.Options.User.RequireUniqueEmail = true;
     _identityUserManager.Options.User.AllowedUserNameCharacters = $"{_identityUserManager.Options.User.AllowedUserNameCharacters}"; // add special characters here!
     _identityUserManager.Options.Password.RequireDigit = false;
     _identityUserManager.Options.Password.RequireUppercase = false;
     _identityUserManager.Options.Password.RequireNonAlphanumeric = false;
     _identityUserManager.Options.Password.RequireLowercase = false;
     _identityUserManager.Options.Password.RequiredLength = 1;
 }

UserImportData GetAPI Code,

public virtual async Task<PagedResultDto<UserImportDto>> GetListAsync(GetUserImportsInput input)
{
        var totalCount = await _userImportRepository.GetCountAsync(input.FilterText, input.FileDescriptorId, input.Status);
        var items = await _userImportRepository.GetListAsync(input.FilterText, input.FileDescriptorId, input.Status, input.Sorting, input.MaxResultCount, input.SkipCount);

        return new PagedResultDto<UserImportDto>
        {
            TotalCount = totalCount,
            Items = ObjectMapper.Map<List<UserImport>, List<UserImportDto>>(items)
        };
    }
}

  • Exception message and full stack trace:
  • Steps to reproduce the issue:
    • Download the ZIP
    • Unzip, Host and Run
    • Missing Lib folder exception, Volo.Abp.AbpException: Could not find file '/libs/prismjs/themes/prism-okaidia.css' at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundlerBase.GetFileInfo(IBundlerContext context, String file) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\BundlerBase.cs:line 130 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundlerBase.GetAndMinifyFileContent(IBundlerContext context, String fileName) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\BundlerBase.cs:line 99 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundlerBase.GetFileContentConsideringMinification(IBundlerContext context, String fileName) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\BundlerBase.cs:line 94 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundlerBase.Bundle(IBundlerContext context) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\BundlerBase.cs:line 46 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleManager.<>c__DisplayClass17_0.<AddToBundleCache>b__0() in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\BundleManager.cs:line 125 at System.Collections.Generic.AbpDictionaryExtensions.<>c__DisplayClass7_02.<GetOrAdd>b__0(TKey k) in C:\GitHub\abp\framework\src\Volo.Abp.Core\System\Collections\Generic\AbpDictionaryExtensions.cs:line 130 at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at System.Collections.Generic.AbpDictionaryExtensions.GetOrAdd[TKey,TValue](ConcurrentDictionary2 dictionary, TKey key, Func1 factory) in C:\GitHub\abp\framework\src\Volo.Abp.Core\System\Collections\Generic\AbpDictionaryExtensions.cs:line 130 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleCache.GetOrAdd(String bundleName, Func1 factory) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\BundleCache.cs:line 19 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleManager.AddToBundleCache(String bundleName, IBundler bundler, List1 bundleFiles) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\BundleManager.cs:line 114 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleManager.GetBundleFilesAsync(BundleConfigurationCollection bundles, String bundleName, IBundler bundler) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\BundleManager.cs:line 100 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleManager.GetStyleBundleFilesAsync(String bundleName) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\BundleManager.cs:line 60 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers.AbpTagHelperStyleService.GetBundleFilesAsync(String bundleName) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\TagHelpers\AbpTagHelperStyleService.cs:line 42 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers.AbpTagHelperResourceService.ProcessAsync(ViewContext viewContext, TagHelper tagHelper, TagHelperContext context, TagHelperOutput output, List1 bundleItems, String bundleName) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\TagHelpers\AbpTagHelperResourceService.cs:line 60 at Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers.AbpBundleTagHelperService2.ProcessAsync(TagHelperContext context, TagHelperOutput output) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bundling\Volo\Abp\AspNetCore\Mvc\UI\Bundling\TagHelpers\AbpBundleTagHelperService.cs:line 21 at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count) at AspNetCoreGeneratedDocument.Pages_Documents_Project_Index.<ExecuteAsync>b__40_0() at Microsoft.AspNetCore.Mvc.Razor.RazorPage.RenderSectionAsyncCore(String sectionName, Boolean required) at AspNetCoreGeneratedDocument.Themes_Basic_Layouts_Empty.<>c__DisplayClass15_0.<<ExecuteAsync>b__0>d.MoveNext() in C:\GitHub\abp\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Themes\Basic\Layouts\Empty.cshtml:line 43 --- End of stack trace from previous location --- at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync() at AspNetCoreGeneratedDocument.Themes_Basic_Layouts_Empty.ExecuteAsync() in C:\GitHub\abp\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Themes\Basic\Layouts\Empty.cshtml:line 29 at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context) at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 statusCode) at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 statusCode) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore\Volo\Abp\AspNetCore\Security\AbpSecurityHeadersMiddleware.cs:line 53 at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore\Microsoft\AspNetCore\RequestLocalization\AbpRequestLocalizationMiddleware.cs:line 54 at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Mvc.Libs.AbpMvcLibsService.<CheckLibs>b__1_0(HttpContext httpContext, RequestDelegate next) in C:\GitHub\abp\framework\src\Volo.Abp.AspNetCore.Mvc\Volo\Abp\AspNetCore\Mvc\Libs\AbpMvcLibsService.cs:line 44 at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application)
Showing 101 to 110 of 126 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on November 11, 2025, 06:29
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.