C3p0 - APPARENT DEADLOCK on MSSQL, but not PostgreSQL or MySQL C3p0 - APPARENT DEADLOCK on MSSQL, but not PostgreSQL or MySQL postgresql postgresql

C3p0 - APPARENT DEADLOCK on MSSQL, but not PostgreSQL or MySQL


SQL Server has a much more restrictive locking strategy compared to PostgreSQL or InnoDB.

Especially it will block SELECTs on rows (tables?) that are updated from a different connection/transaction (in the default installation).

You should make sure that you are not selecting the same rows in one session that are being updated from another.

If you can't change the sequence of your code, you might get away with using "dirty reads" in SQL Server.

If I remember that correctly, this is accomplished by adding WITH NOLOCK to the SELECT statements (but I'm not entirely sure)

Edit
A different possibility (if you are on SQL Server 2005 or later) would be to use the new "snapshot isolation" to avoid blocking selects.