Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL 2.0.1: systemd-logind logs session out after few minutes, purges /run/user/{uid} #10552

Closed
1 of 2 tasks
phw opened this issue Sep 27, 2023 · 4 comments
Closed
1 of 2 tasks

Comments

@phw
Copy link

phw commented Sep 27, 2023

Windows Version

Microsoft Windows [Version 10.0.22621.2283]

WSL Version

2.0.1.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

No response

Distro Version

Ubuntu 22.04

Other Software

No response

Repro Steps

With WSL 2.0.1 pre-release:

  1. Run wsl --shutdown
  2. Start a new WSL2 session
  3. Check the output of systemctl status systemd-logind.service, a new session login should be logged. Also /run/user/1000 should exist
  4. Wait a few minutes (around 2 in my case)
  5. Check output from 3. again

Expected Behavior

A new user session exists and stays, /run/user/1000 does exist.

Actual Behavior

After around 2 minutes systemd-logind reports the session logged out, even though the terminal window is still open and usable. Here is the tail of journalctl --unit=systemd-logind.service

-- Boot 96fd903f21e34b4aba65abdb32422cc2 --
Sep 27 08:04:16 jap-phw systemd[1]: Starting User Login Management...
Sep 27 08:04:16 jap-phw systemd-logind[383]: New seat seat0.
Sep 27 08:04:16 jap-phw systemd[1]: Started User Login Management.
Sep 27 08:04:24 jap-phw systemd-logind[383]: New session 1 of user phw.
Sep 27 08:06:16 jap-phw systemd-logind[383]: Session 1 logged out. Waiting for processes to exit.
Sep 27 08:06:16 jap-phw systemd-logind[383]: Removed session 1.

Due to this also the /run/user/{uid} directory for this user gets purged. This can cause issues with running applications making use of this directory and can prevent applications from starting.

For me this behavior is reliably reproducible every time, and every time session log out happens at around 2 minutes after start. I can start applications using /run/user/{uid} initially and see that this directory is being filled, but regardless of whether I have applications started or just have the terminal sit idle it gets cleaned up after the 2 minutes.

This behavior did not happen with the stable release WSL 1.3

Diagnostic Logs

No response

@phw phw changed the title systemd-logind loggs session out too early, resulting in /run/user/{uid} directory being purged WSL 2.0.1: systemd-logind logs session out after few minutes, purges /run/user/{uid} Sep 27, 2023
@phw
Copy link
Author

phw commented Sep 27, 2023

I had autoMemoryReclaim=dropcache set in ~/.wslconfig. Just to make sure that this is not related to the issue I removed this line from the config file and retested. But same behavior.

@OneBlue
Copy link
Collaborator

OneBlue commented Sep 27, 2023

/logs

@mosullivan93
Copy link

I suspect this is also due to #10496. What does systemctl status systemd-networkd-wait-online say?

If it timed out while waiting (2 minutes is the default), then it's (partially) due to a change with systemd (bug report).

You should be able fix it by disabling systemd-networkd (and shutdown & reboot WSL):
systemctl disable --now systemd-networkd.service

In order to get it to work without disabling this service you'll need to wait for the proposed fix to roll out (and tweak your systemd-networkd config to tell it to explicitly ignore the built in adapter).

@phw
Copy link
Author

phw commented Sep 28, 2023

Thank you very much for the quick and detailed response. Your are exactly right, the systemd-networkd is the cause for this. I attached details about both systemd-networkd and systemd-logind below. Disabling systemd-networkd seems to be a sensible thing to do under WSL anyway, so this works for me.

That also means not my update to WSL 2.0.1 but updating the packages inside the VM was the reason this started to happen.

I close this issue as it is already tracked in #10496 and also essentially a systemd and not a WSL issue.

phw@jap-phw ~ % systemctl status systemd-networkd-wait-online
× systemd-networkd-wait-online.service - Wait for Network to be Configured
     Loaded: loaded (/lib/systemd/system/systemd-networkd-wait-online.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Thu 2023-09-28 14:41:08 CEST; 27s ago
       Docs: man:systemd-networkd-wait-online.service(8)
    Process: 410 ExecStart=/lib/systemd/systemd-networkd-wait-online (code=exited, status=1/FAILURE)
   Main PID: 410 (code=exited, status=1/FAILURE)

Sep 28 14:39:08 jap-phw systemd[1]: Starting Wait for Network to be Configured...
Sep 28 14:41:08 jap-phw systemd-networkd-wait-online[410]: Timeout occurred while waiting for network connectivity.
Sep 28 14:41:08 jap-phw systemd[1]: systemd-networkd-wait-online.service: Main process exited, code=exited, status=1/FA>
Sep 28 14:41:08 jap-phw systemd[1]: systemd-networkd-wait-online.service: Failed with result 'exit-code'.
Sep 28 14:41:08 jap-phw systemd[1]: Failed to start Wait for Network to be Configured.
phw@jap-phw ~ % systemctl status systemd-logind.service                                                              3
● systemd-logind.service - User Login Management
     Loaded: loaded (/lib/systemd/system/systemd-logind.service; static)
     Active: active (running) since Thu 2023-09-28 14:39:08 CEST; 2min 33s ago
       Docs: man:sd-login(3)
             man:systemd-logind.service(8)
             man:logind.conf(5)
             man:org.freedesktop.login1(5)
   Main PID: 383 (systemd-logind)
     Status: "Processing requests..."
      Tasks: 1 (limit: 8277)
     Memory: 1.6M
     CGroup: /system.slice/systemd-logind.service
             └─383 /lib/systemd/systemd-logind

Sep 28 14:39:08 jap-phw systemd[1]: Starting User Login Management...
Sep 28 14:39:08 jap-phw systemd-logind[383]: New seat seat0.
Sep 28 14:39:08 jap-phw systemd[1]: Started User Login Management.
Sep 28 14:39:17 jap-phw systemd-logind[383]: New session 1 of user phw.
Sep 28 14:41:09 jap-phw systemd-logind[383]: Session 1 logged out. Waiting for processes to exit.
Sep 28 14:41:09 jap-phw systemd-logind[383]: Removed session 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants