I suspected it had to do with unit of work, but we arent tagging these functions as [UnitOfWork]. it is implicit in v4?
so in the functions i want to make sure are outside the scope of their clling fucntions i need to wrap them in their own unit of work?
thanks
More information: i can repeat it fairly regularly when i am running multiple jobs simultaneously from hangfire.
hope that helps
Here is the whole error stack trace
" at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable1.Enumerator.Dispose()\r\n at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable
1 source)\r\n at Castle.Proxies.Invocations.ITenantRepository_FindById.InvokeMethodOnTarget()\r\n at Castle.DynamicProxy.AbstractInvocation.Proceed()\r\n at Castle.DynamicProxy.AbstractInvocation.ProceedInfo.Invoke()\r\n at Castle.DynamicProxy.AsyncInterceptorBase.ProceedSynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.<ProceedAsync>d__7.MoveNext()\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Volo.Abp.Uow.UnitOfWorkInterceptor.<InterceptAsync>d__3.MoveNext()\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.<InterceptAsync>d__31.MoveNext()\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Castle.DynamicProxy.NoCoverage.RethrowHelper.Rethrow(Exception exception)\r\n at Castle.DynamicProxy.NoCoverage.RethrowHelper.RethrowInnerIfAggregate(Exception exception)\r\n at Castle.DynamicProxy.AsyncInterceptorBase.InterceptSynchronousResult[TResult](AsyncInterceptorBase me, IInvocation invocation)\r\n at Castle.DynamicProxy.AbstractInvocation.Proceed()\r\n at Castle.Proxies.IBasicRepository
1Proxy_12.FindById(Guid id, Boolean includeDetails)\r\n at Volo.Saas.Tenants.TenantStore.Find(Guid id)\r\n at Volo.Abp.MultiTenancy.MultiTenantConnectionStringResolver.Resolve(String connectionStringName)\r\n at DAG.TFORM.Web.Resolvers.TFORMMultiTenantConnectionStringResolver.Resolve(String connectionStringName) in C:\Users\ronald.rizk\source\repos\tform_repo\DAG.TFORM\aspnet-core\src\DAG.TFORM.Web\Resolvers\TFORMMultiTenantConnectionStringResolver.cs:line 27"
That line 27 is the line of code i identified above: var connectionString = base.Resolve(connectionStringName);
public async Task LinuxNetstatsDiscovery(string TaskName, Guid? TenantId)
{
DateTime nowDt = DateTime.UtcNow;
List<string> failedIpAddesses = new List<string>();
using (CurrentTenant.Change(TenantId))
{
var sourceOfTruthNewDevices = new List<SourceOfTruthDataModel>();
**This class function is defined below **
Guid BgjID = await _helperRepository.CreateBackgroundJobProcessingRecord(TenantId, $"{OperatingSystemEnum.Names.Linux} {DiscoveryType} Discovery");
List<HostListItemModel> hosts = await _helperRepository.GetHostList(TenantId, OperatingSystemEnum.OperatingSystem.Linux);
try
{
foreach (var host in hosts)
{
... do our processing ...
add record to DbContenxt.MyTable(record);
}
await _helperRepository.UpdateBackgroundJobStatusSuccess(BgjID, failedIpAddesses);
await DbContext.SaveChangesAsync();
}
catch (Exception ex)
{
//DbContext.Reset();
LogException(ex);
await _helperRepository.UpdateBackgroundJobStatusError(BgjID, failedIpAddesses);
throw;
}
}
}
public async Task<Guid> CreateBackgroundJobProcessingRecord(Guid? tenantId, string jobName)
{
BackgroundJobDataModel jobDetails = new BackgroundJobDataModel(_guidGenerator.Create())
{
StartTime = DateTime.UtcNow,
TenantId = tenantId,
JobName = jobName,
Status = "Processing"
};
jobDetails.EndTime = jobDetails.StartTime;
**_backgroundRepository is an IRepositry that is dependancy injected in the consturctor**
await _backgroundRepository.InsertAsync(jobDetails, true);
await _backgroundRepository.GetDbContext().SaveChangesAsync();
return jobDetails.Id;
}
so even though i save changes in this function, it does not unless i hit the save changes at the bottom of my loop
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
i have no way to create the issue on demand, it just sort of happens some times, here is a screenshot of the code along with the error. not that it should matter, but the connectionStringName is not null, but null should be a valid option for it
https://gyazo.com/e1c07cce38a2e189cef5e7c4e4445639
Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.
i already do that, if the string being returned from the Base.resolver is empty i just return string.empty. should it be null instead? that being said, thats not the line that fails, i am getting the exception on the call to base.resolver trying to get the connection string so i can test its value.
This works fairly well, the one issuei am finding is that i sometimes get a null reference on this line, whcih makes no sense to me:
var connectionString = base.Resolve(connectionStringName);
you want to know if i use your cli to create a new application can i reproduce it?