Обсуждение: org.postgresql.util.PSQLException: An I/O error occured while sending to the backend

Поиск
Список
Период
Сортировка

org.postgresql.util.PSQLException: An I/O error occured while sending to the backend

От
Kiran Kulkarni
Дата:
I am getting this error couple of time in a day. How do I avoid it?

Before making the call, I am checking these below things.
session.isDirty: false
session.isOpen: true
session.isConnected: true
session.getStatistics: SessionStatistics[entity count=0collection count=0]

connManager.isCurrentlyConnected(): true
connManager.hasBorrowedConnection(): false

But even after this check i am getting this error. Pls help.

---------------------------------------------------------------

2012-06-27 12:48:17,957 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) session.isDirty: false
2012-06-27 12:48:17,957 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) session.isOpen: true
2012-06-27 12:48:17,957 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) session.isConnected: true
2012-06-27 12:48:17,957 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) session.getStatistics: SessionStatistics[entity count=0collection count=0]
2012-06-27 12:48:17,957 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) 
2012-06-27 12:48:17,957 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) connManager.isCurrentlyConnected(): true
2012-06-27 12:48:17,957 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) connManager.hasBorrowedConnection(): false
2012-06-27 12:48:17,957 DEBUG [org.hibernate.jdbc.ConnectionManager] (TimerForFileReading) opening JDBC connection
2012-06-27 12:48:17,957 DEBUG [org.hibernate.jdbc.ConnectionManager] (TimerForFileReading) opening JDBC connection
2012-06-27 12:48:17,957 TRACE [org.hibernate.connection.DriverManagerConnectionProvider] (TimerForFileReading) total checked-out connections: 0
2012-06-27 12:48:17,957 TRACE [org.hibernate.connection.DriverManagerConnectionProvider] (TimerForFileReading) total checked-out connections: 0
2012-06-27 12:48:17,958 TRACE [org.hibernate.connection.DriverManagerConnectionProvider] (TimerForFileReading) using pooled JDBC connection, pool size: 0
2012-06-27 12:48:17,958 TRACE [org.hibernate.connection.DriverManagerConnectionProvider] (TimerForFileReading) using pooled JDBC connection, pool size: 0
2012-06-27 12:48:17,958 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) connManager.getConnection(): org.postgresql.jdbc3.Jdbc3Connection@57005f31
2012-06-27 12:48:17,958 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) conn.isClosed(): false
2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction] (TimerForFileReading) begin
2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction] (TimerForFileReading) begin
2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction] (TimerForFileReading) current autocommit status: false
2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction] (TimerForFileReading) current autocommit status: false
2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.JDBCContext] (TimerForFileReading) after transaction begin
2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.JDBCContext] (TimerForFileReading) after transaction begin
2012-06-27 12:48:17,958 TRACE [org.hibernate.engine.query.QueryPlanCache] (TimerForFileReading) located native-sql query plan in cache (select count(*) from bbbb_deployment_location)
2012-06-27 12:48:17,958 TRACE [org.hibernate.engine.query.QueryPlanCache] (TimerForFileReading) located native-sql query plan in cache (select count(*) from bbbb_deployment_location)
2012-06-27 12:48:17,958 TRACE [org.hibernate.impl.SessionImpl] (TimerForFileReading) SQL query: select count(*) from bbbb_deployment_location
2012-06-27 12:48:17,958 TRACE [org.hibernate.impl.SessionImpl] (TimerForFileReading) SQL query: select count(*) from bbbb_deployment_location
2012-06-27 12:48:17,958 DEBUG [org.hibernate.jdbc.AbstractBatcher] (TimerForFileReading) about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2012-06-27 12:48:17,958 DEBUG [org.hibernate.jdbc.AbstractBatcher] (TimerForFileReading) about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2012-06-27 12:48:17,958 DEBUG [org.hibernate.SQL] (TimerForFileReading) select count(*) from bbbb_deployment_location
2012-06-27 12:48:17,958 DEBUG [org.hibernate.SQL] (TimerForFileReading) select count(*) from bbbb_deployment_location
2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.AbstractBatcher] (TimerForFileReading) preparing statement
2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.AbstractBatcher] (TimerForFileReading) preparing statement
2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.958 (2) simple execute, handler=org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler@6b443d9, maxRows=0, fetchSize=0, flags=1
2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959 (2)  FE=> Bind(stmt=S_1,portal=null)
2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959 (2)  FE=> Execute(portal=null,limit=0)
2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959 (2)  FE=> Parse(stmt=null,query="select count(*) from bbbb_deployment_location",oids={})
2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959 (2)  FE=> Bind(stmt=null,portal=null)
2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959 (2)  FE=> Describe(portal=null)
2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959 (2)  FE=> Execute(portal=null,limit=0)
2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959 (2)  FE=> Sync
2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) 13:03:43.626 (2)  FE=> Terminate
2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) 13:03:43.626 (2) Discarding IOException on close:
2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) java.net.SocketException: Broken pipe
2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) at java.net.SocketOutputStream.socketWrite0(Native Method)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.core.PGStream.flush(PGStream.java:508)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.core.v3.ProtocolConnectionImpl.close(ProtocolConnectionImpl.java:137)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:282)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.doQuery(Loader.java:696)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.doList(Loader.java:2233)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.list(Loader.java:2125)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at java.util.TimerThread.mainLoop(Timer.java:512)
2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at java.util.TimerThread.run(Timer.java:462)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.doQuery(Loader.java:696)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.doList(Loader.java:2233)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.Loader.list(Loader.java:2125)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at java.util.TimerThread.mainLoop(Timer.java:512)
2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at java.util.TimerThread.run(Timer.java:462)
2012-06-27 13:03:43,629 INFO  [STDOUT] (TimerForFileReading) SQLException: SQLState(08006)
2012-06-27 13:03:43,629 DEBUG [org.hibernate.jdbc.AbstractBatcher] (TimerForFileReading) about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2012-06-27 13:03:43,629 DEBUG [org.hibernate.jdbc.AbstractBatcher] (TimerForFileReading) about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2012-06-27 13:03:43,629 TRACE [org.hibernate.jdbc.AbstractBatcher] (TimerForFileReading) closing statement
2012-06-27 13:03:43,629 TRACE [org.hibernate.jdbc.AbstractBatcher] (TimerForFileReading) closing statement
2012-06-27 13:03:43,629 DEBUG [org.hibernate.util.JDBCExceptionReporter] (TimerForFileReading) could not execute query [select count(*) from bbbb_deployment_location]
org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
at org.hibernate.loader.Loader.doList(Loader.java:2233)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
at org.hibernate.loader.Loader.list(Loader.java:2125)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
at com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
at com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: java.net.SocketException: Connection timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
... 20 more
2012-06-27 13:03:43,629 DEBUG [org.hibernate.util.JDBCExceptionReporter] (TimerForFileReading) could not execute query [select count(*) from bbbb_deployment_location]
org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
at org.hibernate.loader.Loader.doList(Loader.java:2233)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
at org.hibernate.loader.Loader.list(Loader.java:2125)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
at com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
at com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: java.net.SocketException: Connection timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
... 20 more
2012-06-27 13:03:43,629 WARN  [org.hibernate.util.JDBCExceptionReporter] (TimerForFileReading) SQL Error: 0, SQLState: 08006
2012-06-27 13:03:43,629 WARN  [org.hibernate.util.JDBCExceptionReporter] (TimerForFileReading) SQL Error: 0, SQLState: 08006
2012-06-27 13:03:43,629 ERROR [org.hibernate.util.JDBCExceptionReporter] (TimerForFileReading) An I/O error occured while sending to the backend.
2012-06-27 13:03:43,629 ERROR [org.hibernate.util.JDBCExceptionReporter] (TimerForFileReading) An I/O error occured while sending to the backend.
2012-06-27 13:03:43,629 TRACE [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading) 
org.hibernate.exception.JDBCConnectionException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2236)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
at org.hibernate.loader.Loader.list(Loader.java:2125)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
at com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
at com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
at com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
at org.hibernate.loader.Loader.doList(Loader.java:2233)
... 12 more
Caused by: java.net.SocketException: Connection timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
... 20 more

Re: org.postgresql.util.PSQLException: An I/O error occured while sending to the backend

От
Dave Cramer
Дата:
Can you tell me the version of the driver you are using? Is there a
firewall ? Windows ?

We have had an unusually high number of reports of this lately

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Wed, Jun 27, 2012 at 6:15 PM, Kiran Kulkarni
<kkiran_kulkarni@yahoo.com> wrote:
> I am getting this error couple of time in a day. How do I avoid it?
>
> Before making the call, I am checking these below things.
> session.isDirty: false
> session.isOpen: true
> session.isConnected: true
> session.getStatistics: SessionStatistics[entity count=0collection count=0]
>
> connManager.isCurrentlyConnected(): true
> connManager.hasBorrowedConnection(): false
>
> But even after this check i am getting this error. Pls help.
>
> ---------------------------------------------------------------
>
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> session.isDirty: false
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> session.isOpen: true
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> session.isConnected: true
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> session.getStatistics: SessionStatistics[entity count=0collection count=0]
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> connManager.isCurrentlyConnected(): true
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> connManager.hasBorrowedConnection(): false
> 2012-06-27 12:48:17,957 DEBUG [org.hibernate.jdbc.ConnectionManager]
> (TimerForFileReading) opening JDBC connection
> 2012-06-27 12:48:17,957 DEBUG [org.hibernate.jdbc.ConnectionManager]
> (TimerForFileReading) opening JDBC connection
> 2012-06-27 12:48:17,957 TRACE
> [org.hibernate.connection.DriverManagerConnectionProvider]
> (TimerForFileReading) total checked-out connections: 0
> 2012-06-27 12:48:17,957 TRACE
> [org.hibernate.connection.DriverManagerConnectionProvider]
> (TimerForFileReading) total checked-out connections: 0
> 2012-06-27 12:48:17,958 TRACE
> [org.hibernate.connection.DriverManagerConnectionProvider]
> (TimerForFileReading) using pooled JDBC connection, pool size: 0
> 2012-06-27 12:48:17,958 TRACE
> [org.hibernate.connection.DriverManagerConnectionProvider]
> (TimerForFileReading) using pooled JDBC connection, pool size: 0
> 2012-06-27 12:48:17,958 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> connManager.getConnection(): org.postgresql.jdbc3.Jdbc3Connection@57005f31
> 2012-06-27 12:48:17,958 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> conn.isClosed(): false
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction]
> (TimerForFileReading) begin
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction]
> (TimerForFileReading) begin
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction]
> (TimerForFileReading) current autocommit status: false
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction]
> (TimerForFileReading) current autocommit status: false
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.JDBCContext]
> (TimerForFileReading) after transaction begin
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.JDBCContext]
> (TimerForFileReading) after transaction begin
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.engine.query.QueryPlanCache]
> (TimerForFileReading) located native-sql query plan in cache (select
> count(*) from bbbb_deployment_location)
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.engine.query.QueryPlanCache]
> (TimerForFileReading) located native-sql query plan in cache (select
> count(*) from bbbb_deployment_location)
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.impl.SessionImpl]
> (TimerForFileReading) SQL query: select count(*) from
> bbbb_deployment_location
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.impl.SessionImpl]
> (TimerForFileReading) SQL query: select count(*) from
> bbbb_deployment_location
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) about to open PreparedStatement (open
> PreparedStatements: 0, globally: 0)
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) about to open PreparedStatement (open
> PreparedStatements: 0, globally: 0)
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.SQL] (TimerForFileReading)
> select count(*) from bbbb_deployment_location
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.SQL] (TimerForFileReading)
> select count(*) from bbbb_deployment_location
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) preparing statement
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) preparing statement
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.958
> (2) simple execute,
> handler=org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler@6b443d9,
> maxRows=0, fetchSize=0, flags=1
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Bind(stmt=S_1,portal=null)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Execute(portal=null,limit=0)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Parse(stmt=null,query="select count(*) from
> bbbb_deployment_location",oids={})
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Bind(stmt=null,portal=null)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Describe(portal=null)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Execute(portal=null,limit=0)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Sync
> 2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) 13:03:43.626
> (2)  FE=> Terminate
> 2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) 13:03:43.626
> (2) Discarding IOException on close:
> 2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading)
> java.net.SocketException: Broken pipe
> 2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) at
> java.net.SocketOutputStream.socketWrite0(Native Method)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.net.SocketOutputStream.write(SocketOutputStream.java:136)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.core.PGStream.flush(PGStream.java:508)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.core.v3.ProtocolConnectionImpl.close(ProtocolConnectionImpl.java:137)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:282)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doQuery(Loader.java:696)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doList(Loader.java:2233)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.list(Loader.java:2125)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.util.TimerThread.mainLoop(Timer.java:512)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.util.TimerThread.run(Timer.java:462)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading)
> org.postgresql.util.PSQLException: An I/O error occured while sending to the
> backend.
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doQuery(Loader.java:696)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doList(Loader.java:2233)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.list(Loader.java:2125)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> java.util.TimerThread.mainLoop(Timer.java:512)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> java.util.TimerThread.run(Timer.java:462)
> 2012-06-27 13:03:43,629 INFO  [STDOUT] (TimerForFileReading) SQLException:
> SQLState(08006)
> 2012-06-27 13:03:43,629 DEBUG [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) about to close PreparedStatement (open
> PreparedStatements: 1, globally: 1)
> 2012-06-27 13:03:43,629 DEBUG [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) about to close PreparedStatement (open
> PreparedStatements: 1, globally: 1)
> 2012-06-27 13:03:43,629 TRACE [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) closing statement
> 2012-06-27 13:03:43,629 TRACE [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) closing statement
> 2012-06-27 13:03:43,629 DEBUG [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) could not execute query [select count(*) from
> bbbb_deployment_location]
> org.postgresql.util.PSQLException: An I/O error occured while sending to the
> backend.
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> at org.hibernate.loader.Loader.doQuery(Loader.java:696)
> at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> at org.hibernate.loader.Loader.doList(Loader.java:2233)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> at org.hibernate.loader.Loader.list(Loader.java:2125)
> at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> at java.util.TimerThread.mainLoop(Timer.java:512)
> at java.util.TimerThread.run(Timer.java:462)
> Caused by: java.net.SocketException: Connection timed out
> at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> at
> org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
> at
> org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
> at
> org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
> at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
> at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
> ... 20 more
> 2012-06-27 13:03:43,629 DEBUG [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) could not execute query [select count(*) from
> bbbb_deployment_location]
> org.postgresql.util.PSQLException: An I/O error occured while sending to the
> backend.
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> at org.hibernate.loader.Loader.doQuery(Loader.java:696)
> at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> at org.hibernate.loader.Loader.doList(Loader.java:2233)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> at org.hibernate.loader.Loader.list(Loader.java:2125)
> at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> at java.util.TimerThread.mainLoop(Timer.java:512)
> at java.util.TimerThread.run(Timer.java:462)
> Caused by: java.net.SocketException: Connection timed out
> at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> at
> org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
> at
> org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
> at
> org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
> at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
> at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
> ... 20 more
> 2012-06-27 13:03:43,629 WARN  [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) SQL Error: 0, SQLState: 08006
> 2012-06-27 13:03:43,629 WARN  [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) SQL Error: 0, SQLState: 08006
> 2012-06-27 13:03:43,629 ERROR [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) An I/O error occured while sending to the backend.
> 2012-06-27 13:03:43,629 ERROR [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) An I/O error occured while sending to the backend.
> 2012-06-27 13:03:43,629 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> org.hibernate.exception.JDBCConnectionException: could not execute query
> at
> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
> at
> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
> at org.hibernate.loader.Loader.doList(Loader.java:2236)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> at org.hibernate.loader.Loader.list(Loader.java:2125)
> at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> at java.util.TimerThread.mainLoop(Timer.java:512)
> at java.util.TimerThread.run(Timer.java:462)
> Caused by: org.postgresql.util.PSQLException: An I/O error occured while
> sending to the backend.
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> at org.hibernate.loader.Loader.doQuery(Loader.java:696)
> at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> at org.hibernate.loader.Loader.doList(Loader.java:2233)
> ... 12 more
> Caused by: java.net.SocketException: Connection timed out
> at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> at
> org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
> at
> org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
> at
> org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
> at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
> at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
> ... 20 more
>

Re: org.postgresql.util.PSQLException: An I/O error occured while sending to the backend

От
Kiran Kulkarni
Дата:
Hello David,
We are using postgres 9.0 and JDBC driver is postgresql-8.4-701.jdbc3.jar.
Our app server & DB, both are running on Linux and there is a firewall between app server and DB.

Can upgrading the driver to higher version fix this problem?

I have seen similar posts on the web. Most tell either to reconnect or to try TCP Keep alive.
For my case, hibernate is managing my connections and I would expect hibernate to deal with such scenarios. But since it is not dealing with such issues I would be more comfortable configuring tcp keep alive rather than meddling hibernate managed connections.

Do you know any configuration in hibernate which takes care of such issues? Or else pls give me the steps to configure tcp keep alive.

Regards,
Kiran Kulkarni


From: Dave Cramer <pg@fastcrypt.com>
To: Kiran Kulkarni <kkiran_kulkarni@yahoo.com>
Cc: "pgsql-jdbc@postgresql.org" <pgsql-jdbc@postgresql.org>
Sent: Thursday, June 28, 2012 6:08 AM
Subject: Re: [JDBC] org.postgresql.util.PSQLException: An I/O error occured while sending to the backend

Can you tell me the version of the driver you are using? Is there a
firewall ? Windows ?

We have had an unusually high number of reports of this lately

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Wed, Jun 27, 2012 at 6:15 PM, Kiran Kulkarni
<kkiran_kulkarni@yahoo.com> wrote:
> I am getting this error couple of time in a day. How do I avoid it?
>
> Before making the call, I am checking these below things.
> session.isDirty: false
> session.isOpen: true
> session.isConnected: true
> session.getStatistics: SessionStatistics[entity count=0collection count=0]
>
> connManager.isCurrentlyConnected(): true
> connManager.hasBorrowedConnection(): false
>
> But even after this check i am getting this error. Pls help.
>
> ---------------------------------------------------------------
>
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> session.isDirty: false
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> session.isOpen: true
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> session.isConnected: true
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> session.getStatistics: SessionStatistics[entity count=0collection count=0]
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> connManager.isCurrentlyConnected(): true
> 2012-06-27 12:48:17,957 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> connManager.hasBorrowedConnection(): false
> 2012-06-27 12:48:17,957 DEBUG [org.hibernate.jdbc.ConnectionManager]
> (TimerForFileReading) opening JDBC connection
> 2012-06-27 12:48:17,957 DEBUG [org.hibernate.jdbc.ConnectionManager]
> (TimerForFileReading) opening JDBC connection
> 2012-06-27 12:48:17,957 TRACE
> [org.hibernate.connection.DriverManagerConnectionProvider]
> (TimerForFileReading) total checked-out connections: 0
> 2012-06-27 12:48:17,957 TRACE
> [org.hibernate.connection.DriverManagerConnectionProvider]
> (TimerForFileReading) total checked-out connections: 0
> 2012-06-27 12:48:17,958 TRACE
> [org.hibernate.connection.DriverManagerConnectionProvider]
> (TimerForFileReading) using pooled JDBC connection, pool size: 0
> 2012-06-27 12:48:17,958 TRACE
> [org.hibernate.connection.DriverManagerConnectionProvider]
> (TimerForFileReading) using pooled JDBC connection, pool size: 0
> 2012-06-27 12:48:17,958 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> connManager.getConnection(): org.postgresql.jdbc3.Jdbc3Connection@57005f31
> 2012-06-27 12:48:17,958 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> conn.isClosed(): false
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction]
> (TimerForFileReading) begin
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction]
> (TimerForFileReading) begin
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction]
> (TimerForFileReading) current autocommit status: false
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.transaction.JDBCTransaction]
> (TimerForFileReading) current autocommit status: false
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.JDBCContext]
> (TimerForFileReading) after transaction begin
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.JDBCContext]
> (TimerForFileReading) after transaction begin
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.engine.query.QueryPlanCache]
> (TimerForFileReading) located native-sql query plan in cache (select
> count(*) from bbbb_deployment_location)
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.engine.query.QueryPlanCache]
> (TimerForFileReading) located native-sql query plan in cache (select
> count(*) from bbbb_deployment_location)
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.impl.SessionImpl]
> (TimerForFileReading) SQL query: select count(*) from
> bbbb_deployment_location
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.impl.SessionImpl]
> (TimerForFileReading) SQL query: select count(*) from
> bbbb_deployment_location
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) about to open PreparedStatement (open
> PreparedStatements: 0, globally: 0)
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) about to open PreparedStatement (open
> PreparedStatements: 0, globally: 0)
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.SQL] (TimerForFileReading)
> select count(*) from bbbb_deployment_location
> 2012-06-27 12:48:17,958 DEBUG [org.hibernate.SQL] (TimerForFileReading)
> select count(*) from bbbb_deployment_location
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) preparing statement
> 2012-06-27 12:48:17,958 TRACE [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) preparing statement
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.958
> (2) simple execute,
> handler=org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler@6b443d9,
> maxRows=0, fetchSize=0, flags=1
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Bind(stmt=S_1,portal=null)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Execute(portal=null,limit=0)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Parse(stmt=null,query="select count(*) from
> bbbb_deployment_location",oids={})
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Bind(stmt=null,portal=null)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Describe(portal=null)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Execute(portal=null,limit=0)
> 2012-06-27 12:48:17,959 INFO  [STDOUT] (TimerForFileReading) 12:48:17.959
> (2)  FE=> Sync
> 2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) 13:03:43.626
> (2)  FE=> Terminate
> 2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) 13:03:43.626
> (2) Discarding IOException on close:
> 2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading)
> java.net.SocketException: Broken pipe
> 2012-06-27 13:03:43,626 INFO  [STDOUT] (TimerForFileReading) at
> java.net.SocketOutputStream.socketWrite0(Native Method)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.net.SocketOutputStream.write(SocketOutputStream.java:136)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.core.PGStream.flush(PGStream.java:508)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.core.v3.ProtocolConnectionImpl.close(ProtocolConnectionImpl.java:137)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:282)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doQuery(Loader.java:696)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doList(Loader.java:2233)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.list(Loader.java:2125)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.util.TimerThread.mainLoop(Timer.java:512)
> 2012-06-27 13:03:43,627 INFO  [STDOUT] (TimerForFileReading) at
> java.util.TimerThread.run(Timer.java:462)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading)
> org.postgresql.util.PSQLException: An I/O error occured while sending to the
> backend.
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doQuery(Loader.java:696)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.doList(Loader.java:2233)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.Loader.list(Loader.java:2125)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> java.util.TimerThread.mainLoop(Timer.java:512)
> 2012-06-27 13:03:43,628 INFO  [STDOUT] (TimerForFileReading) at
> java.util.TimerThread.run(Timer.java:462)
> 2012-06-27 13:03:43,629 INFO  [STDOUT] (TimerForFileReading) SQLException:
> SQLState(08006)
> 2012-06-27 13:03:43,629 DEBUG [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) about to close PreparedStatement (open
> PreparedStatements: 1, globally: 1)
> 2012-06-27 13:03:43,629 DEBUG [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) about to close PreparedStatement (open
> PreparedStatements: 1, globally: 1)
> 2012-06-27 13:03:43,629 TRACE [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) closing statement
> 2012-06-27 13:03:43,629 TRACE [org.hibernate.jdbc.AbstractBatcher]
> (TimerForFileReading) closing statement
> 2012-06-27 13:03:43,629 DEBUG [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) could not execute query [select count(*) from
> bbbb_deployment_location]
> org.postgresql.util.PSQLException: An I/O error occured while sending to the
> backend.
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> at org.hibernate.loader.Loader.doQuery(Loader.java:696)
> at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> at org.hibernate.loader.Loader.doList(Loader.java:2233)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> at org.hibernate.loader.Loader.list(Loader.java:2125)
> at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> at java.util.TimerThread.mainLoop(Timer.java:512)
> at java.util.TimerThread.run(Timer.java:462)
> Caused by: java.net.SocketException: Connection timed out
> at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> at
> org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
> at
> org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
> at
> org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
> at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
> at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
> ... 20 more
> 2012-06-27 13:03:43,629 DEBUG [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) could not execute query [select count(*) from
> bbbb_deployment_location]
> org.postgresql.util.PSQLException: An I/O error occured while sending to the
> backend.
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> at org.hibernate.loader.Loader.doQuery(Loader.java:696)
> at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> at org.hibernate.loader.Loader.doList(Loader.java:2233)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> at org.hibernate.loader.Loader.list(Loader.java:2125)
> at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> at java.util.TimerThread.mainLoop(Timer.java:512)
> at java.util.TimerThread.run(Timer.java:462)
> Caused by: java.net.SocketException: Connection timed out
> at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> at
> org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
> at
> org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
> at
> org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
> at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
> at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
> ... 20 more
> 2012-06-27 13:03:43,629 WARN  [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) SQL Error: 0, SQLState: 08006
> 2012-06-27 13:03:43,629 WARN  [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) SQL Error: 0, SQLState: 08006
> 2012-06-27 13:03:43,629 ERROR [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) An I/O error occured while sending to the backend.
> 2012-06-27 13:03:43,629 ERROR [org.hibernate.util.JDBCExceptionReporter]
> (TimerForFileReading) An I/O error occured while sending to the backend.
> 2012-06-27 13:03:43,629 TRACE
> [com.aaaa.bbbb.dbconnection.RdbConnectionFactory] (TimerForFileReading)
> org.hibernate.exception.JDBCConnectionException: could not execute query
> at
> org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
> at
> org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
> at org.hibernate.loader.Loader.doList(Loader.java:2236)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2130)
> at org.hibernate.loader.Loader.list(Loader.java:2125)
> at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
> at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1724)
> at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
> at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.testSession(RdbConnectionFactory.java:153)
> at
> com.aaaa.bbbb.dbconnection.RdbConnectionFactory.getSession(RdbConnectionFactory.java:100)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading.updateDB(TimerForFileReading.java:103)
> at
> com.aaaa.bbbb.scheduler.TimerForFileReading$1.run(TimerForFileReading.java:91)
> at java.util.TimerThread.mainLoop(Timer.java:512)
> at java.util.TimerThread.run(Timer.java:462)
> Caused by: org.postgresql.util.PSQLException: An I/O error occured while
> sending to the backend.
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:283)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
> at org.hibernate.loader.Loader.doQuery(Loader.java:696)
> at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
> at org.hibernate.loader.Loader.doList(Loader.java:2233)
> ... 12 more
> Caused by: java.net.SocketException: Connection timed out
> at java.net.SocketInputStream.socketRead0(Native Method)
> at java.net.SocketInputStream.read(SocketInputStream.java:129)
> at
> org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
> at
> org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
> at
> org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
> at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
> at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1620)
> at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
> ... 20 more
>


Re: org.postgresql.util.PSQLException: An I/O error occured while sending to the backend

От
Craig Ringer
Дата:
(I accidentally sent this direct a couple of days ago; re-posting on-list)

On 06/28/2012 06:15 AM, Kiran Kulkarni wrote:
I am getting this error couple of time in a day. How do I avoid it?

Before making the call, I am checking these below things.
session.isDirty: false
session.isOpen: true
session.isConnected: true
session.getStatistics: SessionStatistics[entity count=0collection count=0]

connManager.isCurrentlyConnected(): true
connManager.hasBorrowedConnection(): false

But even after this check i am getting this error. Pls help.

Your connections are timing out. Without knowing how you connect to your database (host, via what conection, routers and nat in the way, etc) it's had to say why. You also haven't shown the PostgreSQL logs, which may contain additional information.

Setting a tcp keepalive may help.

More importantly though, your app must be robust in the face of errors and failed connections. You can test that a connection is OK, then go to us it and find that it broke in the tiny interval since you tested it - maybe the DB server got restated, maybe the network had a hiccup, whatever. You need to be able to open a new connection and retry your work when the connection fails, same way you need to be able to reissue a unit of work when there's a serialization failure in a serializable transaction.

Most JDBC work should look roughly like:

boolean work_done = false;
do {
  try {
     .. open a transaction ...
     .. do the work ...
     .. commit ...
  } catch ( ... various jdbc and ORM exceptions ... ) {
    .. Terminate the transaction
    try {
      ... issue a dummy query to see if the connection is usable
    } catch ( ... exception types ... ) {
      .. connection unusable, get a new connection
    }
  }
} while (!work_done);


The same logic applies if you're using an ORM like Hibernate, but you *also* have to cope with the fact that Hibernate and other JPA implementations leave your object graphs in an invalid state if a database operation fails. To cope with this, use Hibernate's SerializatiionHelper ( http://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/util/SerializationHelper.html) to clone your object graph before merging/persisting. If there's an error in the database operation, discard the objects used in the operation, clone a new set from your backup copy, and try to commit them instead.

You can avoid cloning backups if it's easier for you to discard the object graph, fetch another from the database (usually actually from Hibernate's L1 cache), modify them again, and re-merge them.

Either way, your database access logic then looks like this:

.. (maybe) clone object graph ...
boolean work_done = false;
do {
  try {
     .. open a transaction ...
     .. do the work ...
     .. commit ...
  } catch ( ... various jdbc and ORM exceptions ... ) {
    .. Terminate the transaction
    try {
      ... issue a dummy query to see if the connection is usable
    } catch ( ... exception types ... ) {
      .. connection unusable, get a new connection
    }
    .. replace the object being merged/committed with a fresh one
    .. either by repeating the work or by restoring a cloned copy.
  }
} while (!work_done);


Annoying? Welcome to robustly using databases from application code. The alternative is accepting that your users will see database access errors you could prevent and possibly have to re-do work when a transient database issue occurs. I don't think that's good enough.

You shouldn't be repeating this stuff everywhere, though; when I was using non-container-managed transactions I had helper class that does most of the work. I just extended it with anonymous inner classes that overrode prepareGraphForPersist() and persistGraph() methods in my helper. I might still be able to find it somewhere; let me know if it'd be useful.

--
Craig Ringer

Re: org.postgresql.util.PSQLException: An I/O error occured while sending to the backend

От
Craig Ringer
Дата:
On 06/29/2012 12:15 AM, Kiran Kulkarni wrote:
Hello David,
We are using postgres 9.0 and JDBC driver is postgresql-8.4-701.jdbc3.jar.

Try to use a JDBC driver at least as new, if not newer than, the server. The client(s) should always be the same release as or newer than the server. The same goes for psql, libpq, etc.

Our app server & DB, both are running on Linux and there is a firewall between app server and DB.
Tharrr's yer problem.

Does the firewall do NAT or stateful connection tracking? If so, you must use keepalives to avoid connection drops if your connections are idle for long. If you don't know, then your firewall probably does do connection tracking and thus you must use keepalives.

If you're on a Java EE application server you can get the server to send a dummy connection check statement like "SELECT 1" every now and then instead of using OS level keepalives. I'd prefer an OS level keepalive, though, as unlike connection check statements they don't fill the logs with noise.

Can upgrading the driver to higher version fix this problem?

Probably not if there's a firewall involved.

I have seen similar posts on the web. Most tell either to reconnect or to try TCP Keep alive.
For my case, hibernate is managing my connections and I would expect hibernate to deal with such scenarios.
It doesn't and it can't.

If you configure your connection pool to verify/check connections you'll reduce the frequency with which this happens, but not eliminate it. Your app MUST handle connection and transaction failures if it wants to be robust. It's a pain, but necessary.

But since it is not dealing with such issues I would be more comfortable configuring tcp keep alive rather than meddling hibernate managed connections.

Do you know any configuration in hibernate which takes care of such issues? Or else pls give me the steps to configure tcp keep alive.

Hibernate cannot do everything for you. If the database connection is lost partway through a transaction then YOU must reissue the work. It'd be nice if Hibernate could handle the reconnect-and-retry logic for you, but at the moment it can't - and in fact it even mangles your entity objects when a transaction fails.

I wrote a post on another thread about this a day or two ago, but accidentally forgot to CC the list. I've re-posted it with subject "Re: [JDBC] org.postgresql.util.PSQLException: An I/O error occured while sending to the backend" and it should appear in the archives as http://archives.postgresql.org/message-id/4FED1C55.4050507@ringerc.id.au when the archives are next updated.

--
Craig Ringer

Re: org.postgresql.util.PSQLException: An I/O error occured while sending to the backend

От
Kiran Kulkarni
Дата:
Craig, David,

Thank you very much for your detailed explanation

Regards,
Kiran Kulkarni


From: Craig Ringer <ringerc@ringerc.id.au>
To: Kiran Kulkarni <kkiran_kulkarni@yahoo.com>
Cc: Dave Cramer <pg@fastcrypt.com>; "pgsql-jdbc@postgresql.org" <pgsql-jdbc@postgresql.org>
Sent: Thursday, June 28, 2012 11:15 PM
Subject: Re: [JDBC] org.postgresql.util.PSQLException: An I/O error occured while sending to the backend

On 06/29/2012 12:15 AM, Kiran Kulkarni wrote:
Hello David,
We are using postgres 9.0 and JDBC driver is postgresql-8.4-701.jdbc3.jar.

Try to use a JDBC driver at least as new, if not newer than, the server. The client(s) should always be the same release as or newer than the server. The same goes for psql, libpq, etc.

Our app server & DB, both are running on Linux and there is a firewall between app server and DB.
Tharrr's yer problem.

Does the firewall do NAT or stateful connection tracking? If so, you must use keepalives to avoid connection drops if your connections are idle for long. If you don't know, then your firewall probably does do connection tracking and thus you must use keepalives.

If you're on a Java EE application server you can get the server to send a dummy connection check statement like "SELECT 1" every now and then instead of using OS level keepalives. I'd prefer an OS level keepalive, though, as unlike connection check statements they don't fill the logs with noise.

Can upgrading the driver to higher version fix this problem?

Probably not if there's a firewall involved.

I have seen similar posts on the web. Most tell either to reconnect or to try TCP Keep alive.
For my case, hibernate is managing my connections and I would expect hibernate to deal with such scenarios.
It doesn't and it can't.

If you configure your connection pool to verify/check connections you'll reduce the frequency with which this happens, but not eliminate it. Your app MUST handle connection and transaction failures if it wants to be robust. It's a pain, but necessary.

But since it is not dealing with such issues I would be more comfortable configuring tcp keep alive rather than meddling hibernate managed connections.

Do you know any configuration in hibernate which takes care of such issues? Or else pls give me the steps to configure tcp keep alive.

Hibernate cannot do everything for you. If the database connection is lost partway through a transaction then YOU must reissue the work. It'd be nice if Hibernate could handle the reconnect-and-retry logic for you, but at the moment it can't - and in fact it even mangles your entity objects when a transaction fails.

I wrote a post on another thread about this a day or two ago, but accidentally forgot to CC the list. I've re-posted it with subject "Re: [JDBC] org.postgresql.util.PSQLException: An I/O error occured while sending to the backend" and it should appear in the archives as http://archives.postgresql.org/message-id/4FED1C55.4050507@ringerc.id.au when the archives are next updated.

--
Craig Ringer