DocStar DeadLocks for Simultaneous AR Invoices

We currently use APM to route outgoing AR invoices. We basically use APM to do two things:

  1. Output AR invoices to customers (mostly email).
  2. Query the doclink2 database to locate the file location of the APM invoice files for our field mechanics to be able to present a customer their invoice on demand

I’ve made great strides towards accomplishing replacement thanks to feedback from the experts on this forum (thanks everyone!). The following threads are related to this:

To accomplish the change, I’ve created a custom report style with break & routing that does the two things I need:

So now I’m at another stumbling block. I ran a test of a very small sample of invoices (25) and it appears that DocStar is having issues with attaching the documents due to deadlocks.

In reviewing the event log on the server, for each attachment that failed, I see the following in the event log:

System.Data.SqlClient.SqlException (0x80131904): Transaction (Process ID 603) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()
   at Astria.Framework.Business.V2.FolderBusiness.AddDocuments(Dictionary`2 assignments, SqlTransaction trans)
   at Astria.Framework.Business.V2.DocumentBusiness.Create(DocumentCreatePackage[]& documentPkgs, SqlTransaction trans, Boolean allOrNone, Boolean noContentItems)
   at Astria.Framework.Business.V2.DocumentBusiness.Create(DocumentCreatePackage[] documentPkgs, Boolean allOrNone, SqlTransaction trans)
   at Astria.Framework.Business.V2.DocumentBusiness.Create(DocumentCreatePackage[] documentPkgs, Boolean allOrNone)
   at Astria.Framework.Business.V2.DocumentBusiness.Create(DocumentCreatePackage documentPkg)
   at Astria.Service.Company.V2.DocumentService.Create(DocumentCreatePackage docPackage)
Error Number:1205,State:51,Class:13
Detected Ip:

Has anyone seen errors before like this in DocStar and if so any advice on how to resolve?

FWIW, I’m not locked into DocStar and am fine not using it for this purpose (we paid for it to do AP invoices). I am looking for a simple way to retrieve the PDF that was generated that we sent to the customer by knowing what the invoice number is. It seems crazy with all the power that Epicor and DocStar contain to build my own, but maybe I need to build something to parse an email box? Any help / ideas are appreciated!