Connection pool exhaustion in EFCore provider

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Thomasdc
Posts: 12
Joined: Sat 07 Jul 2018 14:20

Connection pool exhaustion in EFCore provider

Post by Thomasdc » Tue 05 Mar 2019 10:36

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
}

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Connection pool exhaustion in EFCore provider

Post by Shalex » Mon 11 Mar 2019 18:12

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)

Thomasdc
Posts: 12
Joined: Sat 07 Jul 2018 14:20

Re: Connection pool exhaustion in EFCore provider

Post by Thomasdc » Mon 18 Mar 2019 07:51

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Connection pool exhaustion in EFCore provider

Post by Shalex » Mon 18 Mar 2019 17:11

We will notify you when the issue is fixed.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Connection pool exhaustion in EFCore provider

Post by Shalex » Thu 25 Apr 2019 12:42

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Connection pool exhaustion in EFCore provider

Post by Shalex » Fri 07 Jun 2019 18:25

New build of dotConnect for Oracle 9.7.770 is available for download now: viewtopic.php?f=1&t=38884.

Post Reply