Getting Deadlock Error During Processing

Issue:

Intermittently Getting below mentioned error during processing
OLE DB error: OLE DB or ODBC error. Transaction (Process ID n) was deadlocked on thread| communication buffer resources with another process and has been chosen as the deadlock victim.

Cause: A deadlock is a circular blocking chain, where two or more spids are each blocked by the other so that no one can proceed.

You don’t have control over the Select Statement generated by SSAS Processing job (If you are not using Named Query in DSV), in that case you need take care of things from SQL Engine Perspective.

Here are few recommendations, which can reduce deadlock situation:

  • Use separate environment for Reporting and Transaction
  • Ensure the database design is properly normalized.
  • Have the application access database objects in the same order every time.
  • Avoid cursors in DW environment
  • Use as low a level of isolation as possible for user connections.
  • Right indexes for getting correct execution plan (rebuild indexes after huge data modifications)
  • Have updated Statistics what will generate a right execution plan
  • During DW data refresh don’t do Cube Processing
  • In DSV refer View instead of Tables - Processing through a view provides you with an extra layer of abstraction on top of the database is a good design strategy. In the view definition, you can add a NOLOCK or TABLOCK hint to remove database locking overhead during processing.
  • Try experiment with MAXDOP setting - Set it to one, in your dev / test environment and see if you can reproduce issue; Keep in mind Performance Caveat of using MAXDOP=1.

Ref:

SET TRANSACTION ISOLATION LEVEL (Transact-SQL)

How To Monitor Deadlocks in SQL Server