Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TgiUM-0002BS-Ms for pgsql-jdbc@arkaria.postgresql.org; Thu, 06 Dec 2012 20:56:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TgiUL-0002wm-L2 for pgsql-jdbc@arkaria.postgresql.org; Thu, 06 Dec 2012 20:56:09 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TgiUK-0002wh-Pg for pgsql-jdbc@postgresql.org; Thu, 06 Dec 2012 20:56:09 +0000 Received: from nm10-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.147]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TgiUI-0004uX-Sf for pgsql-jdbc@postgresql.org; Thu, 06 Dec 2012 20:56:08 +0000 Received: from [98.139.212.153] by nm10.bullet.mail.bf1.yahoo.com with NNFMP; 06 Dec 2012 20:56:05 -0000 Received: from [76.13.13.44] by tm10.bullet.mail.bf1.yahoo.com with NNFMP; 06 Dec 2012 20:56:05 -0000 Received: from [127.0.0.1] by smtp105.prem.mail.ac4.yahoo.com with NNFMP; 06 Dec 2012 20:56:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1354827365; bh=2d3Y7TXEufZP96WweYPmqQaxChC3useX34vpoezj/dc=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Thread-Index:Content-Language; b=znqhf9ljQ4HIeA+87CHt3nxNyE9CPMD4md+NNb4rg/AsZdJ16jL3fn9izg58q4UfpKLVhvwO2llMTtACZoi1HAgiw4+kboig89xrQY/uzg+l2yLXlxXBhAJDdPEdPAW7q3kaaw1gJrdnuu+tv7dh1GE9tfmHGa4PBisF60QgkBg= X-Yahoo-Newman-Id: 790655.84102.bm@smtp105.prem.mail.ac4.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: y3g5N3QVM1kQrVKlwsAOtgAEBY9pI_GkOIDxUbIWwXx7Wrd JkZ_lJ2Yq6U3PyOGIxtUzkM8yfx8Z1SUP3nAlsJB_KiLjuImlW1QCC4.RvEk kjzpEaWOTYuDC9Y_GfK4iyCSaXzjgGCTLlmmyBmlw3WuxIqoGrPk4PYdsbWo 5asWJwYgqHHg.6ZDAmPIvl7Z7I3tR2WFPNJrPfSFs96NYsA_RvyslO8rsDN7 zvOi3UauO98QIhySWawKl78H07PkqgbrWDT0mtMls78IDhb9cqs714vTPzg_ qv3g0Y4r5ALfz4E9WbjObnehOwiyywxOHXZN1HLIEFCzlncDpXTTHCKMtLYu tBhRyMhFFNijEe_5z6t7lG8E1eCBWZTWZEebvb86LTz0ivdsCgQb_3yMWDrw CHxhF3o1NOB7yrFwk6056ZMbTv7Cx0JlSf7zLF.L3qXWdC0tLvsjzOLgnxxL Sgg0lbttF0Wq6g0mlrncv5yjqF2MOoomWbRzHKtNB0TOs05kSQM9QGRA0XhN nmrA- X-Yahoo-SMTP: mpGJl6eswBD2IBufoVEg0Pa8gg-- Received: from WolfDog (polobo@24.93.28.86 with login) by smtp105.prem.mail.ac4.yahoo.com with SMTP; 06 Dec 2012 12:56:05 -0800 PST From: "David Johnston" To: =?iso-8859-2?Q?'Pavel_Arno=B9t'?= , References: <5097e057-c9b9-42f0-bed0-219eab05bb7d@googlegroups.com> <50C0E09A.4070408@ttc-cmc.net> <014101cdd3e0$a9a302a0$fce907e0$@yahoo.com> In-Reply-To: Subject: Re: Statement.setQueryTimeout() with autoCommit=false Date: Thu, 6 Dec 2012 15:55:53 -0500 Message-ID: <016a01cdd3f4$15296dd0$3f7c4970$@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQF71Xk46Ti56BxJT15wxGI4l97bCgL5hfPWAUAjiNcC3ghMCQGY25evArwOgkeYVNY1kA== Content-Language: en-us X-Pg-Spam-Score: -1.9 (-) 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 The statement timeout that you provided is attached to the INSERT statement - which executed just fine even though it wasn't comitted. The exception you are seeing in the "autoCommit(false)" scenario occurs at "conn.commit()" which implicitly executes "COMMIT;" on the backend and fails due to the replication situation. In "autocommit" mode the commit is executed as part of the same statement as the INSERT (it is a compound statement I guess) and as such the timeout is still in effect at that time. David J. > -----Original Message----- > From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc- > owner@postgresql.org] On Behalf Of Pavel Arno=B9t > Sent: Thursday, December 06, 2012 3:26 PM > To: pgsql-jdbc@postgresql.org > Subject: Re: [JDBC] Statement.setQueryTimeout() with autoCommit=3Dfalse >=20 > That insert was against PostgreSQL server with synchronous replication and > dead slave. >=20 > On Thursday, December 6, 2012 9:18:48 PM UTC+1, Dave Cramer wrote: > > Well my point was that that insert statement shouldn't last long enough to > time out ? > > > > > > Dave > > > > Dave Cramer > > > > dave.cramer(at)credativ(dot)ca > > http://www.credativ.ca > > > > > > > > > > > > > > > > On Thu, Dec 6, 2012 at 1:36 PM, David Johnston > wrote: > > > > > > > > > -----Original Message----- > > > > > From: pgsql-jd...@postgresql.org [mailto:pgsql-jdbc- > > > > > ow...@postgresql.org] On Behalf Of dmp > > > > > Sent: Thursday, December 06, 2012 1:15 PM > > > > > To: pgsql...@postgresql.org > > > > > Cc: pavel....@loutka.cz > > > > > Subject: Re: [JDBC] Statement.setQueryTimeout() with > > > autoCommit=3Dfalse > > > > > > > > > > Exactly. > > > > > > > > > > According to the Java API: > > > > > > > > > > void setAutoCommit(boolean autoCommit) throws SQLException > > > > > > > > > > =A0 =A0 =A0Sets this connection's auto-commit mode to the given state= . If > > > a > > > > > connection is in auto-commit mode, then all its SQL statements will > > > be > > > > > executed and committed as individual transactions. Otherwise, its > > > SQL > > > > > statements are grouped into transactions that are terminated by a > > > call to > > > > > either the method commit or the method rollback. By default, new > > > > > connections are in auto-commit mode. > > > > > > > > > > By setting setAutoCommit(false) you are deciding to tell the > > > database your > > > > > code will determine when to commit the transaction. Thereby I would > > > say > > > > > overiding setQueryTimeout(). > > > > > > > > > > danap. > > > > > > > > Even within an manually administered transaction the setting of > > > > "setQueryTimeout()" will (should?) act on the individual statements > > that > > > > make up the transaction. =A0If any individual statement within the > > transaction > > > > exceeds the limit that statement will fail and thus put the > > transaction into > > > > a "failed" state where a rollback (possibly to savepoint) is required. > > The > > > > transaction itself does not constitute a statement and as such it can > > run > > > > indefinitely long regardless of the presence of a statement timeout. > > > > > > > > David J. > > > > > > > > > > > > > > > > > > Dave Cramer wrote: > > > > > > Why would the query timeout at all ? > > > > > > > > > > > > The query timeout is for long running queries. If the query takes > > > > > > longer than n seconds it will timeout. > > > > > > > > > > > > Dave > > > > > > > > > > > > Dave Cramer > > > > > > > > > > > > dave.cramer(at)credativ(dot)ca > > > > > > http://www.credativ.ca > > > > > > > > > > > > > > > > > > > > > > > > On Thu, Dec 6, 2012 at 12:04 PM, > > > > > > wrote: > > > > > > > > > > > > =A0 =A0 Hi, > > > > > > > > > > > > =A0 =A0 does setQueryTimeout work with autoCommit=3Dfalse? When > > > > autoCommit > > > > > is > > > > > > =A0 =A0 true, this code timeouts after 5 seconds (as expected): > > > > > > > > > > > > ~ > > > > > =A0> ~ > > > > > =A0> ~ > > > > > > =A0 =A0 -- > > > > > > > > > > > > =A0 =A0 But if I set autoCommit to false, this code timeouts after = 30 > > > > > > =A0 =A0 seconds on read timeout: > > > > > > > > > > > > =A0 =A0 -- > > > > > > ~ > > > > > =A0> ~ > > > > > =A0> ~ > > > > > > =A0 =A0 -- > > > > > > > > > > > > =A0 =A0 I'm confused what's setQueryTimeout() method for, why it > > > > doesn't > > > > > > =A0 =A0 work with manual transactions? > > > > > > > > > > > > > > > -- > > > > > Sent via pgsql-jdbc mailing list (pgsql...@postgresql.org) To make > > > > changes > > > > > to your subscription: > > > > > http://www.postgresql.org/mailpref/pgsql-jdbc > > > > > > > > > > > > > > > > -- > > > > Sent via pgsql-jdbc mailing list (pgsql...@postgresql.org) > > > > To make changes to your subscription: > > > > http://www.postgresql.org/mailpref/pgsql-jdbc >=20 >=20 >=20 > -- > Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes > to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc