Page 1 of 2

Connection pool is not getting cleared on AppDomain unload.

Posted: Tue 16 Oct 2012 08:45
by sgawde
Hi Team,
We found connection leak issue with the Devart when we use the connection in different AppDomain.
Scenario:
1. Create a console application which opens connection using Devart.
2. Create another console application with new AppDomain and from the new AppDomain try to execute the first console application
3. Here, the connection remains open even if we unload the newly created AppDomain.
4. We have verified this with V$session query.

ConsoleApplication1: Fire a select query using Devart.
private static void Main(string[] args)
{
Console.WriteLine(" Main in domain {0} called", AppDomain.CurrentDomain.FriendlyName);
String myConnString = "data source=orcl;user id=ABCD;password=ABCD;";
string mySelectQuery = "select * from TestDevart";
using (OracleConnection myConnection = new OracleConnection(myConnString)){
using (OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection)){
myConnection.Open();
using (OracleDataReader myReader = myCommand.ExecuteReader()){
while (myReader.Read()){
string testValue = myReader.GetString(myReader.GetOrdinal("TBLDESC"));}
myReader.Close(); } } }
Console.WriteLine("Query Fired..."); }

ConsoleApplication2: Create different AppDomain and execute the ConsoleApplication1.When we unload the newly created AppDomain, it should close the connection opened in ConsoleApplication1.
private static void Main(string[] args)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
Console.WriteLine("Original AppDomain: " + currentDomain.FriendlyName);
AppDomain secondDomain = AppDomain.CreateDomain("Second AppDomain");
secondDomain.ExecuteAssembly("ConsoleApplication1.exe");
AppDomain.Unload(secondDomain);
Console.WriteLine("Check the connection count");
Console.ReadLine();
}

Query to check the open connections:
select * from V$session where schemaname='xxx'

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Fri 19 Oct 2012 13:34
by Pinturiccio
We have reproduced and fixed the bug with the connection remaining in the pool after the AppDomain upload. We will post here when the corresponding build of dotConnect for Oracle is available for download.

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Thu 25 Oct 2012 08:32
by sgawde
When can we expect fix for this issue?

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Thu 25 Oct 2012 12:36
by Pinturiccio
We are planning to release the next public build of dotConnect for SQLite at the end of the next week.

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Fri 26 Oct 2012 14:05
by sgawde
You said build will be available for "dotConnect for SQLite". Here we are talking about "DotConnect for Oracle". Are both same or it is typo.

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Mon 29 Oct 2012 09:30
by Pinturiccio
Sorry for the misprint. We are planning to release the next public build of dotConnect for Oracle at the end of this week.

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Mon 29 Oct 2012 11:43
by sgawde
Thanks for the response. We have reported one more issue at below thread.

http://forums.devart.com/viewtopic.php? ... 1&start=15

Its related to Char type is not working properly with unicode=true scenario. Just curios to know if, build for this weekend would be having fix for Char issue.

Thanks,
Sandeep

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Thu 01 Nov 2012 14:13
by Pinturiccio
sgawde wrote:Its related to Char type is not working properly with unicode=true scenario. Just curios to know if, build for this weekend would be having fix for Char issue.
This issue has not been fixed yet. We will post in the corresponding topic (http://forums.devart.com/viewtopic.php? ... 1&start=15) when the issue is fixed.

Besides, the fix of the bug with the connection remaining in the pool after the AppDomain upload will not be included into the next public build. We will post here when the corresponding build of dotConnect for Oracle is available for download.

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Thu 10 Jan 2013 08:18
by esben
Hi, just wanted to let you know i just encountered the same bug.
Any suggested workarounds?

Any eta on the fix?

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Thu 10 Jan 2013 12:04
by esben
Okay, I found my workaround. Disabling pooling does the trick, but it is a horrible workaround (works for now though).

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Fri 11 Jan 2013 15:22
by Pinturiccio
We can't change the described behavior, as this will influence all the existing users and their applications will take longer to close.
As a workaround, you can try the following in your application:

Code: Select all

AppDomain.CurrentDomain.DomainUnload += new EventHandler(CurrentDomain_DomainUnload);
static void CurrentDomain_DomainUnload(object sender, EventArgs e) {
      OracleConnection.ClearAllPools();
}
Pool clearing will be performed in 10 to 40 seconds.

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Mon 14 Jan 2013 06:25
by esben
Pinturiccio wrote:We can't change the described behavior, as this will influence all the existing users and their applications will take longer to close.
As a workaround, you can try the following in your application:

Code: Select all

AppDomain.CurrentDomain.DomainUnload += new EventHandler(CurrentDomain_DomainUnload);
static void CurrentDomain_DomainUnload(object sender, EventArgs e) {
      OracleConnection.ClearAllPools();
}
Pool clearing will be performed in 10 to 40 seconds.

Sorry about this, but I REALLY need to know what it is that will break for other users if you let the sessions be cleared properly after unload. The issue is that the session is left hanging in Oracle, and spinning up a new AppDomain spins up a new session with the old one never disappearing. Please IN DETAIL explain to me how fixing this issue will affect anyone? Since re-entering the same appdomain is imposible (as far as i know it has been unloaded and is not accessible anymore) and spinning up a new app-domain will also open a new session.

The System.Data.Oracle client disconnected the session, now I will have to test the ODP driver and see what happens with that.

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Thu 17 Jan 2013 06:53
by esben
Any feedback on how a fix would affect others?

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Fri 18 Jan 2013 14:22
by Pinturiccio
We will fix the issue by the next build.

Re: Connection pool is not getting cleared on AppDomain unload.

Posted: Wed 30 Jan 2013 12:07
by esben
Any idea when the next build with this fix is going to be available?