We have a few Java applications that use a common Azure Sql database through JDBC. Each application has a pool of connections to that database. The number of connections in the pool is limited, so the total number of connections from all applications is well below the database's resource limits.
Lately we've been getting these types of exceptions quite frequently:
com.microsoft.sqlserver.jdbc.SQLServerException: Resource ID : 1. The request limit for the database is 200 and has been reached. See 'http://go.microsoft.com/fwlink/?LinkId=267637' for assistance
- We've verified using a profiler that the applications don't open more connections than they are allowed.
- We've also verified that that the correct number of applications is running, so the number of connections should be below the resource limit.
- One odd thing we've noticed was that
sp_who
shows a large number of connections whoseLogin
column is empty:
Any guesses as to what could be the cause of these errors?
Edit:
One theory we have has to do with Sql Server's MaxDOP parameter.
Apparently, if this parameter is above 1, it's possible for Sql Server to use more than one worker thread per query. We think that those rows in sp_who
without a Login
value correspond to such additional worker threads used by one of the connections. That way, there could be (much) more worker threads than connections, so even though the number of connections is limited, we're saturating all worker threads.
Edit2:
Apparently Azure Sql's default Max Parallelism is set to 0 (unlimited), and can be changed only via a support ticket.
Edit3:
One more piece of evidence. We've executed SELECT * FROM sys.resource_stat
on the master database. We're seeing max_worker_percent
hit 100% from time to time. We really are saturating the worker threads.