Re: BUG #19411: libpq 16.x exhibits a memory leak when connections are repeatedly created and destroyed - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #19411: libpq 16.x exhibits a memory leak when connections are repeatedly created and destroyed
Date
Msg-id 1702505.1771347709@sss.pgh.pa.us
Whole thread Raw
In response to BUG #19411: libpq 16.x exhibits a memory leak when connections are repeatedly created and destroyed  (PG Bug reporting form <noreply@postgresql.org>)
Responses RE: BUG #19411: libpq 16.x exhibits a memory leak when connections are repeatedly created and destroyed
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> This report is for the libpq client library for PostgreSQL.

> I noticed the issue because my Apache Airflow task supervisor processes were
> experiencing memory growth of ~600 KB/min.  When running hundreds of tasks,
> my 32 GB machine OOM-crashed every few hours.  I traced the problem to when
> I upgraded libpq from version 13 to 16.  Varying Python version, and
> PostgreSQL DB version didn't make a difference.  When I updated to psycopg3,
> the leak rate dropped dramatically.

I think there are way too many moving parts here, and too few
configuration details, to allow assigning blame confidently.
I tried making a simple C test program that just connected, issued
BEGIN/UPDATE/COMMIT, and disconnected in a tight loop.  I see zero
leakage with that.  So either the leak isn't actually in libpq, or
there's some critical environmental factor you didn't mention.

Plausible such factors include connection type and authentication
method.  (For example, years ago libpq did leak memory while using
GSSAPI encryption.)  I tried both regular and SSL connections but
didn't really push hard on that, since I'd just be guessing blindly
about what your setup is.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Artem Fadeev
Date:
Subject: Re: BUG #19412: Wrong query result with not null constraint
Next
From: Matt Carter
Date:
Subject: RE: BUG #19411: libpq 16.x exhibits a memory leak when connections are repeatedly created and destroyed