too many sleep process

18 views
Skip to first unread message

c...@cyf.com.ar

unread,
Apr 22, 2015, 7:23:36 AM4/22/15
to npgsq...@googlegroups.com
something goes wrong. since I've implemented the use of the npgsql library, the server reports too many sleeps connection open.
more than 800.....
I've increased the number of max_connections to 1000 on postgresql.conf, but I think I'm making something wrong.
that's my connecton string:
Server=myServerIP;Port=5432;User Id=myUserID;Password=myPasswordString;Database=myDBName;Sslmode=Require;Pooling=False
any idea...?
thanks in advance for your support,

Francisco Figueiredo Jr.

unread,
Apr 22, 2015, 3:26:40 PM4/22/15
to c...@cyf.com.ar, npgsql-help

I think you may be leaking connections. Did you check if everywhere you open a connection, you close it when you don't need it anymore?

Also, why aren't you using a connection pool? This would improve the performance of you application by caching open connections.
Are you using Npgsql in a desktop application?

I hope it helps.
 


--
You received this message because you are subscribed to the Google Groups "Npgsql Help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to npgsql-help...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/npgsql-help/f687490f-ef38-467d-bc4b-c5ad9a4c7cb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

c...@cyf.com.ar

unread,
Apr 22, 2015, 3:32:03 PM4/22/15
to npgsq...@googlegroups.com, c...@cyf.com.ar
francisco, thanks for your support.
I'm developing under vbnet, the general code is:

try
conn.open
conn.close
conn.dispose
catch
end try

is that ok...?
I mean, maybe if error after try loop, goto catch and the connection never close....
should I use:
conn.open
try
conn.close
conn.dispose
catch
..if conn open then close
end try

what is the right way to open the connection...? before or after the try statement...?
thanks again...

Francisco Figueiredo Jr.

unread,
Apr 22, 2015, 3:58:21 PM4/22/15
to cjr, npgsql-help

The best way is to use the "using" statement:
https://msdn.microsoft.com/en-us/library/wydd5hkd.aspx

' Insert the following line at the beginning of your source file.
Imports System.Data.SqlClient
Public Sub AccessSql(ByVal s As String)
    Using sqc As New System.Data.SqlClient.SqlConnection(s)
        MsgBox("Connected with string """ & sqc.ConnectionString & """")
    End Using
End Sub


In this example, it is used exaclty to open a sqlconnection. This way, you don't need to worry about calling close or dispose. The compiler will do that for you when creating the code.  You just need to put your code inside the "using", "end using" statements and you are ok. :)


I hope it helps.




--
You received this message because you are subscribed to the Google Groups "Npgsql Help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to npgsql-help...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

c...@cyf.com.ar

unread,
Apr 22, 2015, 4:47:57 PM4/22/15
to npgsq...@googlegroups.com, c...@cyf.com.ar
On Wednesday, April 22, 2015 at 8:23:36 AM UTC-3, c...@cyf.com.ar wrote:
> something goes wrong. since I've implemented the use of the npgsql library, the server reports too many sleeps connection open.
> more than 800.....
> I've increased the number of max_connections to 1000 on postgresql.conf, but I think I'm making something wrong.
> that's my connecton string:
> Server=myServerIP;Port=5432;User Id=myUserID;Password=myPasswordString;Database=myDBName;Sslmode=Require
> any idea...?
> thanks in advance for your support,

2 things:

1- when I use: AccessSql("Server=myServer;Port=5432;User Id=myUserID;Password=myPassword;Database=myDB;Sslmode=Require")
error comes: Keyword not supported: 'port'.
and another error: Keyword not supported: 'sslmode'.

2- after connect with using statement, how should I execute a simple query like "select now();"
can you please provide me a full simple example, or point me to the right direction?
thanks in advance,
Reply all
Reply to author
Forward
0 new messages