Thread: FATAL 1: Memory exhausted in AllocSetAlloc()

FATAL 1: Memory exhausted in AllocSetAlloc()

From
"Gordon P. Oliver"
Date:
Hi All.
  I have a problem that generates the out of memory error above in a
consistent manner. It doesn't seem to be covered in the faq's. Note that
this same code does _not_ fail in 7.2.1-5, but please don't ask me to
upgrade, it is a production server :-)

Version:
  postgresql-7.0.3-8 (RedHat)

What I am doing:
  BEGIN
  LOCK TABLE a IN EXCLUSIVE MODE;
  ALTER TABLE a RENAME m TO y;
  ALTER TABLE a ADD COLUMN m DATE;
  ALTER TABLE a RENAME n TO z;
  ALTER TABLE a ADD COLUMN n INT;
  UPDATE a SET m = to_date(y, 'MM DD YYYY') WHERE m IS NULL AND y  ~
'^[0-9][0-9][^0-9][0-9][0-9][^0-9][0-9][0-9][0-9][0-9]$';
  UPDATE a SET m = to_date(y, 'MM DD YY') WHERE m IS NULL AND y ~
'^[0-9][0-9][^0-9][0-9][0-9][^0-9][0-9][0-9]$';
  ... more follows ...

What happens:
  Right there, during the second update, I get the out of memory error.

Other information:
  The table has abou 60 columns.
  There are 29 rows in the table.

Output of free: (lots of free memory)
             total       used       free     shared    buffers     cached
Mem:        254504     252348       2156          0      46196      95440
-/+ buffers/cache:     110712     143792
Swap:      1044216       5856    1038360


Output of ulimit: (could it be stack size or pipe size, the error doesn't
seem appropriate)

core file size (blocks)     1000000
data seg size (kbytes)      unlimited
file size (blocks)          unlimited
max locked memory (kbytes)  unlimited
max memory size (kbytes)    unlimited
open files                  1024
pipe size (512 bytes)       8
stack size (kbytes)         8192
cpu time (seconds)          unlimited
max user processes          8157
virtual memory (kbytes)     unlimited

Does anyone have any idea of why this would fail?
Thanks in advance
    -gordo

Re: FATAL 1: Memory exhausted in AllocSetAlloc()

From
Tom Lane
Date:
"Gordon P. Oliver" <gordulat@pacbel.net> writes:
>   I have a problem that generates the out of memory error above in a
> consistent manner. It doesn't seem to be covered in the faq's. Note that
> this same code does _not_ fail in 7.2.1-5, but please don't ask me to
> upgrade, it is a production server :-)

> Version:
>   postgresql-7.0.3-8 (RedHat)

Sorry, but you need to upgrade.  7.0.* and before leak memory within
large queries.  This isn't a FAQ anymore because it stopped being
interesting more than a year ago...

            regards, tom lane