Thread: ERROR-org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.

Hi,
I am facing 'org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend' error while performing jdbc batch insert in postgre sql database using proxool connection pool. This error is random, but once it starts to come, it comes very frequently.
Both my database server and my jetty server are on same linux machine and the batch size is 1000, but changing batch size doesn't eliminate the error.
I don't have much idea about firewall but I don't think it should be an issue on same machine.

Setup details:-
pgsql 9.3
pg-jdbc driver - 9.3
proxool for jdbc connection pooling

Stack trace:-
unknown-ERROR-[JdbcExporter] Error while executing batch : Batch entry 0 insert into ldev (array_serial,date_time,ldev,read_iops,write_iops,rand_iops,seq_iops,read_xfer,write_xfer,read_hit_pct,write_hit_pct,read_resp,write_resp,total_resp,rand_xfer,seq_xfer) values (cast(get_SerialNo('48015') as integer),'2015-04-28 00:00:00.000000 +00:00:00',get_funcNameFromSignature('48015-00:00:CD'),3.1166666666666667,0.3833333333333333,(COALESCE(2.1166666666666667,0)+COALESCE(0.3833333333333333,0)),(COALESCE(1.0,0)+COALESCE(0.0,0)),convert_KBToMB(3078.483333333333),convert_KBToMB(6.383333333333334),100.0,NULL,convert_MiliSecToMicroSec(3.105),convert_MiliSecToMicroSec(0.2816666666666666),convert_MiliSecToMicroSec(3.386666666666666),convert_KBToMB(0.0),convert_KBToMB(0.0)) was aborted.  Call getNextException to see the cause.
2015-06-01 06:06:37,436 [48015_vsp_LdevPerf_12387041536606161 9364] unknown-ERROR-Batch Execute failed while inserting in database.
2015-06-01 06:06:37,436 [48015_vsp_LdevPerf_12387041536606161 9364] unknown-ERROR-org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:411)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2889)
        at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.logicalcobwebs.proxool.ProxyStatement.invoke(ProxyStatement.java:68)
        at org.logicalcobwebs.cglib.proxy.Proxy$ProxyImpl$$EnhancerByCGLIB$$44f8dff2.executeBatch(<generated>)
        at com.cs.core.tasks.export.JdbcExporter.a(JdbcExporter.java:393)
        at com.cs.core.tasks.export.JdbcExporter.e(JdbcExporter.java:345)
        at Aaaa_bf.c(BaseDataProcessor.java:137)
        at Aaaa_bi.a(DataProcessManager.java:114)
        at Aaaa_bi.b(DataProcessManager.java:29)
        at Aaaa_op.b(TaskScheduler.java:255)
        at Aaaa_ok.tj(TaskProcessInitiator.java:25)
        at Aaaa_ok.call(TaskProcessInitiator.java:11)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketException: Socket closed
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:152)
        at java.net.SocketInputStream.read(SocketInputStream.java:122)
        at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:143)
        at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:112)
        at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:71)
        at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:269)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1704)
        at org.postgresql.core.v3.QueryExecutorImpl.sendQuery(QueryExecutorImpl.java:1093)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:396)
        ... 20 more


Please help me with this.


Rahul Khandelwal wrote:
> I am facing 'org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend'
> error while performing jdbc batch insert in postgre sql database using proxool connection pool. This
> error is random, but once it starts to come, it comes very frequently.
> Both my database server and my jetty server are on same linux machine and the batch size is 1000, but
> changing batch size doesn't eliminate the error.
> I don't have much idea about firewall but I don't think it should be an issue on same machine.
> 
> Setup details:-
> pgsql 9.3
> pg-jdbc driver - 9.3
> proxool for jdbc connection pooling
> 
> Stack trace:-
[...]
> org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.
[...]
> Caused by: java.net.SocketException: Socket closed

Could you look into the database server log to see if there is anything relevant?

Are you using SSL?

Yours,
Laurenz Albe