Connection pool is not getting cleared on AppDomain unload.

Connection pool is not getting cleared on AppDomain unload.

Postby sgawde » Tue 16 Oct 2012 08:45

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'
sgawde
 
Posts: 14
Joined: Fri 20 Jul 2012 02:37

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

Postby Pinturiccio » Fri 19 Oct 2012 13:34

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.
Pinturiccio
Devart Team
 
Posts: 1953
Joined: Wed 02 Nov 2011 09:44

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

Postby sgawde » Thu 25 Oct 2012 08:32

When can we expect fix for this issue?
sgawde
 
Posts: 14
Joined: Fri 20 Jul 2012 02:37

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

Postby Pinturiccio » Thu 25 Oct 2012 12:36

We are planning to release the next public build of dotConnect for SQLite at the end of the next week.
Pinturiccio
Devart Team
 
Posts: 1953
Joined: Wed 02 Nov 2011 09:44

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

Postby sgawde » Fri 26 Oct 2012 14:05

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.
sgawde
 
Posts: 14
Joined: Fri 20 Jul 2012 02:37

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

Postby Pinturiccio » Mon 29 Oct 2012 09:30

Sorry for the misprint. We are planning to release the next public build of dotConnect for Oracle at the end of this week.
Pinturiccio
Devart Team
 
Posts: 1953
Joined: Wed 02 Nov 2011 09:44

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

Postby sgawde » Mon 29 Oct 2012 11:43

Thanks for the response. We have reported one more issue at below thread.

http://forums.devart.com/viewtopic.php?f=1&t=24551&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
sgawde
 
Posts: 14
Joined: Fri 20 Jul 2012 02:37

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

Postby Pinturiccio » Thu 01 Nov 2012 14:13

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?f=1&t=24551&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.
Pinturiccio
Devart Team
 
Posts: 1953
Joined: Wed 02 Nov 2011 09:44

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

Postby esben » Thu 10 Jan 2013 08:18

Hi, just wanted to let you know i just encountered the same bug.
Any suggested workarounds?

Any eta on the fix?
esben
 
Posts: 43
Joined: Tue 05 Jul 2011 09:40

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

Postby esben » Thu 10 Jan 2013 12:04

Okay, I found my workaround. Disabling pooling does the trick, but it is a horrible workaround (works for now though).
esben
 
Posts: 43
Joined: Tue 05 Jul 2011 09:40

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

Postby Pinturiccio » Fri 11 Jan 2013 15:22

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.
Pinturiccio
Devart Team
 
Posts: 1953
Joined: Wed 02 Nov 2011 09:44

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

Postby esben » Mon 14 Jan 2013 06:25

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.
esben
 
Posts: 43
Joined: Tue 05 Jul 2011 09:40

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

Postby esben » Thu 17 Jan 2013 06:53

Any feedback on how a fix would affect others?
esben
 
Posts: 43
Joined: Tue 05 Jul 2011 09:40

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

Postby Pinturiccio » Fri 18 Jan 2013 14:22

We will fix the issue by the next build.
Pinturiccio
Devart Team
 
Posts: 1953
Joined: Wed 02 Nov 2011 09:44

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

Postby esben » Wed 30 Jan 2013 12:07

Any idea when the next build with this fix is going to be available?
esben
 
Posts: 43
Joined: Tue 05 Jul 2011 09:40

Next

Return to dotConnect for Oracle