RE: Logical Replication Memory Allocation Error - "invalid memory alloc request size"

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Max Madden' <maxmmadden(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: RE: Logical Replication Memory Allocation Error - "invalid memory alloc request size"
Date: 2025-06-11 02:31:44
Message-ID: OSCPR01MB149660B4FB4ED7B34D4340C6AF575A@OSCPR01MB14966.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear Max,

Thanks for the report.

> The initial snapshot and data copy complete successfully for all tables. However, anywhere from 5
> minutes to 2 hours after the initial sync, the subscription consistently fails with memory allocation errors like:
>
> ```
> 2025-06-10 14:14:56.800 UTC [299] ERROR: could not receive data from WAL stream: ERROR: invalid memory alloc request size 1238451248
> 2025-06-10 14:14:56.805 UTC [1] LOG: background worker "logical replication worker" (PID 299) exited with exit code 1
> ```

I think this is a known postgres bug which has been also reported at [1]. We are discussing
how we fix. Typically this can happen when there are lots of concurrent transactions
and they have DDLs. IIUC there are no good workaround for now - any parameters can't
avoid the failure. Only you can reduce them.

I'm happy if you apply the patch posted at [1] and confirms the issue can be solved, but...
seems difficult because you are in the managed env.

[1]: https://stream.boxwatch.ru/message-id/CALDaNm0TaTPuza7Fa%2BDRMzL%2BmqK3%2B7RVEvFiRoDJbU2vkJESwg%40mail.gmail.com

Best regards,
Hayato Kuroda
FUJITSU LIMITED

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dominique Devienne 2025-06-11 09:26:18 Re: is pg_stat_activity "transactional"? How fast does it update?
Previous Message Tom Lane 2025-06-10 21:31:04 Re: Is it correct to raise an exception in a domain check