pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedConnection attempt hangs when server is unresponsive
3+ messages / 3 participants
[nested] [flat]
* Connection attempt hangs when server is unresponsive
@ 2007-12-05 19:30 Woody Woodring <george.woodring@iglass.net>
2007-12-05 22:33 ` Re: Connection attempt hangs when server is unresponsive Oliver Jowett <oliver@opencloud.com>
2007-12-06 12:23 ` Re: Connection attempt hangs when server is unresponsive Usama Dar <munir.usama@gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Woody Woodring @ 2007-12-05 19:30 UTC (permalink / raw)
To: pgsql-jdbc
We are using 1.2.1 of DBCP with our tomcat server to pool connections to
databases on the wide area. We had an issue today were our tomcat threads
started increasing dramatically when we had a Postgres server go away and we
found a lot of threads stuck trying to create a datasource:
at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav
a:753)
at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:5
40)
at
net.iglass.db.JdbcDbAccess.createConnection(JdbcDbAccess.java:122)
at
net.iglass.db.JdbcDbAccess.createConnection(JdbcDbAccess.java:134)
Since createDataSource is synchronized we traced them to the following
thread that had them blocked:
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:516)
at java.net.Socket.connect(Socket.java:466)
at java.net.Socket.(Socket.java:366)
at java.net.Socket.(Socket.java:179)
at org.postgresql.core.PGStream.(PGStream.java:58)
at
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFa
ctoryImpl.java:77)
at
org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:
65)
at
org.postgresql.jdbc2.AbstractJdbc2Connection.(AbstractJdbc2Connection.java:1
17)
at
org.postgresql.jdbc3.AbstractJdbc3Connection.(AbstractJdbc3Connection.java:3
0)
at org.postgresql.jdbc3.Jdbc3Connection.(Jdbc3Connection.java:24)
at org.postgresql.Driver.connect(Driver.java:235)
at
org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConne
ctionFactory.java:37)
at
org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnect
ionFactory.java:290)
at
org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataS
ource.java:877)
at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav
a:851)
at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:5
40)
at
net.iglass.db.JdbcDbAccess.createConnection(JdbcDbAccess.java:122)
at
net.iglass.db.JdbcDbAccess.createConnection(JdbcDbAccess.java:134)
My question is why this thread did not error out when it could not talk to
the server? Could the server have been up when the connection started and
went away in the middle causing errors? Could there be something we have
overlooked in our conf that would time it out? When the db server came
back, our thread count dropped from 200 down to 35 which is normal.
Thanks in advance,
Woody
----------------------------------------
iGLASS Networks
211-A S. Salem St
Apex NC 27502
(919) 387-3550 x813
www.iglass.net
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Connection attempt hangs when server is unresponsive
2007-12-05 19:30 Connection attempt hangs when server is unresponsive Woody Woodring <george.woodring@iglass.net>
@ 2007-12-05 22:33 ` Oliver Jowett <oliver@opencloud.com>
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Jowett @ 2007-12-05 22:33 UTC (permalink / raw)
To: Woody Woodring <george.woodring@iglass.net>; +Cc: pgsql-jdbc
Woody Woodring wrote:
> Since createDataSource is synchronized we traced them to the following
> thread that had them blocked:
>
> at java.net.PlainSocketImpl.socketConnect(Native Method)
That's an OS-level method, if it blocks and you have not set
loginTimeout there is not much the driver can do.
Maybe you should set loginTimeout? (It is more expensive as it spawns
extra threads to deal with timeouts in this sort of case, though)
-O
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Connection attempt hangs when server is unresponsive
2007-12-05 19:30 Connection attempt hangs when server is unresponsive Woody Woodring <george.woodring@iglass.net>
@ 2007-12-06 12:23 ` Usama Dar <munir.usama@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Usama Dar @ 2007-12-06 12:23 UTC (permalink / raw)
To: Woody Woodring <george.woodring@iglass.net>; +Cc: pgsql-jdbc
> My question is why this thread did not error out when it could not talk to
> the server? Could the server have been up when the connection started and
> went away in the middle causing errors? Could there be something we have
> overlooked in our conf that would time it out? When the db server came
> back, our thread count dropped from 200 down to 35 which is normal.
>
>
Look into
1- Setting the jdbc driver's login timeout
2- make sure that the connection attempts are not trying to do long name
resolution lookups
3- If you are using DBCP make sure tomcat is configured to remove abandoned
connections (removeAbandoned=true) and related parmeters are set to
reasonable value.
--
Usama Munir Dar http://linkedin.com/in/usamadar
Consultant Architect
Cell:+92 321 5020666
Skype: usamadar
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2007-12-06 12:23 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-12-05 19:30 Connection attempt hangs when server is unresponsive Woody Woodring <george.woodring@iglass.net>
2007-12-05 22:33 ` Oliver Jowett <oliver@opencloud.com>
2007-12-06 12:23 ` Usama Dar <munir.usama@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox