Re: Re: patch review : Add ability to constrain backend temporary file space

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: cedric(dot)villemain(dot)debian(at)gmail(dot)com, mark(dot)kirkwood(at)catalyst(dot)net(dot)nz, josh(at)agliodbs(dot)com, robertmhaas(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: patch review : Add ability to constrain backend temporary file space
Date: 2011-07-17 20:42:39
Message-ID: 20110718.054239.22298205139730835.t-ishii@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> Could you please elaborate why "Current usage 8000kB" can bigger than
>> "temp file limit 8kB"? I undertstand the point that temp files are
>> allocated by 8kB at once, but I don't understand why those numbers you
>> suggested could happen. Actually I tried with the modified patches and
>> got:
>
>> test=# CREATE TEMPORARY TABLE resourcetemp1 AS SELECT generate_series(1,100000);
>> SELECT 100000
>> test=# SET temp_file_limit = 578;
>> SET
>> test=# SELECT count(*) FROM (select * FROM resourcetemp1 ORDER BY 1) AS a;
>> ERROR: aborting due to exceeding temp file limit, current usage 576kB, requested size 8192kB, thus it will exceed temp file limit 578kB
>
> You didn't show us how you computed those numbers, but I'm really
> dubious that FileWrite() has got any ability to produce numbers that
> are helpful. Like Cedric, I think the write amount in any one call
> is usually going to be one block.

Here it is(fd.c).

/*
* If performing this write will increase the file size, then abort if it will
* exceed temp_file_limit
*/
if (temp_file_limit >= 0 && VfdCache[file].fdstate & FD_TEMPORARY)
{
if (VfdCache[file].seekPos + amount >= VfdCache[file].fileSize)
{
increaseSize = true;
if ((temporary_files_size + (double)amount) / 1024.0 > (double)temp_file_limit)
ereport(ERROR,
(errcode(ERRCODE_QUERY_CANCELED),
errmsg("aborting due to exceeding temp file limit, current usage %dkB, requested size %dkB, thus it will exceed temp file limit %dkB",
(int)(temporary_files_size/1024),
amount,
temp_file_limit)));
}
}

I also attached the whole patch against fd.c at the point when Mark
proposed the changes.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp

Attachment Content-Type Size
fd.c.patch.gz application/octet-stream 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2011-07-17 21:08:56 Re: [COMMITTERS] pgsql: Add temp_file_limit GUC parameter to constrain temporary file sp
Previous Message Jim Nasby 2011-07-17 20:31:45 Re: proposal: new contrib module plpgsql's embeded sql validator