Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cEakH-00058P-3Z for pgsql-jdbc@arkaria.postgresql.org; Wed, 07 Dec 2016 11:50:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cEakG-0003ov-Mg for pgsql-jdbc@arkaria.postgresql.org; Wed, 07 Dec 2016 11:50:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cESAP-0006YI-FN for pgsql-jdbc@postgresql.org; Wed, 07 Dec 2016 02:41:09 +0000 Received: from relay3.ptmail.sapo.pt ([212.55.154.23] helo=sapo.pt) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cESAI-0002xU-0Z for pgsql-jdbc@postgresql.org; Wed, 07 Dec 2016 02:41:08 +0000 Received: (qmail 22167 invoked from network); 7 Dec 2016 02:40:59 -0000 Received: (qmail 6779 invoked from network); 7 Dec 2016 02:40:59 -0000 Received: from unknown (HELO Macintosh.local.mail) (rjsdg@sapo.pt@[83.223.240.223]) (envelope-sender ) by ptmail-mta-auth02 (qmail-ptmail-1.0.0) with ESMTPA for ; 7 Dec 2016 02:40:59 -0000 X-PTMail-RemoteIP: 83.223.240.223 X-PTMail-AllowedSender-Action: X-PTMail-Service: default Date: Wed, 7 Dec 2016 02:40:58 +0000 From: Rodrigo Garcia To: pgsql-jdbc@postgresql.org Message-ID: Subject: Unexpected transaction behaviour X-Mailer: Airmail (382) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="584776ba_1ff75690_34b1" X-Pg-Spam-Score: -2.6 (--) 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 --584776ba_1ff75690_34b1 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, I have a OLTP system supported by a Java standalone app using JDBC 42 Dri= ver postgresql-jdbc-9.4-1212 and a backend DB running in =22PostgreSQL 9.= 6.1, compiled by Visual C++ build 1800, 64-bit=E2=80=9D. The Os is Window= s 7 64 bit. The system normal throughput is about 110 transactions/min constantly wit= hout degradation. Recently a new Java module of the application was insta= lled and when the app startups the system throughput starts to degrade to= the point that reaches 50 transactions/min, it=E2=80=99s not an immediat= e downfall in the throughput but it looses like 5 to 10 transactions per = minute until it reaches 50 transactions per minute. At this point if we t= erminate the only existing backend pid of the new Java module (that is in= =E2=80=9Cidle in transaction=E2=80=9D with a backend=5Fxmin value) immed= iatly in the next minute the throughput rises again to 110 transactions/m= in. We=E2=80=99re not being able to identify the root cause for this behaviou= r, but we found out that this occurs only when we use JDBC Driver via Jav= a and is reproducible whenever we use JDBC driver with a small piece of J= ava code (simulating the new Java module). At POINT 4 below we stay with = a =E2=80=9Cidle in transaction=E2=80=9D session and a backend=5Fxmin valu= e corresponding to the snapshot of the moment when the =E2=80=9Cselect * = from x=E2=80=9D query was fired. =C2=A0This doesn=E2=80=99t happen when w= e connect via psql and reproduce the similar actions the issue is not occ= uring, this is, with psql we stay at POINT 4 with a =E2=80=9Cidle in tran= saction=E2=80=9D session but without a backend=5Fxmin value. Reading PG documentation this behaviour around backend=5Fxmin depends on = the transaction isolation level, the snapshot collection is diferent. We = suspect that the loss of throughput resides in the fact that the =E2=80=9C= idle in transaction=E2=80=9D with a backend=5Fxmin avoids or causes delay= s in the MVCC versioning core system of Postgres. Nevertheless we don=E2=80= =99t understang why it happens only when using JDBC. The new Java module does the following code: Class.forName(=22org.postgresql.Driver=22); String url =3D =22jdbc:postgresql://127.0.0.1:5433/postgres=22; Properties props =3D new Properties(); props.setProperty(=22user=E2=80=9D,=22postgres=22); props.setProperty(=22password=E2=80=9D,=E2=80=9D**********=22); Connection conn =3D DriverManager.getConnection(url,props); conn.setAutoCommit(true); PreparedStatement st =3D conn.prepareStatement(=22BEGIN=22); st.execute(); st =3D conn.prepareStatement(=22select * from x=22); st.execute(); //POINT 4 =C2=A0=3D> At this point pg=5Fstat=5Factivity shows =22idle in = transaction=E2=80=9D and a backend=5Fxmin value filled Thread.sleep(300000); conn.close(); The same actions via PSQL (after connect) are: =C2=A0BEGIN; =C2=A0select * from x; =3D> At this point pg=5Fstat=5Factivity shows =22idle in transaction=E2=80= =9D and backend=5Fxmin is null Why the differente behaviour=3F We understand that PSQL and JDBC use diff= erent protocols but in terms of transaction behaviour should be the same,= the Java code and PSQL are equivalent in terms of transaction behaviour.= Can someone help=3F Thank you --584776ba_1ff75690_34b1 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline