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

gywdnpxw  于 2022-10-15  发布在  PostgreSQL
关注(0)|答案(4)|浏览(1010)

在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=user_name,db=db_name,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虚拟机配置

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”中的文件?
不确定根本原因是什么

5vf7fwbs

5vf7fwbs1#

在postgresql.conf中设置DYNAMIC_SHARED_MEMORY_TYPE=NONE确实解决了这个问题。

44u64gxh

44u64gxh2#

在Ubuntu 18.04和PostgreSQL 11上也遇到了同样的问题,经过进一步的研究,我找到了一个解决方案。备份用户(与PG服务用户相同)登录系统时出错。下面的链接描述了当用户(同一用户)登录到系统时,/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

mrzz3bfm

mrzz3bfm3#

遇到同样的问题……当我用相同的用户帐户打开两个SQLDeveloper时,其中一个是我的远程会话,我完全忘记了关闭该会话。
我正在执行一些聚合运算符,如count(*)或max(...),并对这两个运算符进行了错误处理。错误是类似的:
错误:无法打开共享内存段“/PostgreSQL.798235387”:没有这样的文件或目录,其中:并行工作进程
解决方案?我终止了远程会话...XD和生活再次平静和快乐:D

vuv7lop3

vuv7lop34#

我们遇到了相同的问题,结果是有人将postgres用户的UID设置为大于1000(这意味着postgres用户不再是系统帐户)。而且,正如here所说:

After hours of searching and reading, I found the culprit.
It's a setting for systemd. The /etc/systemd/logind.conf contains default configuration options, with each of them commented out.
The RemoveIPC option is set to yes by default. That option tells systemd to clean up interprocess communication (IPC) for "user accounts" who aren't logged in.

================================================
This does not affect "system accounts"
================================================

相关问题