excessive logging: "Session N logged out. Waiting for processes to exit."

オープン 初心者向け
#44,828 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c

調査の方向性

session_stop_scope() から始めて、そのログ出力を session_finalize() と比較してください。レポートでは、else 分岐がログを出すのはプロセスが実際にスコープ内に残っている場合だけにし、info ではなく debug レベルで出すことが求められています。ssh host true のループで再現し、その間 journalctl -u systemd-logind -f を監視してから、通常のセッション終了では既存の info レベルの "New session" と "Removed session" 行だけが表示されることを確認してください。完了条件は、通常のセッション終了時に info レベルの "Waiting for processes to exit" が出ず、スコープにまだプロセスがある場合にのみ debug メッセージが出ることです。

索引モデルが issue の本文から書いたものです。

説明

login
systemd version the issue has been seen with

systemd 259 (259.9-0ubuntu0.1)

Used distribution

Ubuntu 26.04

Component

systemd-logind

Expected behaviour you didn't see

With KillUserProcesses=no (the default), session_stop_scope() logs

Session c87010 logged out. Waiting for processes to exit.

at info level on every normal session end. The end of the session is already
recorded at info level by session_finalize():

Removed session c87010.

On a normal session end the first message has no meaning and carries no
information: nothing is waited for, and "Removed session" follows within about
a millisecond. The message is also worded wrongly in that case: it is logged in
the else branch of session_stop_scope() whenever processes are not killed,
without checking whether the scope still has any processes, so it says
"Waiting for processes to exit" when no process is being waited for. A message
like this should be logged only when there is
something to report, for example when processes really remain in the scope
after the session has ended. Even then it is only useful for debugging, so it
belongs at debug level, not info. A session that does not finish is already
visible without this message: loginctl list-sessions and loginctl show-session <ID> show it as State=closing. "New session" and "Removed
session" remain the info-level record of a session, when it started and when it
finished.

Unexpected behaviour you saw

Every short SSH session produces both lines back to back. Example, from
/var/log/auth.log (one ssh login session):

2026-11-15T12:35:45.337414+03:00 host systemd-logind[255]: Session c87010 logged out. Waiting for processes to exit.
2026-11-15T12:35:45.338469+03:00 host systemd-logind[255]: Removed session c87010.

The gap between the two lines was 1.06 ms for this session, and 0.42 ms and
0.97 ms for two other sessions I looked at.

Each session logs 3 systemd-logind lines (New session, logged out, Removed
session), and the "logged out" line carries no information that "Removed
session" does not already carry. On a host with many short sessions (about
105,000 per week here) this is a lot of log volume.

Steps to reproduce the problem
  1. Default logind.conf (KillUserProcesses=no).
  2. Run ssh host true in a loop.
  3. Watch journalctl -u systemd-logind -f: each session prints both lines
    within about a millisecond.
Additional program output to the terminal or log subsystem illustrating the issue

See the two lines above. Both are PRIORITY=6 in the journal, so
LogLevelMax= on the unit cannot drop one without dropping the other.

Possible approach

Do not log "logged out. Waiting for processes to exit." on a normal session
end. If it is kept for the case where processes remain in the scope, log it
only then, and at LOG_DEBUG instead of LOG_INFO.

Related: #26744 and #43745 are about sessions that stay in State=closing
indefinitely; this report is about the opposite, ordinary case where the
session is removed at once.

主要言語
C
スター
17k
フォーク
4.8k
平均マージ
2日 10時間
マージ済み PR(30日)
342

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

systemd/systemd のほかの issue

systemd/systemd の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。