Re: [PATCH] Do not flush BufFile for regular temp files - Mailing list pgsql-hackers

From Pierre Forstmann
Subject Re: [PATCH] Do not flush BufFile for regular temp files
Date
Msg-id 178672293101.650980.4633415195764892783.pgcf@coridan.postgresql.org
Whole thread
In response to [PATCH] Do not flush BufFile for regular temp files  (Sergey Soloviev <sergey.soloviev@tantorlabs.ru>)
Responses Re: [PATCH] Do not flush BufFile for regular temp files
List pgsql-hackers
Hello

I think there is an issue with this patch: you are not taking into account a inter-transaction BufFile.

If a BufFile is created with isInterXact set to true, BufFileClose does not flush data and this looks wrong.

You can test this with the following extension https://github.com/pierreforstmann/buffile .

With PostgreSQL 20devdel, I get:
--
-- Test BufFileClose() flushing behavior.
--
CREATE EXTENSION buffile;
-- A regular temporary BufFile should not be flushed by BufFileClose().
--
-- With temp_file_limit = 0, a physical write must fail.  Therefore
-- false means that BufFileClose() did not attempt the write.
SET temp_file_limit = 0;
SELECT test_buffile_temp(false);
INFO:  BufFileClose has not flushed data
 test_buffile_temp 
-------------------
 f
(1 row)

-- An inter-transaction BufFile must still be flushed by BufFileClose().
--
-- Therefore the physical write should fail with temp_file_limit = 0.
SELECT test_buffile_temp(true);
INFO:  BufFileClose has not flushed data
 test_buffile_temp 
-------------------
 f
(1 row)

RESET temp_file_limit;
-- A FileSet BufFile must also be flushed by BufFileClose(), because
-- another opener must be able to see its contents.
SELECT test_buffile_fileset();
INFO:  BufFileClose has flushed data
 test_buffile_fileset 
----------------------
 t
(1 row)


Regards
Pierre Forstmann

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Limit GRAPH_TABLE path combinations to prevent memory exhaustion
Next
From: Alexander Korotkov
Date:
Subject: Re: Implement waiting for wal lsn replay: reloaded