Nasty resource-leak problem in sort code

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Nasty resource-leak problem in sort code
Date: 1999-05-04 15:07:31
Message-ID: 29883.925830451@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

If a CREATE INDEX fails, the backend returns to the main loop without
having closed the temporary files that are created for sorting.
An easy example that provokes this is

create table titles (adate date);
insert into titles values ('today');
create index titles_f_ind on titles (date(adate) date_ops);
ERROR: SQL-language function not supported in this context.

after which the backend has about a dozen more open files than it had
before.

If you then try to create another index, you will crash for
lack of free file descriptors (unless your kernel has a
higher-than-usual open-files-per-process limit). In any case, the
sort temp files will never get deleted from your database directory.

Offhand I'm not sure how to fix this. The system knows about releasing
memory after an elog(ERROR), but does it have any provisions for
releasing other kinds of resources? I suspect we need something
analogous to the on_shmem_exit() callback-registration list, but I
don't know whether it already exists. Comments?

regards, tom lane

Browse pgsql-hackers by date

  From Date Subject
Next Message Dirk Lutzebaeck 1999-05-04 15:30:06 major flaw in 6.5beta1??? (UPDATE/INSERT waiting)
Previous Message Tatsuo Ishii 1999-05-04 15:02:44 Re: [HACKERS] posmaster failed under high load