Unlimited memory consumption with long-lived connection - Mailing list pgsql-bugs

From Duncan Sands
Subject Unlimited memory consumption with long-lived connection
Date
Msg-id a53cacb0-8835-57d6-31e4-4c5ef196de1a@deepbluecap.com
Whole thread Raw
Responses Re: Unlimited memory consumption with long-lived connection  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-bugs
If I execute the attached python script against a postgresql 15.2 (Ubuntu 
15.2-1.pgdg22.10+1) server, with the default configuration (eg shared_buffers = 
128M), then the server memory usage goes up and up, apparently endlessly.  After 
about 10 minutes (on my laptop) pg_top shows RES memory usage for the back-end 
handling the connection as greater than 1 gigabyte, which seems far too high 
given the server configuration.  The script just performs the same SELECT 
endlessly in a loop.  The memory is released when the script is killed.

Platform: Ubuntu 22.10; Linux version 5.19.0-31-generic; x86-64.

PS: The testcase was reduced from a script that kept a connection open for a 
long time in order to LISTEN, and would execute a query using the same 
connection every time there was a notification on the channel.  It consumed ever 
more memory to the point of crashing the postgresql server.  Changing the script 
to perform the query using a new short-lived connection was an effective workaround.
Attachment

pgsql-bugs by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: BUG #17803: Rule "ALSO INSERT ... SELECT ..." fails to substitute default values
Next
From: Heikki Linnakangas
Date:
Subject: Re: Unlimited memory consumption with long-lived connection