Transaction (Process ID) was deadlocked on resources

Scenario: Occurs when two or more processes block each other while waiting for resources, leading to a deadlock.

Error Message: E2059 - ECE_ForwardedSQLError: Native Error Code: 1205 SQL State: 40001 [Microsoft][ODBC SQL Server Driver][SQL Server]Transaction (Process ID 120) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Cause: Poor query design or simultaneous updates on the same data.

Resolution:

  • Optimize queries to minimize lock contention (e.g., using WITH (NOLOCK) for reads).
  • Break large transactions into smaller, less-intensive ones.
  • Implement retry logic for deadlock errors.