Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jRkT3-0001Kg-4a for pgsql-general@arkaria.postgresql.org; Thu, 23 Apr 2020 22:37:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jRkT2-0006ZQ-0l for pgsql-general@arkaria.postgresql.org; Thu, 23 Apr 2020 22:37:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jRkT1-0006ZA-MU for pgsql-general@lists.postgresql.org; Thu, 23 Apr 2020 22:37:11 +0000 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jRkSy-0000Fz-NA for pgsql-general@postgresql.org; Thu, 23 Apr 2020 22:37:11 +0000 Received: by mail-qk1-x730.google.com with SMTP id l78so8302980qke.7 for ; Thu, 23 Apr 2020 15:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=opensourcestrategies.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=hknxZiHQoAQKzTayfMT3O7uoXWj1h4vS5TRqCn4K1rc=; b=lwrdY09KXVjfDyQNgTkmAaT4oRYorRUyCtM8k29qNMuucWU3hio4WQIMHF+OlWKBh+ nkZXXE9nSHOU+V1H9pWWVRR3kAQVoP2/APec8Tj9A8/93Mryj1wW0uVawy8gm/criiMI 6KPaAB4vBfu18MkY4tNm7wv/snLgvXdVkhtmM1dERtRCpa115Cs3oXw0qwVX5hlsf115 ps2MAdWPYIQ/MRd0W5h3nbR+vperl0uRDBEsoDWZdTxK4ZjJK/y2bAB6Z6qGSUiEyn1N 8Z072lCdVCkuJuQLMoimLDJbpB6pbRPwdzkQntpd/NDzORlQceckYfLVy39nhuII6rUI lH2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=hknxZiHQoAQKzTayfMT3O7uoXWj1h4vS5TRqCn4K1rc=; b=iKwFPqfeMR0yyoysUmpve+kF6Oq2Fe0gZachzUiLV+zdcIQ8lMIQVMbrn8fZ8ZpiKP YBWjwt95VSEuOiqPAGa+wvjD/pXuxbXMa4cPM4WIR7prfwKieMICu62cUbzmNlwOA7CB wyLee1KK6WouAutBbACWuu/Ig+FcEtxNPL95Z8BlWcGITf7jCCPDa0uUdl2zl1U8nvBi VpbzfaO2GpR+WsxSvwKZAXpw566GzvK2LQPEUdz81LDiHEgKfC6VhlTMh0O40D4YI8LH 9ZGSslC8pgMWpmSXYKoviwQEaig38m1kQwUXDQ7d7KzohUb1tnh0OMHfR/cZux/IqkhJ Rcig== X-Gm-Message-State: AGi0PuZxV1U+TWc3bzjQLhbbsoXCbQmczgMTvqjEO+24ZUcg48NRwuM+ N8XZ7O3ruQigBV4vl7321Q2vt2WGehKk40gpBrrjjg== X-Google-Smtp-Source: APiQypKX39Apdjag0MkclPY/AQDmHNm+v14tjgUWPNAfAy1cd7lGbS5GJHAM6eGgUmOjmg9gb4LzDwxLgvOnPxKruTM= X-Received: by 2002:a37:94c3:: with SMTP id w186mr3939943qkd.419.1587681426776; Thu, 23 Apr 2020 15:37:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Si Chen Date: Thu, 23 Apr 2020 15:36:55 -0700 Message-ID: Subject: Re: Ned to understand why all the idle connections To: "David G. Johnston" , pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary="00000000000075b79f05a3fce3e0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --00000000000075b79f05a3fce3e0 Content-Type: text/plain; charset="UTF-8" Thanks for answering my questions. Sorry I didn't mean to "top post" I thought that my other email got lost because I had sent it to lists.postgresql.org ----- Si Chen Open Source Strategies, Inc. Our Mission: https://www.youtube.com/watch?v=Uc7lmvnuJHY On Thu, Apr 23, 2020 at 2:31 PM David G. Johnston < david.g.johnston@gmail.com> wrote: > Please don't top-post; and this is a fairly rude hijack posting given that > you already have a thread going, from today no less, where you've basically > asked this very same question. > > On Thu, Apr 23, 2020 at 2:18 PM Si Chen > wrote: > >> Hello David & David, >> >> I have a similar problem -- a lot of idle transactions. I'm using the >> PostgreSQL JDBC driver. The connections look like this: >> >> pid | wait_event | state_change | >> backend_start | xact_start | query_start | >> ?column? | query >> >> >> -------+------------+-------------------------------+-------------------------------+------------+-------------------------------+-----------------+-------- >> >> 32506 | ClientRead | 2020-04-23 09:29:05.6793-07 | 2020-04-23 >> 01:00:19.612478-07 | | 2020-04-23 09:29:05.679275-07 | >> 00:00:00.000025 | COMMIT >> >> 32506 | ClientRead | 2020-04-23 09:30:33.247119-07 | 2020-04-23 >> 01:00:19.612478-07 | | 2020-04-23 >> 09:30:33.247109-07 | 00:00:00.00001 | COMMIT >> >> 32506 | ClientRead | 2020-04-23 09:31:31.506914-07 | 2020-04-23 >> 01:00:19.612478-07 | | 2020-04-23 >> 09:31:31.506905-07 | 00:00:00.000009 | COMMIT >> >> 32506 | ClientRead | 2020-04-23 09:32:32.06656-07 | 2020-04-23 >> 01:00:19.612478-07 | | 2020-04-23 09:32:32.066552-07 | >> 00:00:00.000008 | COMMIT >> >> 32506 | ClientRead | 2020-04-23 09:36:51.579939-07 | 2020-04-23 >> 01:00:19.612478-07 | | 2020-04-23 09:36:51.579931-07 | >> 00:00:00.000008 | COMMIT >> >> It seems like they haven't been doing anything for a long time, but the >> state_change keeps getting updated. >> > > If the state_change timestamp keeps changing then by definition they are > doing something...... > > >> Is it possible that state_change is being updated, maybe by the JDBC >> driver? >> > > Directly, no, that particular field is read-only by the user and so > nothing is going to directly update it. However, as soon as the session > changes state it will change as well. > > The most likely answer is that your setup for JDBC includes a connection > pool that is periodically checking to see if its session is still active. > You should work on trying to prove or disprove that assumption. > > Do you recommend using PgBouncer with JDBC? >> > > I try to avoid making recommendations without knowing the situation in > which something is operating. Given the level of expertise demonstrated > here I would, however, advise against adding another architectural > component to your setup until your understand completely what you are > already working with. If at that point you can define a problem that you > want to solve, and pgBouncer would constitute a solution, then you could > consider adding it. > > David J. > > --00000000000075b79f05a3fce3e0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for answering my questions.

Sorr= y I didn't mean to "top post"=C2=A0 I thought that my other e= mail got lost because I had sent it to lists.postgresql.org

=
-----
Si Chen
Open Source Strategies, Inc.

Our Mission:= =C2=A0https://www.youtube.com/watch?v=3DUc7lmvnuJHY



On Thu, Apr 23, = 2020 at 2:31 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
Please don't top-po= st; and this is a fairly rude hijack posting given that you already have a = thread going, from today no less, where you've basically asked this ver= y same question.

On Thu, Apr 23, 2020 at 2:18 PM Si Chen <sichen@opensourcestrategi= es.com> wrote:
Hello David = & David,

I have a similar problem -- a lot of idle t= ransactions.=C2=A0 I'm using the PostgreSQL JDBC driver.=C2=A0 The conn= ections look like this:

=C2=A0pid=C2=A0=C2=A0| wait_event |=C2=A0=C2=A0 =C2= =A0 =C2=A0 =C2=A0=C2=A0state_change=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0= |=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0backend_start=C2=A0=C2=A0 =C2=A0 = =C2=A0 =C2=A0=C2=A0| xact_start |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0qu= ery_start=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0|=C2=A0 =C2=A0=C2=A0?colum= n?=C2=A0=C2=A0 =C2=A0=C2=A0| query=C2=A0=C2=A0

-------+------------+----------------------------= ---+-------------------------------+------------+--------------------------= -----+-----------------+--------

=C2=A032506 | ClientRead | 2020-04-23 09:29:05.6793-07=C2=A0=C2= =A0=C2=A0| 2020-04-23 01:00:19.612478-07 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0=C2=A0| 2020-04-23 09:29:05.679275-07 | 00:00:00.000025 | COMMIT<= /span>


=C2=A032506 | ClientRead | 2020-04-23 09:30:33.247119-07 | 2020-04-23 = 01:00:19.612478-07 |=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0| 2020-04-23 0= 9:30:33.247109-07 | 00:00:00.00001=C2=A0=C2=A0| COMMIT


=C2=A032506 | C= lientRead | 2020-04-23 09:31:31.506914-07 | 2020-04-23 01:00:19.612478-07 |= =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0| 2020-04-23 09:31:31.506905-07 | = 00:00:00.000009 | COMMIT


=C2=A032506 | ClientRead | 2020-04-23 09:32:3= 2.06656-07=C2=A0=C2=A0| 2020-04-23 01:00:19.612478-07 |=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0=C2=A0| 2020-04-23 09:32:32.066552-07 | 00:00:00.00000= 8 | COMMIT


=C2=A032506 | ClientRead | 2020-04-23 09:36:51.579939-07 | = 2020-04-23 01:00:19.612478-07 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2= =A0| 2020-04-23 09:36:51.579931-07 | 00:00:00.000008 | COMMIT


It seems like they hav= en't been doing anything for a long time, but the state_change keeps ge= tting updated.
<= /div>

If the state_change timestam= p keeps changing then by definition they are doing something......
= =C2=A0
=C2=A0 Is it possible that state_c= hange is being updated, maybe by the JDBC driver?

<= div>
Directly, no, that particular field is read-only by the user and so = nothing is going to directly update it.=C2=A0 However, as soon as the sessi= on changes state it will change as well.

The most like= ly answer is that your setup for JDBC includes a connection pool that is pe= riodically checking to see if its session is still active.=C2=A0 You should= work on trying to prove or disprove that assumption.

<= /div>
Do you recommend using PgBouncer with = JDBC?

I try to avoid making recommendations with= out knowing the situation in which something is operating.=C2=A0 Given the = level of expertise demonstrated here I would, however, advise against addin= g another architectural component to your setup until your=C2=A0understand = completely what you are already working with.=C2=A0 If at that point you ca= n define a problem that you want to solve, and pgBouncer would constitute= =C2=A0a solution, then you could consider adding it.

D= avid J.

--00000000000075b79f05a3fce3e0--