Re: Add a pg_wal_preallocate() SQL function to eagerly create future WAL segments

From: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
To: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Cc: solai v <solai(dot)cdac(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Ian Lawrence Barwick <barwick(at)gmail(dot)com>
Subject: Re: Add a pg_wal_preallocate() SQL function to eagerly create future WAL segments
Date: 2026-08-12 10:54:53
Message-ID: CAN55FZ1Ruouik6gwnxB+HA5eaYnwGsoZwFGKgS3Gsbi2UhhUNw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, 4 Aug 2026 at 18:11, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> wrote:
>
> On Tue, 4 Aug 2026 at 13:55, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> wrote:
>>
>> On Tue, 4 Aug 2026 at 12:32, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com> wrote:
>>>
>>> I think it is not correct to reduce the request to fit within
>>> max_wal_size. User wants to do something but you change the request
>>> without any confirmation. I think you should reject the request if
>>> 'bytes > max_wal_size && !force', and show a notice or error that the
>>> same request can be done with the force option.
>>
>>
>> Hmm makes sense, thanks for the input. I'll make it so.
>
> v5 attached.
>
> It does [1] instead of silently creating segments.
>
> Nothing gets created when it errors out, and the NOTICE is gone.
>
> I ended up comparing after rounding up to whole segments rather than on the
> byte value directly. Otherwise asking for exactly max_wal_size still sneaks a
> segment past it when max_wal_size isn't a multiple of the segment size.

I think comparing whole segments is correct. v5 LGTM.

--
Regards,
Nazir Bilal Yavuz
Microsoft

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2026-08-12 10:59:59 Re: use of SPI by postgresImportForeignStatistics
Previous Message Hayato Kuroda (Fujitsu) 2026-08-12 10:31:20 RE: 019_replslot_limit.pl might fail due to checkpoint skipped