Railway Postgres PITR = Memory Leak
mhornbacher
PROOP

11 days ago

I created a simple database today. No traffic but it does have two configuration changes. 1 is enabling logical replication for PowerSync. The other is PITR. As you can see as soon as PITR was enabled memory sharply increases. Note that there is no load on the system yet.

I staged and rolled back a disabling of the feature and memory immediately returned to normal (~40mb rather than 2GB)

Has anyone else experienced this kind of runaway memory from backups?

Screenshot 2026-05-31 at 11.30.40 PM.png

Screenshot 2026-05-31 at 11.41.27 PM.png

Screenshot 2026-05-31 at 11.41.33 PM.png

$20 Bounty

3 Replies

Status changed to Open Railway 11 days ago


Anonymous
FREE

11 days ago

I’ve run into this before—it’s usually a quirk with how Postgres handles memory when you pair logical replication with PITR on a completely idle database.

​Even with zero traffic, Postgres is writing internal state changes and checkpoints to the WAL. Because wal_level = logical is active but you don't have an active subscriber actively pulling and flushing that stream yet, the walsender process caches all those internal changes in memory. Postgres defaults logical_decoding_work_mem quite high (often up to 1.5GB–2GB), so it just sits there soaking up RAM instead of spilling to disk.

​If you want to keep PITR on without the massive memory spike, try lowering that buffer limit in your config:

ALTER SYSTEM SET logical_decoding_work_mem = '64MB';

​Once you actually connect PowerSync and it starts consuming the replication slot, that memory footprint should drop back down and behave normally!


I’ve run into this before—it’s usually a quirk with how Postgres handles memory when you pair logical replication with PITR on a completely idle database. ​Even with zero traffic, Postgres is writing internal state changes and checkpoints to the WAL. Because wal_level = logical is active but you don't have an active subscriber actively pulling and flushing that stream yet, the walsender process caches all those internal changes in memory. Postgres defaults logical_decoding_work_mem quite high (often up to 1.5GB–2GB), so it just sits there soaking up RAM instead of spilling to disk. ​If you want to keep PITR on without the massive memory spike, try lowering that buffer limit in your config: ALTER SYSTEM SET logical_decoding_work_mem = '64MB'; ​Once you actually connect PowerSync and it starts consuming the replication slot, that memory footprint should drop back down and behave normally!

kiddomdevops
FREE

11 days ago

So there was an active PowerSync instance connected to it… but that does make sense 🤔

ill give that config a try and see if it helps as well. It should start having load within the week and Ill enable it then to validate


mhornbacher
PROOP

4 days ago

Whoops, that was a work account 😊


Welcome!

Sign in to your Railway account to join the conversation.

Loading...