systemdが共有メモリセグメントを開けない
原文は Ellie Huxtable により に公開されました。 このブログを購読する
しばらくEC2インスタンス上でPostgreSQLを運用していた。ときどきクエリが失敗するという奇妙な問題が発生し、エラーは次のようなものだった。
could not open shared memory segment "/PostgreSQL.271741757".
システムユーザー以外(UID < 1000)の場合、logindはデフォルトでログアウト時に共有メモリファイルを削除する。データベースのようなものにとって、これはまったく望ましくない。なお、データベースユーザーとしてログインすることがなければ、この問題が起きる可能性は低いことは覚えておくといい。
/etc/systemd/logind.confでRemoveIPC=noを設定すれば解決するはずだ。理論上はシステムの稼働中にlogindを再起動することも可能だ。いくつかテストはしてみたが、やはりシステムを再起動するのが最も安全だと思う。
Manページ
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
記事をランダムに読む
コメント
ログインしてコメントする