Hi @maliming
Your code (Pull Request) works on Abp 7.2, our project is Abp 5.3.3 so we had to change some codes. I changed IdentityUserRepository variable's type from IIdentityUserRepository to IRepository<IdentityUser>.
And did a second change on using IdentityUserRepository like below:
//var users = await IdentityUserRepository.GetListByIdsAsync(userGroup.Select(x => x.TargetUserId));
//changed above code like below
var users = (await IdentityUserRepository.GetQueryableAsync())
.Where(p => userGroup.Select(p => p.TargetUserId).Contains(p.Id)).ToList();
In this scenario operation time gets to 15 seconds from 30 seconds.
We made a performance improvement on your code like below and operation time is reduced to 10 seconds from 15 seconds with this change below (increased round trip on your code):
List<IdentityUser> allUsers = new(); //added
using (dataFilter.Disable()) //added
{
allUsers = (await IdentityUserRepository.GetQueryableAsync()) //added
.Where(p => allLinkUsers.Select(p => p.TargetUserId).Contains(p.Id)).ToList(); //added
} //added
foreach (var userGroup in allLinkUsers.GroupBy(x => x.TargetTenantId))
{
var tenantId = userGroup.Key;
TenantConfiguration tenant = null;
if (tenantId.HasValue)
{
tenant = await TenantStore.FindAsync(tenantId.Value);
}
using (CurrentTenant.Change(tenantId))
{
//var users = await IdentityUserRepository.GetListByIdsAsync(userGroup.Select(x => x.TargetUserId)); //commented
//changed above line like below line
var users = allUsers.Where(p => userGroup.Select(p => p.TargetUserId).Contains(p.Id)).ToList(); //added
foreach (var user in users)
{
userDto.Add(new LinkUserDto
{
TargetUserId = user.Id,
TargetUserName = user.UserName,
TargetTenantId = tenant?.Id,
TargetTenantName = tenant?.Name,
DirectlyLinked = userGroup.FirstOrDefault(x => x.TargetUserId == user.Id)?.DirectlyLinked ?? false
});
}
}
}
Note We reduced operation time to 10 seconds and nearly all the time is used by below code line. We inspected source of IdentityLinkUserManager.GetListAsync() method from github and this method makes too much round trips:
var linkUsers = await IdentityLinkUserManager.GetListAsync(new IdentityLinkUserInfo(currentUserId, currentTenantId), includeIndirect: true);
Sent via mail
Hi @maliming
Any news about this problem?
Hi @alper my database is on the cloud and services are working on-premises so if there is too much round trip that may cause too much latency. And for 900 records 4.5 second is not also a good time. Is it possible to change fetching all records to fetching only current page records. And also could you please check if there is a loop for user or tenant info fetch?
Hi @gizem
Did you able to test?
Hi @alper did you try on your environment? Which indices you have on AbpLinkUsers or any related table? And why getting all records on a paged page, shouldn't it fetch 10 records for paged page?
Hi @liangshiwei
In above message your suggestion (below code) does not solve our problem. If we got any error on backgroudjob creation, process will be broken. If it's a UI call, user will get an error and business will be completed. As @ademaygun said there is no UI dashboard to manage and see background jobs for ABP's BackgroundJob system and in the documents ABP suggest us hangfire as an integrated solution. But ABP does not work with Hangfire properly. There would be same problem in EventBus but luckly ABP solves that problem with implementing inbox pattern. There could be same solution for background jobs.
Is it possible to discuss this problem with the team? This problem is really critical for us.
public async Task CreateAsync()
{
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
{
//...
await productRepository.InsertAsync(new Product("Product1"));
await uow.CompleteAsync();
}
await backgroundJobManager.EnqueueAsync(ProductJobArgs);
}
Hi liangshiwei,
Send an email
If you created isseu on github, can you please share issue link, to track status. Thank you
As you can see in the first message, there is no validation message on Password Reset screen (ui page). It only disables button, does not give any validation message.