Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBpL7-0007LN-Nj for pgsql-general@arkaria.postgresql.org; Mon, 06 Nov 2017 21:53:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eBpL6-0006b9-Dk for pgsql-general@arkaria.postgresql.org; Mon, 06 Nov 2017 21:53:52 +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 1eBpL5-0006av-OX for pgsql-general@postgresql.org; Mon, 06 Nov 2017 21:53:51 +0000 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1eBpKy-0000K9-4t for pgsql-general@postgresql.org; Mon, 06 Nov 2017 21:53:51 +0000 Received: by mail-pf0-x22d.google.com with SMTP id p87so8736280pfj.3 for ; Mon, 06 Nov 2017 13:53:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to; bh=lGQ9shWh+IEj8i1kFkFlcZQKpAl85ZcK2jD7EpEDZBk=; b=DJYdTcZHTY8KM2cyzA4On9HA+8+AOvlkVBoz0mm3HYiwaluIpbaLy9Jw+bA4z5L8AI KgHTwbXHzqOoLVp8jV1yEUvdHgqNrfqL4SgPOKUs7yg1IKB5YYeTL8BIvpcXjzXpfFl7 q9Db70yhYICJqN2d+6XQgQD/pEvBnhZUlr4vM9QI4TpRTsQjbr9FYguhEgESZ4Dz7dVP JhKEN36HD6pT/wX50QnUxA8VZwrEBNnx918VIhJ7uWVXBT9k/MHtjmpXPK3pBKU0F/W+ +wqSECB+E5jNI921X7mWMtLOFa7QAVgmLwVsXzUTjDTn2MeaO1fuNOwvwKgpHv25zTne ldqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=lGQ9shWh+IEj8i1kFkFlcZQKpAl85ZcK2jD7EpEDZBk=; b=UGPrGz1fbFoTL+bS71pE1XYpDBwJQmb/YAuDzofWNG9y1f2TyKpXdSQM/xw/A/WJU6 hfXA1FwQ17ZIY4Bdh/aMhkf8IHx4NY77bqxXTT+5zWHyiOSOTV+YTUymxJiOmPBWcgf9 gUOmGjYNaOcemU+G1QFYeGBXv10PKRfWer9LGAk049i561m79h4IpodHkQ73W1ITWE75 wJEGB7ze0YquXgIv4en/T8BWwP7q+9ZJ9nm8saCUwyAsd7qm5+zchQu2h50ytb8cKqCH JNmpsQKMnRP7Ub3ieBKYaOGWZ3DGosCIxxiMv/JxB/beL+da3x+Z77ErzHXscOxvszSt X9lg== X-Gm-Message-State: AMCzsaVWQLOKoxJljO6I6BvraJHIIYYpr40rfOUKBQCIps8fyctD5+ah DURjharSYjiB0WWKbmjPZWG+Au7o X-Google-Smtp-Source: ABhQp+TsVh8ixQ0mc6J0bdh3ePn5fSSSLmuPcziHcYyJSMdaslsvcUGqnLgPy3EPkxxou3Mg/hS/1A== X-Received: by 10.84.245.150 with SMTP id j22mr16203617pll.324.1510005221402; Mon, 06 Nov 2017 13:53:41 -0800 (PST) Received: from [10.104.134.14] ([155.100.47.6]) by smtp.gmail.com with ESMTPSA id s88sm28430416pfe.36.2017.11.06.13.53.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 13:53:40 -0800 (PST) Subject: Re: idle in transaction, why To: Merlin Moncure References: <4a365db4-8608-65c8-e3dc-23524f881bc3@gmail.com> <16893.1509999467@sss.pgh.pa.us> <6ed9ca9b-fb80-e505-2522-be9b5f63a759@gmail.com> <19493.1510000892@sss.pgh.pa.us> <81aa980b-fb4c-e9b4-fa82-9f14df71a2df@gmail.com> Cc: Tom Lane , "David G. Johnston" , "pgsql-general@postgresql.org" From: Rob Sargent Message-ID: Date: Mon, 6 Nov 2017 14:53:53 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------6C9C58B5EE055D1DF4F5FB25" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org This is a multi-part message in MIME format. --------------6C9C58B5EE055D1DF4F5FB25 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 11/06/2017 02:38 PM, Merlin Moncure wrote: > On Mon, Nov 6, 2017 at 2:50 PM, Rob Sargent wrote: >> >> On 11/06/2017 01:41 PM, Tom Lane wrote: >>> Rob Sargent writes: >>>> idle_in_transaction_session_timeout | 0 | default | >>>> | | A value of 0 turns off the timeout. | user >>> Meh. I think we're barking up the wrong tree anyway: so far as I can >>> find, there is no error message reading 'idle transaction timeout' >>> in the existing PG sources (and I sure hope no committer would have >>> thought that such an ambiguous message text was satisfactory). >>> So I think your error is coming from client-side or third-party code. >>> What other moving parts have you got in there? >>> >>> regards, tom lane >> The most likely culprit is JOOQ, which I chose as a learning experience >> (normally I use ORM tools). But that said, I just ran the same data into my >> test env, (postgres 10.0 (real) on centos 6.9, ubuntu client) and all went >> swimmingly. It's a sizable payload (several batches of over 100K items, >> deserialized from json) and takes 5 minutes to save. >> >> I was hoping to blame the virt or the beta. Not a good time to start doubt >> JOOQ > I can't speak to JOOQ (who are fantastic postgres supporters BTW), but > in the java world this typically comes from one of two things: > > 1) you have long running in-transaction process that has very heavy > computation between sql statements. this is a rare case > --or-- > 2) you are connecting pooling and the app sent a connection back into > the pool without having a transaction committed. > > "2" is a common and dangerous bug. It can happen due to bug in > application code (most likely), the jdbc wrapping library code (less > likely), or the connection pooler itself if you're using one. A > typical cause of application side problems is manual transaction > management and some uncaught exception paths where errors (say, a > duplicate key error). So investigate causes like that first > (database errors in the database log might be a helpful clue) and go > from there. If the problem is within JOOQ, you ought to take it up > with them, which I encourage you to do, since I consider JOOQ to be a > wonderful treatment of SQL integration from the java perspective. > > merlin "2" definitely fits this bill. The difference between test and prod is pgboucer which I've forgotten to mention at all in this thread. I do start a tx in my code a la: public void writedb(DSLContext ctx) { logger.error("{}: start transaction at {}", getRunTag(), System.currentTimeMillis()); ctx.transaction(ltx -> { startProcess(ctx); writeSegments(ctx); finishProcess(ctx); }); logger.error("{}: end transaction at {}", getRunTag(), System.currentTimeMillis()); } But I don't think this is out of the ordinary. However writing lists with up to 1,175,151 records might not be (2 this size, to at 131K). I'll take this up with JOOQ and pgbouncer. (fasterxml is having trouble with this size too. Not sure how I can break this up if need be done, they're all generate from the same analysis run.) Thanks to all. --------------6C9C58B5EE055D1DF4F5FB25 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit



On 11/06/2017 02:38 PM, Merlin Moncure wrote:
On Mon, Nov 6, 2017 at 2:50 PM, Rob Sargent <robjsargent@gmail.com> wrote:

On 11/06/2017 01:41 PM, Tom Lane wrote:
Rob Sargent <robjsargent@gmail.com> writes:
   idle_in_transaction_session_timeout | 0       | default |
|            | A value of 0 turns off the timeout. | user
Meh.  I think we're barking up the wrong tree anyway: so far as I can
find, there is no error message reading 'idle transaction timeout'
in the existing PG sources (and I sure hope no committer would have
thought that such an ambiguous message text was satisfactory).
So I think your error is coming from client-side or third-party code.
What other moving parts have you got in there?

                        regards, tom lane
The most likely culprit is JOOQ, which I chose as a learning experience
(normally I use ORM tools).  But that said, I just ran the same data into my
test env, (postgres 10.0 (real) on centos 6.9, ubuntu client) and all went
swimmingly.  It's a sizable payload (several batches of over 100K items,
deserialized from json) and takes 5 minutes to save.

I was hoping to blame the virt or the beta.  Not a good time to start doubt
JOOQ
I can't speak to JOOQ (who are fantastic postgres supporters BTW), but
in the java world this typically comes from one of two things:

1) you have long running in-transaction process that has very heavy
computation between sql statements.  this is a rare case
--or--
2) you are connecting pooling and the app sent a connection back into
the pool without having a transaction committed.

"2" is a common and dangerous bug.  It can happen due to bug in
application code (most likely), the jdbc wrapping library code (less
likely), or the connection pooler itself if you're using one.  A
typical cause of application side problems is manual transaction
management and some uncaught exception paths where errors (say, a
duplicate key error).  So investigate causes like that first
(database errors in the database log might be a helpful clue) and go
from there.   If the problem is within JOOQ, you ought to take it up
with them, which I encourage you to do, since I consider JOOQ to be a
wonderful treatment of SQL integration from the java perspective.

merlin

"2" definitely fits this bill.  The difference between test and prod is pgboucer which I've forgotten to mention at all in this thread.  I do start a tx in my code a la:
    public void writedb(DSLContext ctx) {
        logger.error("{}: start transaction at {}", getRunTag(), System.currentTimeMillis());
        ctx.transaction(ltx -> {
                startProcess(ctx);
                writeSegments(ctx);
                finishProcess(ctx);
            });
        logger.error("{}: end transaction at {}", getRunTag(), System.currentTimeMillis());
    }
But I don't think this is out of the ordinary. However writing lists with up to 1,175,151 records might not be (2 this size, to at 131K). I'll take this up with JOOQ and pgbouncer.  (fasterxml is having trouble with this size too.  Not sure how I can break this up if need be done, they're all generate from the same analysis run.)

Thanks to all.




--------------6C9C58B5EE055D1DF4F5FB25--