Re: How to generate a WAL record spanning multiple WAL files?

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: How to generate a WAL record spanning multiple WAL files?
Date: 2022-04-22 14:02:07
Message-ID: CALj2ACUpmNDHa6mhCpYLRv5cHiFzMwnuMZRqOm75Abs8EVVatQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 6, 2022 at 6:56 AM Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> wrote:
>
> On Wed, Apr 6, 2022 at 12:41 AM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>>
>> On Tue, Apr 5, 2022 at 10:10 AM Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> wrote:
>> >> > I wanted to have a WAL record spanning multiple WAL files of size, say
>> >> > 16MB. I'm wondering if the Full Page Images (FPIs) of a TOAST table
>> >> > would help here. Please let me know if there's any way to generate
>> >> > such large WAL records.
>> >>
>> >> It's easier to use pg_logical_emit_message().
>> >
>> > Not sure I understand the question correctly here. What if I use the below code
>> > where the len might be very large? like 64MB.
>> >
>> > XLogBeginInsert();
>> > XLogRegisterData((char *)&xl_append, sizeof(xl_cstore_append));
>> > XLogRegisterData((char *)data, len);
>> >
>> > XLogInsert(..);
>>
>> Well, that's how to do it from C. And pg_logical_emit_message() is how
>> to do it from SQL.
>>
>
> OK, Thanks for your confirmation!

Thanks all for your responses. Yes, using pg_logical_emit_message() is
easy, but it might come in the way of logical decoding as those
messages get decoded.

PS: I wrote a small extension (just for fun) called pg_synthesize_wal
[1] implementing functions to generate huge WAL records. I used the
"Custom WAL Resource Managers" feature [2] that got committed to PG15.

[1] https://github.com/BRupireddy/pg_synthesize_wal
[2] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=5c279a6d350205cc98f91fb8e1d3e4442a6b25d1

Regards,
Bharath Rupireddy.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-04-22 14:04:05 Re: pgsql: Allow db.schema.table patterns, but complain about random garbag
Previous Message Bharath Rupireddy 2022-04-22 13:47:37 Re: pg_receivewal fail to streams when the partial file to write is not fully initialized present in the wal receiver directory