Connections Hang Indefinitely using SSL

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
BryanW
Posts: 3
Joined: Tue 27 Sep 2016 17:26

Connections Hang Indefinitely using SSL

Post by BryanW » Tue 27 Sep 2016 17:56

Hello,

We are using dotConnect PostgreSQL 7.3.161.0.

We have recently changed our software to use SSL certificates in our connections to the database (previously we were not). After making these changes we frequently experience lock-ups when making calls into Devart. It seems to be somewhat random where the lockup occurs; it happens when opening a connection, closing one, or in the middle of a LINQ query.

Our application uses a single open connection, in a single thread. From that we create a new DB context anytime a task needs to be done and we dispose of it immediately. I have included the code used to setup and tear down a connection and a typical use of the DB context object (maybe we are doing something wrong).

Opening a connection...

Code: Select all

PgSqlConnectionStringBuilder connStringBuilder = new PgSqlConnectionStringBuilder();
connStringBuilder.UserId = UserId;
connStringBuilder.Host = Host;
connStringBuilder.Port = Int32.Parse(Port);
connStringBuilder.Password = Password;
connStringBuilder.Database = DatabaseName;
connStringBuilder.PersistSecurityInfo = false;
connStringBuilder.Pooling = true;
connStringBuilder.Schema = "public";

SqlConnection = new PgSqlConnection(connStringBuilder.ToString());
SqlConnection.StateChange += SqlConnectionStateChange;
SqlConnection.ConnectionTimeout = ConnectionTimeout;
SqlConnection.SslOptions.SslMode = SslMode.Require;
SqlConnection.Open();

DbChangeAlerter = new PgSqlAlerter(SqlConnection, alerts);
DbChangeAlerter.Alert += DbNotificationAlert;
DbChangeAlerter.Start();
Closing a connection...

Code: Select all

DbChangeAlerter.Stop();
DbChangeAlerter.Alert -= DbNotificationAlert;
DbChangeAlerter.Dispose();

SqlConnection.StateChange -= SqlConnectionStateChange;
SqlConnection.Close();
Using DB Context...

Code: Select all

int count;
using (DataContextFoo db = new DataContextFoo(SqlConnection))
{
  IQueryable<CollectionSet> result = db... // some query
  count = result.Count();
}
I think the code often hangs in this method:
Devart.Data.PostgreSql.dll!Devart.Security.SSL.ah.d

Your help would be greatly appreciated in coming up with a solution.
Please let me know what other information would help you with this.

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

Re: Connections Hang Indefinitely using SSL

Post by Shalex » Wed 28 Sep 2016 09:29

BryanW wrote:We have recently changed our software to use SSL certificates in our connections to the database (previously we were not). After making these changes we frequently experience lock-ups when making calls into Devart. It seems to be somewhat random where the lockup occurs; it happens when opening a connection, closing one, or in the middle of a LINQ query.
1. Please run your application in the debug mode and, when the program hangs, press Pause in Visual Studio to get the full stack trace. Try these steps several times to compare the stack traces. Specify these stack traces.

2. Localize the issue and send us a small test project with the corresponding DDL/DML script. In case of >2MB attachment, we recommend either using some file exchange server (send us the corresponding link) or uploading a test project to our FTP server (the credentials will be provided by email request).

BryanW
Posts: 3
Joined: Tue 27 Sep 2016 17:26

Re: Connections Hang Indefinitely using SSL

Post by BryanW » Wed 28 Sep 2016 16:13

Okay, I have witnessed several times that the application hangs in the same spot. Since the code is obfuscated, the stack trace goes like this:

Code: Select all

Devart.Data.PostgreSql.dll!Devart.Security.SSL.ah.d
[External Code]
our code...
I'm not sure if it is worth mentioning that I see several other threads waiting for notifications at:

Code: Select all

Devart_PgSqlAlerter_Notification  Devart.Data.PostgreSql.dll!Devart.Security.SSL.y.e	
I assume this is normal behavior.

I am attempting to get a small project going to reproduce the issue; however, our system is not "simple", so I might not be successful. If that is the case, Is there an option for our organization to negotiate for debug DLLs or source code, diagnose the problem, and report back what we find?

BryanW
Posts: 3
Joined: Tue 27 Sep 2016 17:26

Re: Connections Hang Indefinitely using SSL

Post by BryanW » Thu 29 Sep 2016 15:58

I sent a message via the contact link you provided.
I did end up reproducing the issue in a small, simple test appliaction; however, it did have to run overnight to see the issue.

Some more info:

- I have observed the lockup at different places than previously:

Code: Select all

DataContext.SubmitChanges();
...
Devart.Data.PostgreSql.dll!Devart.Security.p.a
and

Code: Select all

PgSqlAlerter.start()
...
Devart.Data.PostgreSql.dll!Devart.Security.SSL.y.d
- Trying the latest (trial) version of dotConnect (7.3.161.0) did not fix the issue.
- I verified that turning SSL off fixed the issue.
- The low CPU usage seems to indicate more of a dead lock behavior than spinning forever or a live lock

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

Re: Connections Hang Indefinitely using SSL

Post by Shalex » Mon 03 Oct 2016 17:53

Thank you for the test project. We will investigate the issue and notify you about the result.

Post Reply