dba-dash icon indicating copy to clipboard operation
dba-dash copied to clipboard

Potential issue getting AgentID from DBADashAgent_Upd

Open DavidWiseman opened this issue 2 years ago • 0 comments

System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Int32'.
   at DBADash.DBADashAgent.update(String connectionString) in D:\a\dba-dash\dba-dash\DBADash\DBADashAgent.cs:line 108
   at DBADash.DBADashAgent.GetDBADashAgentID(String connectionString) in D:\a\dba-dash\dba-dash\DBADash\DBADashAgent.cs:line 44
   at DBADash.DBImporter.updateInstance(DataRow& rInstance) in D:\a\dba-dash\dba-dash\DBADash\DBImporter.cs:line 445
   at DBADash.DBImporter.<>c__DisplayClass11_0.<Update>b__0(Context context) in D:\a\dba-dash\dba-dash\DBADash\DBImporter.cs:line 211
   at Polly.Policy.<>c__DisplayClass116_0`1.<Execute>b__0(Context ctx, CancellationToken _)
   at Polly.Retry.RetryEngine.Implementation[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Action`4 onRetry, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider)
2022-10-15 08:27:13.295 +01:00 [INF] Write to destination LAB2022|DBADashDB_test fro

The issue will occur calling DBADashAgent_Upd in rare circumstances. The DBA Dash agent row must not exist, then there must be a concurrency issue were two processes try to insert into the table. As SCOPE_IDENTITY is used to get the ID, the value will be NULL for the query that didn't insert a row.

DavidWiseman avatar Oct 15 '22 19:10 DavidWiseman