thanks for the hint. solution implemented
Thanks for the suggestion! I was unaware that ABP had something similar out of the box 👍.
I have a few questions about the implementation of the PerRequestRedisCache though
Yes, the PermissionManager is created through dependency injection. So is the _session btw private readonly IAbpSession _session;
The background job is not a timed job but is handled like the notifications are (through AbpBackgoundJobs)
await _backgroundJobManager.EnqueueAsync<SyncWithMooJob, SyncWithMooJobArgs>(new SyncWithMooJobArgs(AbpSession.GetTenantId()));
And
public class SyncWithMooJob : BackgroundJob<SyncWithMooJobArgs>, ITransientDependency
{
private readonly IMooManager _mooSyncManager;
public SyncWithMooJob(IMooManager mooSyncManager)
{
_mooSyncManager = mooSyncManager;
}
public override void Execute(SyncWithMooJobArgs args)
{
AsyncHelper.RunSync(() => _mooSyncManager.AutomaticSyncWithMoo(args.TenantId));
}
}
}
If I strip the method down to just
public async Task AutomaticSyncWithMoo(int tenantId)
{
try
{
using (CurrentUnitOfWork.SetTenantId(tenantId))
{
using (_session.Use(tenantId, null))
{
var permission = _permissionManager.GetPermissionOrNull(AppPermissions.Pages_Administration_TeacherGroups);
}
}
}
catch (Exception ex)
{
Logger.Error(ex.Message + ex.StackTrace);
}
}
I still get a NULL result. Just for clarity, when I add _permissionManager.GetPermissionOrNull(AppPermissions.Pages_Administration_TeacherGroups);
to for instance an AppService there are no issues
We managed to reproduce the behaviour. Please see the GitHub issue.
Hi JakeE,
We would love to hear from you wether you managed to find a solution to the problem other than expiring the caches after 1 second. We are experiencing the same issues (https://support.aspnetzero.com/QA/Questions/9015)
We know about the possibility to clear the cache by hand, but have been unable to reproduce the corrupted cache after doing this.
It doesn't seem to happen everytime, which is why we assume there is a specific scenario somewhere that leads to the tenant filter not being applied in AbpFeatureValueStore.GetTenantFeatureCacheItem(Async)
We believe that when this scenario presents itself just as the cache has been expired, these two situations together lead to the cache being corrupted. Me and my team have been going through our code to find this scenario, but have not had any luck.
We would be very grateful if you could brainstorm with us on what could possibility lead to this.
We use the default FeatureChecker implementation to check if features are enabled for tenants. Next to this we use the RequiresFeature Attribute on almost all our AppServices. We don't know how this Attribute is implemented behind the scenes.
We don't know where this behavior comes from so it is hard to answer your second question. We only know the end result as we pointed out in the original post. We did suspect using DisableFilter for MayHaveTenant/MustHaveTenant or when using SetTenantId on the CurrentUnitOfWork but were unable to reproduce it using these scenarios.
We also have the assumption that the data gets corrupted only when the cache has expired and data is re-added through either GetTenantFeatureCacheItemAsync or GetTenantFeatureCacheItem.
In summary, we know the end result but not what leads to this.