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 1okP0C-0003WI-8t for psycopg@arkaria.postgresql.org; Mon, 17 Oct 2022 12:13:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1okP0B-0007il-5O for psycopg@arkaria.postgresql.org; Mon, 17 Oct 2022 12:13:51 +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 1okP0A-0007hY-So for psycopg@lists.postgresql.org; Mon, 17 Oct 2022 12:13:50 +0000 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1okP08-000097-Lg for psycopg@postgresql.org; Mon, 17 Oct 2022 12:13:50 +0000 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-3560e81aa1dso105450257b3.2 for ; Mon, 17 Oct 2022 05:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=uMvDZoIll/zne9nQqBpEPAT//sXsyXxI9jXejdDGP7Q=; b=OIXgoahHp2CZK1vAbXq9sLrbNmarV09a6NF6G03miBS4IuQAYHZrl0nxsicsc3Xc7Y 8i3hspZpnkUkqN992V+F26Y7DWeKoSbdDoFHZXPrSEbbknaJ4cyWbIJ4pdQ+2kWPLtR6 7eHkztwVbHY/rAbeRF9AVSuGk68z4N/CvG2bzZnmrgj+VpuVfuS1irYm9sziFsklNoWg N3O6BsLLqWX21tSNWHX4dEqMvuKfnO81YFYhabn9jFHpltb51vSackVNTySPqKlr7UdQ b6y2kHl68uN0XV5ZYaac7DJv58y9QpEmfSU/k+M0X4mRrfsFoKFMCaRbCdjySwwgFz68 3bYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uMvDZoIll/zne9nQqBpEPAT//sXsyXxI9jXejdDGP7Q=; b=TbKYRLQxNJvIr98fDLV5CcOyVW+iWKyiLxmCoI0lsNIXelwvVdR3iarv2H8rzWtrRl Ng3BSSWfs3gBOtpvigntdII1seBuMPS7AkEM0/AqI4u8LCDAg/CSFca2YIjgYDV10iRs Y869x0BOikfPPhfE2lk/NjjfByG8RuUqSjTiZb3wQU5c2Lq+cwFpznCp9ExN5qqAiEOX hIZLQWHkDY2e+FrK8L0PV01MfMt/Nndayyo0YpRhN12kJzi0KXK6EE3hnYEEVARxrD3z 8geIWIsetx46BOjgBUExyF876sSyjfTxtFkKxjIIYcf14DHfVz75yk9wAhdkkZAiOotq xzqA== X-Gm-Message-State: ACrzQf07/LmcNxwKKoC8XGQv3ZWL62iyitrU05xVYMqSG/ABbhC3CRJf G+epXiP4vHw/BzpeQnRHkotV89gMipue9mQ3wRo= X-Google-Smtp-Source: AMsMyM5Dkl2alvDTtuPUwHB0MhibPLqO6EN3izYvlbJf8yJiEMy3iDOYOubyxNV4IVJCLx+Ys3Gu2R56cCQRsk/GJjI= X-Received: by 2002:a0d:d8d2:0:b0:356:642b:53ed with SMTP id a201-20020a0dd8d2000000b00356642b53edmr9031733ywe.88.1666008826784; Mon, 17 Oct 2022 05:13:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Stefan Knecht Date: Mon, 17 Oct 2022 19:13:37 +0700 Message-ID: Subject: Re: Puzzling situation with threads and psycopg2 on RDS To: Daniele Varrazzo Cc: psycopg@postgresql.org Content-Type: multipart/alternative; boundary="00000000000050308f05eb39e80c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000050308f05eb39e80c Content-Type: text/plain; charset="UTF-8" Exact same behavior with psycopg2-binary 2.9.4. On Mon, Oct 17, 2022 at 7:08 PM Stefan Knecht wrote: > Ciao Daniele > > Thanks for looking at this. > > > >> I understand this happens on RDS. Does it happen on normal Postgres >> too, from a normal process (not some serverless thing?) >> >> > I'll test this now. > > >> Are there processes/forks involved? > > > No, just Python's basic threading. > > >> Which version of psycopg are you >> using? Some old one have problems with closing connections in >> multiprocess environments. That was fixed in psycopg 2.8 (#829). >> >> > This is psycopg 3.1.3 > > And I just realized that all the other threading code I've got is on > psycopg2-binary 2.8. Has there something changed with threads in v3 ? > > > > Stefan > > --00000000000050308f05eb39e80c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Exact same behavior with psycopg2-binary 2.9.4.
=



On Mon, Oct 17, 2022 at 7:08 PM Stefan Knecht= <knecht.stefan@gmail.com= > wrote:
Ciao Daniele

Th= anks for looking at this.



I understand this happens on RDS. Does it happen on normal Postgres
too, from a normal process (not some serverless thing?)


I'll test this now.
=C2=A0
Are there processes/forks involved?

No, ju= st Python's basic threading.
=C2=A0
Which version of psycopg are you
using? Some old one have problems with closing connections in
multiprocess environments. That was fixed in psycopg 2.8 (#829).


This is psycopg 3.1.3
=C2=A0=
And I just realized that all the other threading code I've g= ot is on psycopg2-binary 2.8. Has there something changed with threads in v= 3 ?



Stefan

=
--00000000000050308f05eb39e80c--