- Newest
- Most votes
- Most comments
The increased swap usage you're observing after setting a finite value for max_slot_wal_keep_size and the OS upgrade could be related to how PostgreSQL manages replication slots and Write-Ahead Log (WAL) retention.
When you set a finite value for max_slot_wal_keep_size, PostgreSQL changes how it manages WAL files for replication slots. This parameter limits how much disk space can be consumed by WAL retention for replication slots. While this helps prevent unbounded disk usage growth from inactive replication slots, it can affect memory usage patterns.
Here's what might be happening:
-
WAL management changes: With a finite
max_slot_wal_keep_size, PostgreSQL may be changing its WAL processing behavior, potentially affecting memory allocation patterns for WAL senders and related processes. -
Replication slot monitoring: The system might be allocating additional memory to track WAL usage against the new limit, especially if you have multiple replication slots.
-
OS upgrade impact: The RDS OS upgrade that occurred simultaneously could have introduced changes to memory management, swap policies, or default configurations that contribute to the increased swap usage.
-
Background processes: The change might have affected how background processes like WAL writers and checkpointers operate, potentially leading to different memory usage patterns.
The fact that swap usage grows again after setting max_slot_wal_keep_size back to -1 suggests that the parameter is indeed related to the behavior you're seeing. With -1, PostgreSQL doesn't limit WAL retention for replication slots, which can lead to different memory allocation patterns.
To further troubleshoot:
-
Monitor PostgreSQL wait events, particularly those related to WAL operations like
WALWriteLock. -
Check if there are any changes in checkpoint behavior or frequency, as these can affect memory and I/O patterns.
-
Examine if there are any inactive or lagging replication slots that might be affecting WAL retention.
-
Consider enabling Performance Insights for more detailed analysis of database load and memory usage patterns.
If the swap usage continues to be a concern, you might want to consider adjusting your instance size or memory configuration to accommodate the new behavior, or contact AWS Support for a more in-depth investigation of the OS-level changes that might have occurred during the upgrade.
Sources
WALWriteLock wait elevated without any obvious cause | AWS re:Post
DMS between two RDS instances, grown OldestReplicationSlotLag | AWS re:Post
Understanding transaction visibility in PostgreSQL clusters with read replicas | AWS Database Blog
answered a year ago
