PostgreSQL 11共享内存错误:无法打开共享内存段“ /PostgreSQL.XXXXXXXX”:没有这样的文件或目录

时间:2019-07-09 14:18:36

标签: postgresql systemd ubuntu-18.04 postgresql-11

共享内存文件在Postgres 11中被删除了一段时间(〜15小时)

2019-07-09 08:46:41 CDT [] [6723]: [1-1] user=,db=,e=58P01 ERROR:  could not open shared memory segment "/PostgreSQL.291691635": No such file or directory
2019-07-09 08:46:41 CDT [] [6722]: [1-1] user=,db=,e=58P01 ERROR:  could not open shared memory segment "/PostgreSQL.291691635": No such file or directory
2019-07-09 08:46:41 CDT [10.40.0.204(60550)] [13880]: [1-1] user=voicescreener,db=voicescreener,e=58P01 ERROR:  could not open shared memory segment "/PostgreSQL.291691635": No such file or directory
2019-07-09 08:46:41 CDT [10.40.0.204(60550)] [13880]: [2-1] user=user_name,db=db_name,e=58P01 CONTEXT:  parallel worker
2019-07-09 08:46:41 CDT [10.40.0.204(60550)] [13880]: [3-1] user=user_name,db=db_name,e=58P01 STATEMENT:  WITH overall_reviewed AS (SQL Query)

GCP VM配置

CPU: 4
RAM: 16 GB
 OS: Ubuntu 18.04.1 LTS

共享的内核共享内存设置

kernel.shmmax=8589934592
kernel.shmall=2097152 

postgresql.config

max_connections = 500
shared_buffers = 4GB
effective_cache_size = 12GB
maintenance_work_mem = 1GB
checkpoint_completion_target = 0.7
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem = 4194kB
min_wal_size = 1GB
max_wal_size = 2GB
max_worker_processes = 4
max_parallel_workers_per_gather = 2
max_parallel_workers = 4

启动期间:无错误/警告 约15小时后,某些共享内存文件被删除,我怀疑是否还有其他删除“ /dev/shm”中文件的过程?

不确定根本原因是什么

2 个答案:

答案 0 :(得分:1)

在 Ubuntu 18.04 和 PostgreSQL 11 上遇到了同样的问题,经过更多研究,我为我们找到了解决方案。与PG服务用户是同一用户的backup用户登录系统时出现该错误。以下链接描述了当用户(同一用户)登录系统时删除/dev/shm 下的存储。所以我们的解决方案是更改以下内容:

/etc/systemd/logind.conf 

添加行

RemoveIPC=no

并重启服务

systemctl restart systemd-logind.service

来源:

https://www.postgresql-archive.org/systemd-deletes-shared-memory-segment-in-dev-shm-Postgresql-NNNNNN-td5883507.html

https://superuser.com/questions/1117764/why-are-the-contents-of-dev-shm-is-being-removed-automatically

答案 1 :(得分:0)

在postgresql.conf中使dynamic_shared_memory_type = none确实解决了该问题。