Page 1 of 1

Connection pool exhaustion in EFCore provider

Posted: Tue 05 Mar 2019 10:36
by Thomasdc
The EFCore provider doesn't close connections when the DbContext is disposed in combination with an ambient TransactionScope as discussed here.
Result is that DbConnections are never returned to the connection pool causing connection pool exhaustion.

Situation when disposing the DbContext with Devart.Data.Oracle.EFCore:
Image

Situation when disposing the DbContext with Microsoft.EntityFrameworkCore.SqlServer:
Image

Can you confirm this is a bug?

Sample code:

Code: Select all

using (var scope = new TransactionScope(
	TransactionScopeOption.Required,
	new TransactionOptions {IsolationLevel = IsolationLevel.ReadCommitted},
	TransactionScopeAsyncFlowOption.Enabled))
{
	using (var context = new BloggingContext())
	{
		var blog = new Blog
		{
			Url = "http://www.foo.bar",
			Posts = new List<Post>
			{
				new Post {Title = "Test", Content = "The content"}
			}
		};
		context.Add(blog);
		context.SaveChanges();
		scope.Complete();
	} // <-- DbConnection is never closed and returned to the connection pool when BloggingContext gets disposed
}

Re: Connection pool exhaustion in EFCore provider

Posted: Mon 11 Mar 2019 18:12
by Shalex
Thomasdc wrote:DbConnection is never closed and returned to the connection pool when BloggingContext gets disposed
We have reproduced the issue and are investigating it.

JIC: if pooling is turned on (by default), a physical connection should remain open (https://www.devart.com/dotconnect/oracl ... Q.html#q56)

Re: Connection pool exhaustion in EFCore provider

Posted: Mon 18 Mar 2019 07:51
by Thomasdc
JIC: if pooling is turned on (by default), a physical connection should remain open
I know, but the issue is that the pooled DbConnections are never reused because they are never closed.

Re: Connection pool exhaustion in EFCore provider

Posted: Mon 18 Mar 2019 17:11
by Shalex
We will notify you when the issue is fixed.

Re: Connection pool exhaustion in EFCore provider

Posted: Thu 25 Apr 2019 12:42
by Shalex
The bug with closing database connection by context.Dispose() in the scope of a distributed transaction in EF Core 2 is fixed. The internal build with the fix is available at https://www.devart.com/pub/nuget_oracle_9_7_742.zip.

Re: Connection pool exhaustion in EFCore provider

Posted: Fri 07 Jun 2019 18:25
by Shalex
New build of dotConnect for Oracle 9.7.770 is available for download now: viewtopic.php?f=1&t=38884.