שגיאות OOM ב-Postgresql?

סיכום מבוסס בינה מלאכותית

Postgresql OOM Errors? discussion started with piffy experiencing recurring connection errors to their Postgresql database every 30 minutes, which were found to correspond with dips in memory and OOM errors in the Postgresql logs. Their system has 8 GB Memory, 4 AMD vCPUs, and 160 GB Disk. piffy recently downgraded their machine and updated their app.yml and rebuilt Discourse, but still encountered issues. However, in their follow-up post, piffy suspected the issue was due to the db_shared_buffers setting in their app.yml being too high (4GB) and adjusted it to 2GB. After making the change, piffy noted that a full rebuild was required for the changes to take effect.

It seems that about every 30 minutes or so I am getting this error:

ActiveRecord::ConnectionNotEstablished : connection to server on socket “/var/run/postgresql/.s.PGSQL.5432” failed: FATAL: the database system is in recovery mode

I have found it corresponds to dips in memory and the postgresql logs suggest an OOM error.

free -h

total used free shared buff/cache available
Mem: 7.8Gi 4.0Gi 142Mi 3.4Gi 3.7Gi 156Mi
Swap: 2.0Gi 1.4Gi 659Mi

But I am having a difficult time trying to pinpoint where the memory is going.
I have the following setup: 8 GB Memory / 4 AMD vCPUs / 160 GB Disk

I did recently DOWNGRADE this from a beefier machine, which could be the issue. But I have updated my app.yml and rebuilt Discourse since then so I don’t know where the problem would be coming from.

app.yml:

UNICORN_WORKERS: 4
UNICORN_SIDEKIQ_MAX_RSS: 1000

Any advice?

ואז בזמן שכתבתי את זה, אני חושב שמצאתי את הבעיה

הייתי צריך להתאים את זה ב־app.yml שלי מ־4GB ל־2GB

 db_shared_buffers: “2048MB”

אני אבדוק שוב בעוד כחצי שעה כדי לראות אם זה עובד. ואשמור את ההודעה הזאת למקרה שמישהו אחר יזהה את אותה הבעיה בעתיד.

עדכון: נראה שזה דורש בנייה מחדש מלאה כדי שהשינויים ייכנסו לתוקף.