Excessive Blocking when using BizTalk SQL Adapter
-------------------------------------
Addendum – June 22 2007: Under absolutely NO circumstances should you modify the data model of the BizTalk databases in any way. You should only optimize your own application databases.
-------------------------------------
I have seen this issue in many places, which still surprises me because there are a lot of blog entries about this. For what it's worth, here's one more.
Scenario: BizTalk solution makes moderate to heavy use of SQL adapter in calling stored procedures in a database.
Problem: SQL server shows many blocking (perhaps deadlocking) SPIDs, most of which are owned by the BizTalk host instance account.
Factors:
- The longer the procedure takes to execute, the worse off you are
- Big tables, poor logic, bad indexes, bad db maintenance, disk contention etc.
- The more concurrent procedure executions the worse off you are
- short polling interval
- multiple ports
- multiple host instances
Diagnosing:
- Enterprise Manager or Management Studio can give some insight to active and blocking spids (check to see who owns the blocking spid and use dbcc inputbuffer to see the sql it is executing)
- Try using sp_who,sp_who2,and sp_who3, they may give you lots of insight
- Call MS PSS (or download pssdiag for yourself from the MS download site) and have them configure a pssdiag trace for you. Look especially closely at the blocker output and the profiler trace. Use rml.exe (read80trace) to generate a report of the "worst offenders" sql scripts or procedures.
Fixes:
- As per documentation, don't use T-SQL transactions in your proc. The SQL Adapter already has this all wrapped up in a distributed transaction so relax!
- As per documentation, you can try setting the transaction isolation level to READ COMMITTED, or perhaps REPEATABLE READ. If you are running SERIALIZABLE that is a great way to tank performance and cause blocking.
- Speed up the procs (Archive, purge, index, create views, run db maintenance, buy a big SAN, whatever. The locks won't kill you if they don't last)
- Don't go silly with coarse locking hints. Keep your lock few in number and small in granuarity. If you must manually lock, then please read up on the READPAST hint - especially for queue or "trigger" tables. (Thanks to Kunjal K for this hint)
- Reduce concurrency - You can try lengthening your polling interval or reducing the number of host instances that run that port.
Didn't find what you were looking for? Try one of these:
- Known SQL Adapter Issues
- How to resolve a deadlock
- Understanding Isolation Levels
- Contact me through comment below
Is there something that I can do to make this blog more helpful to you?
I welcome your feedback!
Comments
- Anonymous
June 20, 2007
PingBack from http://mauros.wordpress.com/2007/06/20/links-for-2007-06-20/