pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedPossible memory leak in PostgreSQL 12.2 on truncate, insert or delete when type interval is involved
3+ messages / 2 participants
[nested] [flat]
* Possible memory leak in PostgreSQL 12.2 on truncate, insert or delete when type interval is involved
@ 2020-02-17 16:04 Hazuki Amamiya <hatsuki_a-ie@yahoo.com.hk>
0 siblings, 1 reply; 3+ messages in thread
From: Hazuki Amamiya @ 2020-02-17 16:04 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Hi Developers,
Recently, there is a memory leak in the game server I hosted. After checking the log, the leak seems appeared after I upgrade PostgreSQL from 11 to 12.1, and I have no luck even I upgraded the PostgreSQL to 12.2 [PostgreSQL 12.2 (Debian 12.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit] in Debian 10.
I ran a CLI php script which stays forever like a service, and the script won't disconnect form PostgreSQL after connected.
As my original script is difficult to reproduce for you to debug, here I attached a test PHP CLI script which I guess it can simulate the problematic behaviour found in my script:
================================== <?php
$conn=pg_connect("host=127.0.0.1 dbname=fgtracker user=fgtracker password=fgtracker11 connect_timeout=5",PGSQL_CONNECT_FORCE_NEW);
pg_query ("DROP TABLE IF EXISTS temp_bugreproduction;");
pg_query ("DROP SEQUENCE IF EXISTS temp_bugreproduction_seq;");
pg_query ("CREATE SEQUENCE temp_bugreproduction_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;");
pg_query ("CREATE TABLE temp_bugreproduction (callsign text,flighttime interval,effective_flight_time interval,rank integer DEFAULT nextval('temp_bugreproduction_seq') NOT NULL) WITH (oids = false);");
$j=0;$sql="";
for ($i=0;$i<50;$i++)
$sql.="Insert into temp_bugreproduction (callsign ,flighttime ,effective_flight_time) VALUES ('abc', interval '00:00:01', interval '00:00:02');";
while (1)
{ $j++;
pg_query ("select setval('temp_bugreproduction_seq',1);");
pg_query ("Truncate table temp_bugreproduction");
pg_query ($sql);
for ($i=0;$i<10;$i++)
{ pg_query ("Insert into temp_bugreproduction select callsign ,flighttime +'00:00:01' ,effective_flight_time +'00:00:01' from temp_bugreproduction");
pg_query ("delete from temp_bugreproduction where flighttime > effective_flight_time");
}
print "Iterate $j\n";
}
?>====================================
While the script continuing to run, the RES (shown in command “top”) will keep increasing forever.
As this is my first bug report here, please accept my apologies if anything not clear.
In avoidance of doubt, although I mentioned in title that type interval may be the culprit, this is merely my guess and the culprit may be something else.
Hazuki
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Possible memory leak in PostgreSQL 12.2 on truncate, insert or delete when type interval is involved
@ 2020-02-17 22:22 Tom Lane <tgl@sss.pgh.pa.us>
parent: Hazuki Amamiya <hatsuki_a-ie@yahoo.com.hk>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2020-02-17 22:22 UTC (permalink / raw)
To: Hazuki Amamiya <hatsuki_a-ie@yahoo.com.hk>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Hazuki Amamiya <hatsuki_a-ie@yahoo.com.hk> writes:
> Recently, there is a memory leak in the game server I hosted. After checking the log, the leak seems appeared after I upgrade PostgreSQL from 11 to 12.1, and I have no luck even I upgraded the PostgreSQL to 12.2 [PostgreSQL 12.2 (Debian 12.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit] in Debian 10.
FWIW, I see no sign of a memory leak with this example.
> While the script continuing to run, the RES (shown in command “top”) will keep increasing forever.
Does it really increase "forever"? A fairly common cause of confusion
is that top will report the process' space consumption as gradually
increasing until all of Postgres' shared buffers have been touched
(after which the number stops growing). That's not a leak, it's just
an artifact of how top chooses to count usage of shared memory.
Usually, if you don't see the total "VIRT" column increasing, there's
no real leak happening.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Possible memory leak in PostgreSQL 12.2 on truncate, insert or delete when type interval is involved
@ 2020-02-18 03:48 Hazuki Amamiya <hatsuki_a-ie@yahoo.com.hk>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Hazuki Amamiya @ 2020-02-18 03:48 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Hi Tom,
Indeed my scripts seems not able to replicate what happened in my production server. With my production script in my production server, both RES and VIRT do increase. Just I am unable to replicate it with a simple script and simple database schema.
Since the workaround is rather easy by establishing a new connection session every certain time, I would like to close this bug report.
Thanks for your help.
hazuki
On Tuesday, 18 February 2020, 06:22:41 GMT+8, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Hazuki Amamiya <hatsuki_a-ie@yahoo.com.hk> writes:
> Recently, there is a memory leak in the game server I hosted. After checking the log, the leak seems appeared after I upgrade PostgreSQL from 11 to 12.1, and I have no luck even I upgraded the PostgreSQL to 12.2 [PostgreSQL 12.2 (Debian 12.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit] in Debian 10.
FWIW, I see no sign of a memory leak with this example.
> While the script continuing to run, the RES (shown in command “top”) will keep increasing forever.
Does it really increase "forever"? A fairly common cause of confusion
is that top will report the process' space consumption as gradually
increasing until all of Postgres' shared buffers have been touched
(after which the number stops growing). That's not a leak, it's just
an artifact of how top chooses to count usage of shared memory.
Usually, if you don't see the total "VIRT" column increasing, there's
no real leak happening.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-02-18 03:48 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 16:04 Possible memory leak in PostgreSQL 12.2 on truncate, insert or delete when type interval is involved Hazuki Amamiya <hatsuki_a-ie@yahoo.com.hk>
2020-02-17 22:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-02-18 03:48 ` Hazuki Amamiya <hatsuki_a-ie@yahoo.com.hk>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox