vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on "Patroni" and DCS "etcd" or "consul"). Automating with Ansible.
MIT License
1.34k stars 370 forks source link

getting LOG: could not fork autovacuum worker process: Cannot allocate memory #671

Open kumarashish071092 opened 3 weeks ago

kumarashish071092 commented 3 weeks ago

I have suddenly started getting OOM errors in my Postgres cluster . I have to restart the patroni to log in to the database.

If I can log in by killing any existing session, then I am getting this error :

postgres=# select count(1) from pg_stat_activity;
ERROR:  out of memory
LINE 1: select count(1) from pg_stat_activity;
                             ^
DETAIL:  Failed on request of size 25462 in memory context "MessageContext".

postgresql_parameters:

kumarashish071092 commented 3 weeks ago

postgres version : 15 OS: Ubuntu 22.04 RAM : 8 GB Core : 2 Swap : 2 GB pgbouncer : enabled

it was working fine earlier . Suddenly this issue has appeared.

vitabaks commented 3 weeks ago

Hi @kumarashish071092

This issue is not related to cluster deployment but to maintenance issues. Consider sponsorship, some of the subscriptions include individual support.

Where to start:

  1. Check the monitoring system to determine the reason for the increased memory consumption. For example: more connections or a change in workload. Which processes consume memory.
  2. If query optimization is not considered, then try to reduce memory usage (shared_buffers, work_mem, maintenance_work_mem) or increase the resources of the database server.
  3. Monitor database performance metrics when changing parameters. If the memory usage parameters are reduced, performance degradation is possible.