Blocking in databases is a result of locks taken in the database in order to help maintain concurrency among multiple transactions, indicating transaction intent. A potential side effect of these locks can be blocking (and in some cases deadlocks!), where transactions are waiting for other transactions to release a lock resource. Often we can see this result in slower performance for users. (some of this is affected by transaction isolation levels, which would be a whole different post).
Similar to capturing deadlocks & foreign key errors, blocking can be captured. I think in this case SQL Server has the leg up on tools here.
On the MySQL side, I look for long running transactions, not necessarily only blocking transactions. Here I use the Percona Monitoring Plugin for Nagios, using pmp-check-mysql-innodb , checking for all three options idle_blocker_duration, waiter_count and max_duration.
I’d like to thank Kendra at sqlworkbooks.com for explaining the (native!) tools in SQL Server to capture blocking in her online training class Troubleshooting Blocking and Deadlocks for Beginners (free through Dec 2017, recommended!).
Unlike the xml_deadlock_report, the blocked_process_report does not appear to be captured by default in the system_health extended event. Like deadlocks, a custom Extended Event can be created & enabled to capture blocked processes, choosing “blocked_process_report” from the event library under Select Events to capture. Once a blocker is captured, you can doubleclick to open the report and view information on the resources affected & (partial) queries.
Additionally, there is a handy open source SQL Server Blocked Process Report Viewer that creates a stored procedure which creates the lead & blocker trees for viewing the blocked processes in an easier to read tree format based based on the blockers captured in the extended events session.
The extended event captures blocking sessions, but doesn’t notify on occurrence. An SQL Server Agent alert condition can be setup for “@performance_condition=N’General Statistics|Processes blocked||>|0′” to notify when a blocking event has occurred.