Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xk6aK-0007KX-Hm for pgsql-jdbc@arkaria.postgresql.org; Fri, 31 Oct 2014 07:25:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Xk6aI-0004Z8-Ue for pgsql-jdbc@arkaria.postgresql.org; Fri, 31 Oct 2014 07:25:23 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Xk6aG-0004Yz-Mi for pgsql-jdbc@postgresql.org; Fri, 31 Oct 2014 07:25:20 +0000 Received: from blu004-omc2s7.hotmail.com ([65.55.111.82]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xk6aA-0004FP-Nk for pgsql-jdbc@postgresql.org; Fri, 31 Oct 2014 07:25:17 +0000 Received: from BLU172-W6 ([65.55.111.73]) by BLU004-OMC2S7.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751); Fri, 31 Oct 2014 00:25:13 -0700 X-TMN: [B+ivMGhe69P9yWKaSKzkKdO+OQErS1/6] X-Originating-Email: [dhavallj@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="_0c0cedea-e62f-4bf4-9c67-549b6b5df523_" From: dhaval jaiswal To: Dave Cramer CC: Kevin Grittner , "pgsql-jdbc@postgresql.org" Subject: Re: Hung thread Date: Fri, 31 Oct 2014 12:55:12 +0530 Importance: Normal In-Reply-To: References: , , , <1414506496.58956.YahooMailNeo@web122301.mail.ne1.yahoo.com>, , , MIME-Version: 1.0 X-OriginalArrivalTime: 31 Oct 2014 07:25:13.0790 (UTC) FILETIME=[CFC5DDE0:01CFF4DB] X-Pg-Spam-Score: -1.5 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org --_0c0cedea-e62f-4bf4-9c67-549b6b5df523_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Kevin/Dave=2C=20 I would really appreciate if you can help me to solve this issue. I have ch= ecked at network end and there is no idle session timeout policy between tw= o segment (from tomcat to the db server).=20 Adding to that it happens some time only.=20 DB end i found below logs=2C however not sure whether it is reflecting for = which connection.=20 could not receive data from client: Connection reset by peer unexpected EOF on client connection From: dhavallj@hotmail.com To: pg@fastcrypt.com CC: kgrittn@ymail.com=3B pgsql-jdbc@postgresql.org Subject: RE: [JDBC] Hung thread Date: Wed=2C 29 Oct 2014 14:24:04 +0530 =0A= =0A= =0A= maxWait=3D"30000" ms From: pg@fastcrypt.com Date: Tue=2C 28 Oct 2014 13:47:25 -0400 Subject: Re: [JDBC] Hung thread To: dhavallj@hotmail.com CC: kgrittn@ymail.com=3B pgsql-jdbc@postgresql.org So it is possible that as Kevin said the test on borrow statement referred = to a connection that was still in the TCP stack but had not timed out yet. How long did you wait ?Dave Cramer dave.cramer(at)credativ(dot)ca http://www.credativ.ca =0A= On 28 October 2014 13:44=2C dhaval jaiswal wrote: =0A= =0A= =0A= Following is the JDBC connection. =20 There is nothing reflecting in the result of the pg_stat_activity.=20 There is no relevant logs found in pg_logs too. Thread is not only stuck at the time of get connection. Some times at the t= ime of query execution.=20 java.net.SocketInputStream.socketRead0(Native Method) java.net.SocketInputStream.read(SocketInputStream.java:129) org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInp= utStream.java:145) org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBuffered= InputStream.java:114) org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputSt= ream.java:73) org.postgresql.core.PGStream.ReceiveChar(PGStream.java:274) org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.= java:1660) org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:25= 7) org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement= .java:500) org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2= Statement.java:388) org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Stat= ement.java:273) com.eos.accounts.data.OrderAuthorization.loadOrderAuthorization(OrderAutho= rization.java:102) com.eos.tally.reports.data.TallyOrder.getOrdersForTallyReport(TallyOrder.j= ava:88) com.eos.tally.reports.SaleReport.setData(SaleReport.java:71) com.eos.tally.reports.AgentSaleReport.generateMap(AgentSaleReport.java:25) com.eos.tally.reports.AbstractTallyReport.generateTallyReport(AbstractTall= yReport.java:171) com.eos.tally.reports.TallyReport.generateReport(TallyReport.java:112) com.eos.b2c.beans.callcenter.AccountingBean.downloadTallyAgentSalesReport(= AccountingBean.java:602) com.eos.b2c.ui.B2cCallcenterNavigation.doGet(B2cCallcenterNavigation.java:= 1117) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicati= onFilterChain.java:290) =20 TCP_KEEP_ALIVE is 2 hours at the server level. =20 > Date: Tue=2C 28 Oct 2014 07:28:16 -0700 > From: kgrittn@ymail.com > Subject: Re: [JDBC] Hung thread > To: pg@fastcrypt.com=3B dhavallj@hotmail.com > CC: pgsql-jdbc@postgresql.org >=20 > Dave Cramer wrote: > > On 28 October 2014 07:34=2C dhaval jaiswal wrote= : >=20 > >> java.lang.Thread.State: RUNNABLE > >> at java.net.SocketInputStream.socketRead0(Native Method) > >> at java.net.SocketInputStream.read(SocketInputStream.java:129) > >> at org.postgresql.core.VisibleBufferedInputStream.readMore(Visi= bleBufferedInputStream.java:145) > >> at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(V= isibleBufferedInputStream.java:114) > >> at org.postgresql.core.VisibleBufferedInputStream.read(VisibleB= ufferedInputStream.java:73) > >> at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:274) > >> at org.postgresql.core.v3.QueryExecutorImpl.processResults(Quer= yExecutorImpl.java:1660) > >> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecut= orImpl.java:257) > >> - locked <0x00002aaaf6282d00> (a org.postgresql.core.v3.QueryEx= ecutorImpl) > >> at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(Abstract= Jdbc2Statement.java:500) > >> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags= (AbstractJdbc2Statement.java:374) > >> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(Abs= tractJdbc2Statement.java:254) > >> at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery= (DelegatingStatement.java:208) > >> at org.apache.tomcat.dbcp.dbcp.AbandonedObjectPool.borrowObject= (AbandonedObjectPool.java:84) > >> at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConnection(= PoolingDataSource.java:96) > >> at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(Ba= sicDataSource.java:880) > >> at com.eos.hotels.viahotel.manager.ViaHotelDatabaseManager.getC= onnection(ViaHotelDatabaseManager.java:74) > [ snip ] >=20 > > Given the little bit of information available my guess would be > > that since this is using dbcp=2C and the connections are never really > > closed. >=20 > The stack trace shows that the getConnection() method of dbcp is > trying to re-use a connection in the pool=2C and is first testing the > connection by invoking our JDBC driver's executeQuery() method. >=20 > > I believe once a connection is made we are always listening > > on the socket. >=20 > I don't follow that=3B it is listening for the response to a query. > What thread would be "always listening"=2C anyway? The driver is not > multi-threaded. >=20 > > However I will say I haven't really spent much time on this. Either > > way we would need much more information in order to be able to help > > you. >=20 > It would be interesting to know what query dbcp is using to test > whether the connection is still alive. Also=2C if the client port > can be discovered=2C looking for it in the pg_stat_activity view > would be interesting. >=20 > I can think of one halfway plausible explanation=2C though. A > firewall between the machine running dbcp and the database server > might be blocking traffic after some idle timeout=2C possibly > resulting in a hang like this when the pooler eventually tries to > use the connection again. You might want to try configuring TCP > timeouts on both the client and the server. It wouldn't hurt to > closely review the network path between the machines. >=20 > Logging connections and disconnections and closely reviewing the > server logs could provide insights. >=20 > -- > Kevin Grittner > EDB: http://www.enterprisedb.com > The Enterprise PostgreSQL Company =0A= = --_0c0cedea-e62f-4bf4-9c67-549b6b5df523_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Kevin/Dave=2C

I would re= ally appreciate if you can help me to solve this issue. I have checked at n= etwork end and there is no idle session timeout policy between two segment = (from tomcat to the db server).

Adding to that it happens some time= only.

DB end i found below logs=2C however not sure whether it is = reflecting for which connection.

could not receive data from client= : Connection reset by peer
unexpected EOF on client connection



From: dhavallj@hotmail.com
To: pg@fas= tcrypt.com
CC: kgrittn@ymail.com=3B pgsql-jdbc@postgresql.org
Subject= : RE: [JDBC] Hung thread
Date: Wed=2C 29 Oct 2014 14:24:04 +0530

= =0A= =0A= =0A=
maxWait=3D"30000" ms



From: pg@fastcrypt.com
Date: Tue=2C 28 Oct 2014 13:47:25 -0400
= Subject: Re: [JDBC] Hung thread
To: dhavallj@hotmail.com
CC: kgrittn@= ymail.com=3B pgsql-jdbc@postgresql.org

So it is pos= sible that as Kevin said the test on borrow statement referred to a connect= ion that was still in the TCP stack but had not timed out yet.

How long did you wait ?
Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca
=0A=
On 28 October 2014 13:44=2C dhaval jaiswa= l <=3Bdhavallj@hotmail.com>=3B wrote:
=0A= =0A= =0A=
Following is the JDBC connection. =3B

 =3B =3B =3B =3B =3B =3B =3B <=3BResource na= me=3D"jdbc/DB" auth=3D"Container" type=3D"javax.sql.DataSource"
 =3B=  =3B =3B =3B =3B =3B =3B driverClassName=3D"org.pos= tgresql.Driver" url=3D"jdbc:postgresql://IP:PORT/DB_NAME"
 =3B = =3B =3B =3B =3B =3B =3B username=3D"" password=3D""
=  =3B =3B =3B =3B =3B =3B =3B maxActive=3D"100" = maxIdle=3D"30" maxWait=3D"30000"
 =3B =3B =3B =3B = =3B =3B =3B validationQuery=3D"select 1" testOnBorrow=3D"true"
&= nbsp=3B =3B =3B =3B =3B =3B =3B removeAbandoned=3D"= true" removeAbandonedTimeout=3D"120" logAbandoned=3D"true" />=3B

<= br>There is nothing reflecting in the result of the pg_stat_activity.
<= br>There is no relevant logs found in pg_logs too.

Thread is not onl= y stuck at the time of get connection. Some times at the time of query exec= ution.


java.net.SocketInputStream.socketRead0(Native Method) =3Bjava.net.SocketInputStream.read(SocketInputStream.java:129)
&nb= sp=3Borg.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBuffere= dInputStream.java:145)
 =3Borg.postgresql.core.VisibleBufferedInputS= tream.ensureBytes(VisibleBufferedInputStream.java:114)
 =3Borg.postg= resql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:= 73)
 =3Borg.postgresql.core.PGStream.ReceiveChar(PGStream.java:274)<= br> =3Borg.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExe= cutorImpl.java:1660)
 =3Borg.postgresql.core.v3.QueryExecutorImpl.ex= ecute(QueryExecutorImpl.java:257)
 =3Borg.postgresql.jdbc2.AbstractJ= dbc2Statement.execute(AbstractJdbc2Statement.java:500)
 =3Borg.postg= resql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.= java:388)
 =3Borg.postgresql.jdbc2.AbstractJdbc2Statement.executeQue= ry(AbstractJdbc2Statement.java:273)
 =3Bcom.eos.accounts.data.OrderA= uthorization.loadOrderAuthorization(OrderAuthorization.java:102)
 = =3Bcom.eos.tally.reports.data.TallyOrder.getOrdersForTallyReport(TallyOrder= .java:88)
 =3Bcom.eos.tally.reports.SaleReport.setData(SaleReport.ja= va:71)
 =3Bcom.eos.tally.reports.AgentSaleReport.generateMap(AgentSa= leReport.java:25)
 =3Bcom.eos.tally.reports.AbstractTallyReport.gene= rateTallyReport(AbstractTallyReport.java:171)
 =3Bcom.eos.tally.repo= rts.TallyReport.generateReport(TallyReport.java:112)
 =3Bcom.eos.b2c= .beans.callcenter.AccountingBean.downloadTallyAgentSalesReport(AccountingBe= an.java:602)
 =3Bcom.eos.b2c.ui.B2cCallcenterNavigation.doGet(B2cCal= lcenterNavigation.java:1117)
 =3Bjavax.servlet.http.HttpServlet.serv= ice(HttpServlet.java:690)
 =3Bjavax.servlet.http.HttpServlet.service= (HttpServlet.java:803)
 =3Borg.apache.catalina.core.ApplicationFilte= rChain.internalDoFilter(ApplicationFilterChain.java:290) =3B

TCP_KEEP_ALIVE is 2 hours at the server level. =3B




>=3B Date: Tue=2C 28 Oct 2014 07:28:16 -0700
>=3B From: <= a href=3D"mailto:kgrittn@ymail.com" target=3D"_blank">kgrittn@ymail.com=
>=3B Subject: Re: [JDBC] Hung thread
>=3B To: pg@fastcrypt.com=3B dhavallj@hotmail.com
>= =3B CC: pgsq= l-jdbc@postgresql.org

>=3B
>=3B Dave = Cramer <=3Bpg@fastc= rypt.com>=3B wrote:
>=3B >=3B On 28 October 2014 07:34=2C dhav= al jaiswal <=3B= dhavallj@hotmail.com>=3B wrote:
>=3B
>=3B >=3B>=3B jav= a.lang.Thread.State: RUNNABLE
>=3B >=3B>=3B at java.net.Soc= ketInputStream.socketRead0(Native Method)
>=3B >=3B>=3B at = java.net.SocketInputStream.read(SocketInputStream.java:129)
>=3B >= =3B>=3B at org.postgresql.core.VisibleBufferedInputStream.readMore= (VisibleBufferedInputStream.java:145)
>=3B >=3B>=3B at org.= postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInput= Stream.java:114)
>=3B >=3B>=3B at org.postgresql.core.Visib= leBufferedInputStream.read(VisibleBufferedInputStream.java:73)
>=3B &g= t=3B>=3B at org.postgresql.core.PGStream.ReceiveChar(PGStream.java= :274)
>=3B >=3B>=3B at org.postgresql.core.v3.QueryExecutor= Impl.processResults(QueryExecutorImpl.java:1660)
>=3B >=3B>=3B = at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.j= ava:257)
>=3B >=3B>=3B - locked <=3B0x00002aaaf6282d00>= =3B (a org.postgresql.core.v3.QueryExecutorImpl)
>=3B >=3B>=3B = at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Sta= tement.java:500)
>=3B >=3B>=3B at org.postgresql.jdbc2.Abst= ractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
>= =3B >=3B>=3B at org.postgresql.jdbc2.AbstractJdbc2Statement.exec= uteQuery(AbstractJdbc2Statement.java:254)
>=3B >=3B>=3B at = org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery(DelegatingStat= ement.java:208)
>=3B >=3B>=3B at org.apache.tomcat.dbcp.dbc= p.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:84)
>=3B &= gt=3B>=3B at org.apache.tomcat.dbcp.dbcp.PoolingDataSource.getConn= ection(PoolingDataSource.java:96)
>=3B >=3B>=3B at org.apac= he.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)=
>=3B >=3B>=3B at com.eos.hotels.viahotel.manager.ViaHotelD= atabaseManager.getConnection(ViaHotelDatabaseManager.java:74)
>=3B [ s= nip ]
>=3B
>=3B >=3B Given the little bit of information avail= able my guess would be
>=3B >=3B that since this is using dbcp=2C an= d the connections are never really
>=3B >=3B closed.
>=3B
&= gt=3B The stack trace shows that the getConnection() method of dbcp is
&= gt=3B trying to re-use a connection in the pool=2C and is first testing the=
>=3B connection by invoking our JDBC driver's executeQuery() method.<= br>>=3B
>=3B >=3B I believe once a connection is made we are alwa= ys listening
>=3B >=3B on the socket.
>=3B
>=3B I don't f= ollow that=3B it is listening for the response to a query.
>=3B What t= hread would be "always listening"=2C anyway? The driver is not
>=3B m= ulti-threaded.
>=3B
>=3B >=3B However I will say I haven't rea= lly spent much time on this. Either
>=3B >=3B way we would need much= more information in order to be able to help
>=3B >=3B you.
>= =3B
>=3B It would be interesting to know what query dbcp is using to = test
>=3B whether the connection is still alive. Also=2C if the clien= t port
>=3B can be discovered=2C looking for it in the pg_stat_activit= y view
>=3B would be interesting.
>=3B
>=3B I can think of = one halfway plausible explanation=2C though. A
>=3B firewall between = the machine running dbcp and the database server
>=3B might be blockin= g traffic after some idle timeout=2C possibly
>=3B resulting in a hang= like this when the pooler eventually tries to
>=3B use the connection= again. You might want to try configuring TCP
>=3B timeouts on both t= he client and the server. It wouldn't hurt to
>=3B closely review the= network path between the machines.
>=3B
>=3B Logging connection= s and disconnections and closely reviewing the
>=3B server logs could = provide insights.
>=3B
>=3B --
>=3B Kevin Grittner
>= =3B EDB: http://w= ww.enterprisedb.com
>=3B The Enterprise PostgreSQL Company
=0A=

= --_0c0cedea-e62f-4bf4-9c67-549b6b5df523_--