SocketException on connect, busy server

From: Palle Girgensohn <girgen(at)partitur(dot)se>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: SocketException on connect, busy server
Date: 2001-09-02 21:41:49
Message-ID: 3B92A79D.71F36AAC@partitur.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi!

On a busy server, serving web pages using tomcat and apache, I
get this error sometimes:

java.net.SocketException: errno: 48, error: Address already in
use for fd: 168
at java.net.PlainSocketImpl.socketConnect(Native
Method)
at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java,
Compiled Code)
at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java,
Compiled Code)
at
java.net.PlainSocketImpl.connect(PlainSocketImpl.java, Compiled
Code)
at java.net.Socket.<init>(Socket.java, Compiled Code)
at java.net.Socket.<init>(Socket.java, Compiled Code)
at org.postgresql.PG_Stream.<init>(PG_Stream.java,
Compiled Code)
at
org.postgresql.Connection.openConnection(Connection.java,
Compiled Code)
at org.postgresql.Driver.connect(Driver.java, Compiled
Code)
at
java.sql.DriverManager.getConnection(DriverManager.java,
Compiled Code)
at
java.sql.DriverManager.getConnection(DriverManager.java,
Compiled Code)
at
net.pingpong.util.core.PPDbBroker.getConnection(PPDbBroker.java,
Compiled Code)
at
net.pingpong.util.core.PPGlobalDbBroker.getConnection(PPGlobalDbBroker.java,
Compiled Code)
at
net.pingpong.core.PPPerson.getDepartmentId(PPPerson.java,
Compiled Code)
at
pp.system.ppentrance._0002fpp_0002fsystem_0002fppentrance_0002fevents_0002dcatalog_0002ejspevents_0002dcatalog_jsp_0._jspService(_0002fpp_0002fsystem_0
002fppentrance_0002fevents_0002dcatalog_0002ejspevents_0002dcatalog_jsp_0.java,
Compiled Code)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java,
Compiled Code)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java,
Compiled Code)
at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java,
Compiled Code)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java,
Compiled Code)
at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java,
Compiled Code)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java,
Compiled Code)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java,
Compiled Code)
at org.apache.tomcat.core.Handler.service(Handler.java,
Compiled Code)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java,
Compiled Code)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java,
Compiled Code)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java,
Compiled Code)
at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java,
Compiled Code)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java,
Compiled Code)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java,
Compiled Code)
at java.lang.Thread.run(Thread.java, Compiled Code)
End of Stack Trace

It happens around here in our app (in the database connection
broker):

synchronized (connections) {
if (connections.size() < maxConnections) {
// All connections used but we can open a new one.
try {
con = DriverManager.getConnection(dbURL, DEFAULT_USER,
DEFAULT_PASSWD);
connections.put(con, new PPDbConnData(false, new Date()));

(connections is a Hash containing a number of db connections).
Hence, it seems to happen only when all connections are busy
and opening a new one is necessary. This seems to me like some
kind of synchronization problem, but I can't find it. Any
ideas?

/Palle

--
Partitur Informationsteknik AB
Wenner-Gren Center +46 8 566 280 02
113 46 Stockholm +46 70 785 86 02
Sweden girgen(at)partitur(dot)se

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message andy 2001-09-03 05:47:29 JAVA vs PERL : PERL wins to postgreSQL
Previous Message Rene Pijlman 2001-09-02 12:12:08 Re: ? (question mark) characters