public inbox for [email protected]
help / color / mirror / Atom feedFrom: Max Madden <[email protected]>
To: [email protected]
Subject: Logical Replication Memory Allocation Error - "invalid memory alloc request size"
Date: Tue, 10 Jun 2025 16:37:03 +0100
Message-ID: <CAD1FGCT2sYrP_70RTuo56QTizyc+J3wJdtn2gtO3VttQFpdMZg@mail.gmail.com> (raw)
Hello,
I'm encountering a consistent issue with PostgreSQL 15 logical replication
and would appreciate any guidance on debugging or resolving this problem.
*Setup:*
- Source: PostgreSQL 15.x
- Target: PostgreSQL 15.x
- Replication: Logical replication using publication/subscription (pgoutput)
- Tables: 3 tables (details below)
*Table Details:*
- Table 1: ~1,300 records, 7 columns, no large objects
- Table 2: ~100,000 records, 7 columns, no large objects
- Table 3: ~100,000 records, 17 columns, no large objects
*Problem:*
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
```
This occurs whether I replicate all 3 tables together or individually.
My initial hypothesis is that large transactions are creating WAL segments
that exceed memory limits when sent to the subscriber. However, I haven't
been able to confirm this / find the cause.
*Questions:*
1. What's the best approach to debug this memory allocation issue?
2. Are there specific PostgreSQL settings I should check ?
3. How can I identify if large transactions are indeed the root cause?
*Additional Context:*
- This happens consistently across multiple replication attempts
- The error size varies but is always requesting > 1GB
- No custom logical replication settings currently applied
- Subscriber machine has 256 GB of RAM and Ubuntu 20.04
- Can recreate it on different machines
I should also mention that we're operating in a managed environment on
DigitalOcean, which means we don't have direct access to the WAL logs on
the publisher node. This is why the log information above is limited. I
understand this constraint makes it more difficult to provide help, but I
would really appreciate any insights or suggestions you might have.
Thanks,
Max
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Logical Replication Memory Allocation Error - "invalid memory alloc request size"
In-Reply-To: <CAD1FGCT2sYrP_70RTuo56QTizyc+J3wJdtn2gtO3VttQFpdMZg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox