LINQ to SQL connection pool error

In our project, I used LINQ to SQL for every interaction with databases. Now, from what I know, when I create and use a DataContext object: it opens a connection, splits the transaction, executes the request, and closes the connection.

From time to time we get a connection pool error for our services and server.

"The timeout period before receiving a connection from the pool. Perhaps this was due to the fact that all the joined connections were involved and the maximum pool size was reached."

Any idea? Am I quite here? Is this related to SQL Server?

We use LINQ, .Net 3.5 and Sql Server 2008

NOTE. NO SENSOR IS USED IN THE SYSTEM.

thank

+3
source share
1 answer

Look here:

When do I need to get rid of the data context

I quote Jon Skeet, quoting someone else here, but it was a surprise to me since we were faced with a similar problem.

The logic that automatically closes the DataContext connection can be tricked into leaving the connection open. The DataContext relies on application code that lists all the query results from the moment it receives the end of the result set and starts a connection to close. If the application uses the IEnumerable MoveNext Method instead of foreach in C # or VB, you can exit the listing prematurely. If your application is having problems with connections not closing and you suspect automatic shutdown does not work, you can use Dispose as a work around.

, , datacontext, . , .

+6

Source: https://habr.com/ru/post/1743221/


All Articles