public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Matt Carter <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: BUG #19411: libpq 16.x exhibits a memory leak when connections are repeatedly created and destroyed
Date: Tue, 17 Feb 2026 13:47:49 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <BL3PR08MB728301C87997AF17C743633A996DA@BL3PR08MB7283.namprd08.prod.outlook.com>
References: <[email protected]>
	<[email protected]>
	<BL3PR08MB728301C87997AF17C743633A996DA@BL3PR08MB7283.namprd08.prod.outlook.com>

Matt Carter <[email protected]> writes:
> Tom Lane <[email protected]> wrote:
>> I think there are way too many moving parts here, and too few configuration details,
>> to allow assigning blame confidently.

> Thank you for taking the time to test this and for the feedback.  Your C test showing no leak suggests the issue is specific to how psycopg2 uses libpq, not libpq itself.  I apologize for not including enough environmental details.  I used Kerberos/GSSAPI with SSL (TLS 1.2 connections).  My connection string was: "postgresql://hostname/database" (no password, Kerberos auth).
> Your mention of "years ago libpq did leak memory while using GSSAPI encryption" is interesting because we ARE using GSSAPI/Kerberos authentication.

Interesting.  I wondered about GSSAPI, but spinning up such an
environment is more work than I wanted to do on speculation.

> I can test with non-GSSAPI authentication to try to isolate that variable.  I can also create a pure psycopg2 reproducer (without SQLAlchemy).  I can also test whether disabling GSSAPI encryption (but keeping GSSAPI auth) changes the behavior.  Would testing with GSSAPI authentication help narrow this down? I can also report this to the psycopg2 project if you think it's their issue.

Please try varying the connection type and encryption.  I do suspect
this may be psycopg2's fault, but we lack enough data to pin blame
as yet.

			regards, tom lane






reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: BUG #19411: libpq 16.x exhibits a memory leak when connections are repeatedly created and destroyed
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox