Work queue entry doesn't end up in the error queue after concurrency exception during processing

Work queue entry processing sometimes ends up with a concurrency exception error.

I was expecting work queue entry will end up in a queue selected as an “error” queue of the action.

Instead it ended up in the normal queue (with an error)

Only errorText is set, which is good. From analysing the code, it seems, it won’t also update retry counts in case of concurrency exception.

Details:
The processing of work queue ends up with the concurrency exception (A real user had changed the queue between it’s loaded and processed). Since the data of the actual work queue entry are still the same in the dataset, the concurrency exception raises again when trying to save errors, update retries, or move the queue entry to the error queue. Unfortunately only updating the errors is handling concurrency exception here:


The move to error queue and retries are not handled so the result is that the queue is not moved and notifications about error is not sent.

Stack trace

---> System.Data.DBConcurrencyException: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.
   at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
   at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
   at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
   at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
   at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)
   at Origam.DA.Service.AbstractSqlDataService.ExecuteUpdate(DataStructureQuery query, String transactionId, UserProfile profile, DataStructure dataStructure, IDbTransaction transaction, IDbConnection connection, ArrayList deletedRowIds, DataTable changedTable, DataRowState rowState, DataStructureEntity entity, Int32 rowCount, Boolean forceBulkInsert) in D:\a\1\s\backend\Origam.DA.Service\AbstractSqlDataService.cs:line 961
   at Origam.DA.Service.AbstractSqlDataService.<>c__DisplayClass21_2.<UpdateData>b__1() in D:\a\1\s\backend\Origam.DA.Service\AbstractSqlDataService.cs:line 601
   at Origam.DA.Service.Profiler.ExecuteAndTakeLoggingAction(DataStructureEntity entity, Action`2 loggingAction, Action actionToExecute) in D:\a\1\s\backend\Origam.DA.Service\AbstractSqlDataService.cs:line 2980
   at Origam.DA.Service.AbstractSqlDataService.UpdateData(DataStructureQuery query, IPrincipal userProfile, DataSet dataset, String transactionId, Boolean forceBulkInsert) in D:\a\1\s\backend\Origam.DA.Service\AbstractSqlDataService.cs:line 591
   --- End of inner exception stack trace ---
   at Origam.DA.Service.AbstractSqlDataService.UpdateData(DataStructureQuery query, IPrincipal userProfile, DataSet dataset, String transactionId, Boolean forceBulkInsert) in D:\a\1\s\backend\Origam.DA.Service\AbstractSqlDataService.cs:line 670
   at Origam.DA.Service.AbstractSqlDataService.UpdateData(DataStructureQuery query, IPrincipal userProfile, DataSet dataset, String transactionId) in D:\a\1\s\backend\Origam.DA.Service\AbstractSqlDataService.cs:line 467
   at Origam.Workflow.DataServiceAgent.SaveData(DataStructureQuery query, DataSet data) in D:\a\1\s\backend\Origam.Workflow\Service Agents\DataServiceAgent.cs:line 270
   at Origam.Workflow.DataServiceAgent.Run() in D:\a\1\s\backend\Origam.Workflow\Service Agents\DataServiceAgent.cs:line 472
   at Origam.Workbench.Services.CoreServices.DataService.StoreData(DataStructureQuery dataStructureQuery, DataSet data, String transactionId) in D:\a\1\s\backend\Origam.Workbench.Services\CoreServices\DataService.cs:line 158
   at Origam.Workflow.WorkQueue.WorkQueueService.HandleMoveQueue(WorkQueueClass wqc, DataTable selectedRows, Guid newQueueId, String errorMessage, String transactionId, Boolean resetErrors) in D:\a\1\s\backend\Origam.Workflow\WorkQueue\WorkQueueService.cs:line 1051
   at Origam.Workflow.WorkQueue.WorkQueueService.HandleAction(WorkQueueRow queue, String queueClass, DataTable selectedRows, Guid commandType, String command, String param1, String param2, Boolean lockItems, Object errorQueueId, String transactionId) in D:\a\1\s\backend\Origam.Workflow\WorkQueue\WorkQueueService.cs:line 891
   at Origam.Workflow.WorkQueue.WorkQueueService.ProcessQueueItem(WorkQueueRow queue, DataRow queueEntryRow) in D:\a\1\s\backend\Origam.Workflow\WorkQueue\WorkQueueService.cs:line 1414