| From: | Sergey Soloviev <sergey(dot)soloviev(at)tantorlabs(dot)ru> |
|---|---|
| To: | Pierre Forstmann <pierre(dot)forstmann(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] Do not flush BufFile for regular temp files |
| Date: | 2026-08-17 06:01:31 |
| Message-ID: | 1cd5505e-8e0a-47ea-8205-a2a661fa9c2f@tantorlabs.ru |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi!
Thanks for response.
I do not know whether this is correct to throw error when we can not do it.
'temp_file_limit' is enforced for actually created files and not on BufFile, so
if we can create one without it's associated file, then I see here no problems.
And this must be true for both normal and inter-xact, because in that case
owner backend is the only who can work with the file, so there is no need
to forcibly create disk file.
> 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
---
Sergey Soloviev
TantorLabs: https://tantorlabs.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrey Rachitskiy | 2026-08-17 06:05:56 | Re: Residual cleanups for tied objects in PL/Perl |
| Previous Message | Stepan Tyagushev | 2026-08-17 05:55:43 | Re: Fix XLogFileReadAnyTLI silently applying divergent WAL from wrong timeline |