Systemd could not open shared memory segment

Ellie Huxtable

Systemd가 공유 메모리 세그먼트를 열 수 없습니다

원문은 Ellie Huxtable님이 에 게재했습니다. 이 블로그 구독하기

한동안 EC2 인스턴스에서 실행 중인 PostgreSQL을 운영한 적이 있다. 가끔 쿼리가 실패하는 이상한 문제가 있었는데, 에러는 다음과 같았다.

could not open shared memory segment "/PostgreSQL.271741757".

시스템 계정이 아닌(UID < 1000) 사용자의 경우, logind는 기본적으로 로그아웃 시 공유 메모리 파일을 정리한다. 데이터베이스 같은 경우에는 전혀 바람직하지 않은 동작이다. 참고로 데이터베이스 사용자로 직접 로그인한 적이 없다면 이런 일이 발생할 가능성은 낮다.

RemoveIPC=no/etc/systemd/logind.conf에 설정하면 문제가 해결된다. 이론상으로는 시스템이 실행 중인 상태에서도 logind를 재시작할 수 있다. 직접 몇 가지 테스트를 해봤지만, 그래도 시스템을 재부팅하는 것이 가장 안전한 방법이라고 생각한다.

맨 페이지

RemoveIPC=
           Controls whether System V and POSIX IPC objects belonging to
           the user shall be removed when the user fully logs out. Takes
           a boolean argument. If enabled, the user may not consume IPC
           resources after the last of the user's sessions terminated.
           This covers System V semaphores, shared memory and message
           queues, as well as POSIX shared memory and message queues.
           Note that IPC objects of the root user and other system users
           are excluded from the effect of this setting. Defaults to
           "yes".

변경 후에는 전체 재부팅을 하면 설정이 확실하게 적용된다. 또는 logind를 재시작해도 해결된다: systemctl restart systemd-logind.service

유용한 링크:

  • https://github.com/systemd/systemd/issues/4532
  • https://github.com/systemd/systemd/issues/2039
  • https://stackoverflow.com/questions/49065733/redhat-or-centos7-systemd-may-remove-user-ipc-resources-unexpectedly
  • https://stackoverflow.com/questions/73368759/why-systemd-remove-my-shm-file-but-not-postgresqls

이 글은 muse-spark-1.2-contributor 모델을 사용해 번역했습니다.

댓글