Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bel7P-0004Hw-OL for pgsql-jdbc@arkaria.postgresql.org; Tue, 30 Aug 2016 15:38:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bel7P-0002Vl-9v for pgsql-jdbc@arkaria.postgresql.org; Tue, 30 Aug 2016 15:38:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bel0q-00021V-FJ for pgsql-jdbc@postgresql.org; Tue, 30 Aug 2016 15:31:44 +0000 Received: from mbx-mailscanner-1.wit-software.com ([193.126.243.249]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bel0l-0006YI-Uo for pgsql-jdbc@postgresql.org; Tue, 30 Aug 2016 15:31:42 +0000 X-Spam-Status: No X-witsoftware-MailScanner-EFA-Watermark: 1473175891.21857@bR5lWoapIgEMTVsZCi5DgA X-witsoftware-MailScanner-EFA-From: alexandre.brito@wit-software.com X-witsoftware-MailScanner-EFA: Found to be clean X-witsoftware-MailScanner-EFA-ID: 50D7310005E.A7FAA X-witsoftware-MailScanner-EFA-Information: Please contact itteam@wit-software.com for more information Received: from AlexHP (54.139.54.77.rev.vodafone.pt [77.54.139.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mbx-mailscanner-1.wit-software.com (Postfix) with ESMTPSA id 50D7310005E; Tue, 30 Aug 2016 16:31:29 +0100 (WEST) From: "Alexandre Brito" To: "'Jingzhi Zhang'" Cc: References: <006c01d1fec2$e6152130$b23f6390$@wit-software.com> In-Reply-To: Subject: Re: SocketTimeout and ConnectionTimeout Date: Tue, 30 Aug 2016 16:31:28 +0100 Message-ID: <027f01d202d3$93dfabf0$bb9f03d0$@wit-software.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0280_01D202DB.F5AD14A0" X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQIsBlnWSsS7AudERAVuCDbwIq8FrQHyf05xn54FoQA= Content-Language: en-gb X-Pg-Spam-Score: -3.4 (---) 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 This is a multipart message in MIME format. ------=_NextPart_000_0280_01D202DB.F5AD14A0 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit Hello, Hm, ok. Do you know how to control the retries behaviour from the EL? Please bear in mind that we are using the latest JDBC driver available at postgresql.org (which includes EL). Regards, Alex From: Jingzhi Zhang [mailto:jingzhi.zhang@outlook.com] Sent: 30 August 2016 16:23 To: Alexandre Brito Cc: pgsql-jdbc@postgresql.org Subject: Re: [JDBC] SocketTimeout and ConnectionTimeout In the log, there are only one [EL Warning], all other retries logging are [EL Info]. So it is EL controls the retries behavior(just as connection pool), not JDBC. 在 2016年8月25日,19:22,Alexandre Brito > 写道: Hi, We are facing a problem with the JBDC connection being drop silently and the driver is not throwing a SQL Exception in a timely manner. Going through the mailing-list and the internet, it seems the problem is not so rare however the solution is still out of my reach. What is happening is simple: 1. JDBC connection is open and then stays idle 2. A network component (Fortinet) beyond our control seems to be dropping idle TCP connections. 3. Our webapp places a query and it takes 1min and 12 seconds (more or less) for the SQL Exception to be caught. We’ve reproduced the issue behaviour (on our environment ) by setting an iptables rule blocking port 5432 after the DB connection was successfully established. On the logs I can see the socket read (I think) timeout is around 12 seconds and then there are 6 retries 10 secs apart. (see the extracted log file from tomcat attached with EL log to finest) I would like to have control over the number of retries and timeout. Basically, I would like the receive an SQL Connection Timeout Exception within 5-10 seconds. We are using tomcat 8 and latest JDCB driver (9.4.1209 JDBC42) and JPA. Our schema is tiny and the data in it very very small. This is my tomcat’s context.xml (for troubleshooting proposes) . This is my apps’s persistence.xml org.eclipse.persistence.jpa.PersistenceProvider java:comp/env/jdbc/postgresqlconnection com.all.onbbp.database.entities.BpUser com. all.onbbp.database.entities.BusinessPartner com. all.onbbp.database.entities.Enterprise com. all.onbbp.database.entities.Property com. all.onbbp.database.entities.LokiCookie com. all.onbbp.database.entities.Report com. all.onbbp.database.entities.Languages com. all.onbbp.database.entities.EmailTemplates com. all.onbbp.database.entities.BpMutex com. all.onbbp.database.entities.UserSession NONE Btw the, this is how the EntityManager is initialized public class StartupListener implements ServletContextListener { … private static EntityManagerFactory entityManagerFactory; @Override public void contextInitialized(ServletContextEvent sce) { try { try { entityManagerFactory = Persistence.createEntityManagerFactory("bp-persistence"); } catch (Throwable ex) { throw new BPException(BPErrorCode.INTERNAL_SERVER_ERROR_DB_ERROR); } Does anyone has an idea? Why does the connectionTimeout to the database take so long to return (more than 12 seconds)? Many thanks in advance for any reply Alexandre -- Sent via pgsql-jdbc mailing list ( pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc ------=_NextPart_000_0280_01D202DB.F5AD14A0 Content-Type: text/html; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable

Hello,

 

Hm, ok. Do you know how to control the = retries behaviour from the EL?

Please bear in mind that we are using the = latest JDBC driver available at postgresql.org (which includes = EL).

 

Regards,

Alex

 

From:<= /b> Jingzhi = Zhang [mailto:jingzhi.zhang@outlook.com]
Sent: 30 August 2016 = 16:23
To: Alexandre Brito = <alexandre.brito@wit-software.com>
Cc: = pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] SocketTimeout = and ConnectionTimeout

 

In the log, = there are only one [EL Warning], all other retries logging are [EL = Info].

So it is EL controls the = retries behavior(just as connection pool), not = JDBC.

 

 

 

=1B$B:_=1B(J 2016=1B$BG/=1B(J8=1B$B7n=1B(J25=1B$BF|!$=1B(J19:22=1B$B!$=1B(JAlexandre Brito <alexandre.brito@wit-soft= ware.com> =1B$B

 

Hi,

 

We are = facing a problem with the JBDC connection being drop silently and the = driver is not throwing a SQL Exception in a timely manner. 

=1B(JGoing = through the mailing-list and the internet, it seems the problem is not = so rare however the solution is still out of my = reach.

 

What is = happening is simple:

1.       JDBC = connection is open and then stays idle

2.       A network = component (Fortinet)  beyond our control seems to be dropping idle = TCP connections.

3.       Our webapp = places a query and it takes 1min and 12 seconds (more or less) for the = SQL Exception to be caught. 

 

We=1B$B!G=1B(= Jve reproduced the issue behaviour (on our environment ) by setting an = iptables rule blocking port 5432 after the DB connection was = successfully established. On the logs I can see the socket read (I = think) timeout is around 12 seconds and then there are 6 retries 10 secs apart.  (see the = extracted log file from tomcat attached with EL log to finest) 

 

I would like = to have control over the number of retries and timeout. Basically, I = would like the receive an SQL Connection Timeout Exception within 5-10 = seconds. 

 

We are using = tomcat 8 and latest JDCB driver (9.4.1209 JDBC42) and = JPA.

 

Our schema = is tiny and the data in it very very small. 

<=1B(Jspan = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif'> 

This is my = tomcat=1B$B!G=1B(Js context.xml (for troubleshooting proposes) . 

 

<Resource = auth=3D"Container"

   = driverClassName=3D"org.postgresql.Driver"

   = maxTotal=3D"1"

   = maxIdle=3D"1"

   = maxWaitMillis=3D"3000"

   = name=3D"jdbc/postgresqlconnection"

   = type=3D"javax.sql.DataSource"

   = url=3D"jdbc:postgresql://127.0.0.1:5432/onbbp? = connectionTimeout=3D2&amp;socketTimeout=3D2"

   = factory=3D"org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory"=

   = username=3D"user"

   = password=3D"pass"

/> 

 

This is my = apps=1B$B!G=1B(Js persistence.xml

 

<=1B(Jspan = style=3D'font-size:10.0pt;font-family:"Courier New"'><persistence = xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance<= /a>"

           &= nbsp; version=3D"2.0" xmlns=3D"http://java.sun.com/xml/ns/persistence= ">

    <persistence-unit = name=3D"bp-persistence" = transaction-type=3D"RESOURCE_LOCAL">

        = <provider>org.eclipse.persistence.jpa.PersistenceProvider</provi= der>

        = <non-jta-data-source>java:comp/env/jdbc/postgresqlconnection</no= n-jta-data-source>

        = <class>com.all.onbbp.database.entities.BpUser</class><= span = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif'>

        <class>com. = all.onbbp.database.entities.BusinessPartner</class>

        <class>com. = all.onbbp.database.entities.Enterprise</class>

        <class>com. = all.onbbp.database.entities.Property</class>

        <class>com. = all.onbbp.database.entities.LokiCookie</class>

 =1B(J       <class>com. = all.onbbp.database.entities.Report</class>

        <class>com. = all.onbbp.database.entities.Languages</class>

        <class>com. = all.onbbp.database.entities.EmailTemplates</class>

        <class>com. = all.onbbp.database.entities.BpMutex</class>

        <class>com. = all.onbbp.database.entities.UserSession</class>

        = <shared-cache-mode>NONE</shared-cache-mode>

        = <properties>

           &= nbsp;    <property = name=3D"javax.persistence.validation.mode" = value=3D"AUTO" />

           &= nbsp;    <property = name=3D"eclipselink.logging.level" = value=3D"FINEST"/>

        = </properties>

    </persistence-unit>

</persistence>

  &= nbsp;           &n= bsp; 

Btw the, = this is how the EntityManager is = initialized

 

public class = StartupListener implements ServletContextListener {

 

    = =1B$B!D=1B(J

    = private static EntityManagerFactory entityManagerFactory;

 

    = @Override

    = public void contextInitialized(ServletContextEvent sce) {

        try {

            = try {

           &= nbsp;    entityManagerFactory =3D = Persistence.createEntityManagerFactory("bp-persistence");

          =   } catch (Throwable ex) {

           &= nbsp;    throw new = BPException(BPErrorCode.INTERNAL_SERVER_ERROR_DB_ERROR);

            = }

 

Does anyone = has an idea? Why does the connectionTimeout to the database take so long = to return (more than 12 seconds)? 

 

Many thanks = in advance for any reply

A= lexandre<=1B(Jspan = style=3D'font-size:11.0pt;font-family:"Calibri",sans-serif'>

 

<connectioTimeout_takes_too_long.txt>
-- 
Sent via pgsql-jdbc = mailing list (
pgsql-jdbc@postgresql.org)
To = make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

=

 

------=_NextPart_000_0280_01D202DB.F5AD14A0--