Re: Re: patch review : Add ability to constrain backend temporary file space - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: Re: patch review : Add ability to constrain backend temporary file space
Date
Msg-id 20110718.054239.22298205139730835.t-ishii@sraoss.co.jp
Whole thread Raw
In response to Re: Re: patch review : Add ability to constrain backend temporary file space  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Re: patch review : Add ability to constrain backend temporary file space
List 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
tempfile 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
exceedtemp 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

pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: proposal: new contrib module plpgsql's embeded sql validator
Next
From: Bruce Momjian
Date:
Subject: Re: [COMMITTERS] pgsql: Add temp_file_limit GUC parameter to constrain temporary file sp