You are not logged in.

#1 2024-09-14 21:07:50

tillo.eaux
Member
Registered: 2024-09-14
Posts: 3

[SOLVED] systemd sleep hook error after suspend-then-hibernate

Hello friends,

I ran into a problem following this guide to set up user targets for system targets. I created the system level service to enable the user level target:

# systemctl cat sleep@username.service
# /etc/systemd/system/sleep@.service
#system
[Unit]
Description=Manage sleep.target of user session
After=sleep.target

[Service]
Type=oneshot
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%I/bus
ExecStart=/usr/bin/systemctl --user --machine=%i@ start sleep.target

[Install]
WantedBy=sleep.target


# systemctl --user cat sleep.target
# /home/username/.config/systemd/user/sleep.target
#user
[Unit]
Description=User session sleep.target
StopWhenUnneeded=yes

However, while this setup works perfectly for me, when I am logged in and manually starting the service with systemctl, after I resume my session the service fails with the following result:

# sudo systemctl status sleep@username
× sleep@username.service - Manage sleep.target of user session
     Loaded: loaded (/etc/systemd/system/sleep@.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Sat 2024-09-14 16:47:08 CEST; 5h 43min ago
 Invocation: e762a3d785944c1c910e713379c058a1
   Main PID: 16782 (code=exited, status=1/FAILURE)
   Mem peak: 2.4M
        CPU: 16ms
Sep 14 16:47:08 arch systemd[1]: Starting Manage sleep.target of user session...
Sep 14 16:47:08 arch systemctl[16782]: Failed to start sleep.target: Transport endpoint is not connected
Sep 14 16:47:08 arch systemctl[16782]: See user logs and 'systemctl --user status sleep.target' for details.
Sep 14 16:47:08 arch systemd[1]: sleep@username.service: Main process exited, code=exited, status=1/FAILURE
Sep 14 16:47:08 arch systemd[1]: sleep@username.service: Failed with result 'exit-code'.
Sep 14 16:47:08 arch systemd[1]: Failed to start Manage sleep.target of user session.

# systemctl --user status sleep.target
○ sleep.target - User session sleep.target
     Loaded: loaded (/home/username/.config/systemd/user/sleep.target; static)
     Active: inactive (dead)

Sep 11 21:19:14 arch systemd[763]: Reached target User session sleep.target.
Sep 11 21:19:14 arch systemd[763]: Stopped target User session sleep.target.
Sep 11 21:21:33 arch systemd[763]: Reached target User session sleep.target.
Sep 11 21:21:33 arch systemd[763]: Stopped target User session sleep.target.
Sep 11 21:23:28 arch systemd[763]: Reached target User session sleep.target.
Sep 11 21:23:28 arch systemd[763]: Stopped target User session sleep.target.
Sep 11 21:44:26 arch systemd[763]: Reached target User session sleep.target.
Sep 11 21:44:26 arch systemd[763]: Stopped target User session sleep.target.
Sep 14 14:35:41 arch systemd[763]: Reached target User session sleep.target.
Sep 14 14:35:41 arch systemd[763]: Stopped target User session sleep.target.

The activations of the target were mostly done manually using systemctl for testing and to start the user services that are bound to it.
The weirdest thing, in my opinion, is that when I initially set up this service and target on Sep 11 it worked! Then I rebooted and that's when the error showed up first.

# sudo journalctl -u sleep@username [excerpt]
Sep 11 17:42:23 arch systemd[1]: Starting Manage sleep.target of user session...
Sep 11 17:42:38 arch systemd[1]: sleep@username.service: Deactivated successfully.
Sep 11 17:42:38 arch systemd[1]: Finished Manage sleep.target of user session.
Sep 11 17:46:10 arch systemd[1]: Starting Manage sleep.target of user session...
Sep 11 19:38:55 arch systemd[1]: sleep@username.service: Deactivated successfully.
Sep 11 19:38:55 arch systemd[1]: Finished Manage sleep.target of user session.
-- Boot 0f97614cb76440579e72fa6d0a3982f1 --
Sep 11 21:08:38 arch systemd[1]: Starting Manage sleep.target of user session...
Sep 11 21:08:38 arch systemctl[3599]: Failed to start sleep.target: Transport endpoint is not connected
Sep 11 21:08:38 arch systemctl[3599]: See user logs and 'systemctl --user status sleep.target' for details.
Sep 11 21:08:38 arch systemd[1]: sleep@username.service: Main process exited, code=exited, status=1/FAILURE
Sep 11 21:08:38 arch systemd[1]: sleep@username.service: Failed with result 'exit-code'.
Sep 11 21:08:38 arch systemd[1]: Failed to start Manage sleep.target of user session.

# sudo journalctl -u sleep.target [excerpt]
Sep 11 17:42:38 arch systemd[755]: Reached target User session sleep.target.
Sep 11 17:42:38 arch systemd[755]: Stopped target User session sleep.target.
Sep 11 19:38:55 arch systemd[755]: Reached target User session sleep.target.
Sep 11 19:38:55 arch systemd[755]: Stopped target User session sleep.target.
-- Boot 0f97614cb76440579e72fa6d0a3982f1 --
[missing activation for Sep 11 21:08:52 resume]
Sep 11 21:11:23 arch systemd[763]: Reached target User session sleep.target.
Sep 11 21:11:23 arch systemd[763]: Stopped target User session sleep.target.

# sudo journalctl -u sleep.target [excerpt]
Sep 11 17:42:23 arch systemd[1]: Reached target Sleep.
Sep 11 17:42:38 arch systemd[1]: Stopped target Sleep.
Sep 11 17:46:10 arch systemd[1]: Reached target Sleep.
Sep 11 19:38:55 arch systemd[1]: Stopped target Sleep.
-- Boot 0f97614cb76440579e72fa6d0a3982f1 --
Sep 11 21:08:37 arch systemd[1]: Reached target Sleep.
Sep 11 21:08:52 arch systemd[1]: Stopped target Sleep.

Now I have no idea what the systemd error "transport endpoint not connected" could mean, how the "--machine=%i@" option works or what might cause a restart to break a working service.

The Environment parameter in the sleep@.service was added based on information from this pretty old thread on our forum. I have tested without it and run into the same error. I'm also interested, whether that is a old/deprecated alternative to what the "--machine=%i@" option is doing and can safely be removed.

Thank you for taking a look!

Last edited by tillo.eaux (2024-09-15 12:44:37)

Offline

#2 2024-09-15 12:06:15

tillo.eaux
Member
Registered: 2024-09-14
Posts: 3

Re: [SOLVED] systemd sleep hook error after suspend-then-hibernate

I figured out, why it did work at some point. When I send my system to sleep using systemctl suspend, the service works perfectly. However, when returning from suspend-then-hibernate, the error occurs.

This is an excerpt from the journal (journalctl -r) after suspending:

Sep 15 13:42:49 arch systemd[763]: Stopped target User session sleep.target.
Sep 15 13:42:49 arch systemd[763]: Reached target User session sleep.target.
Sep 15 13:42:49 arch kscreenlocker_greet[27806]: pam_systemd_home(kde:auth): New sd-bus connection (system-bus-pam-systemd-home-27806) opened.
Sep 15 13:42:49 arch NetworkManager[622]: <info>  [1726400569.4969] device (enp0s31f6): state change: unavailable -> unmanaged (reason 'unmanaged-sleeping', sys-iface-state: 'managed')
Sep 15 13:42:49 arch NetworkManager[622]: <info>  [1726400569.4969] manager: sleep: wake requested (sleeping: yes  enabled: yes)
Sep 15 13:42:49 arch systemd[1]: Stopped target Suspend.
Sep 15 13:42:49 arch systemd-logind[625]: Operation 'suspend' finished.
Sep 15 13:42:49 arch systemd[1]: Reached target Suspend.
Sep 15 13:42:49 arch systemd[1]: Stopped target Sleep.
Sep 15 13:42:49 arch systemd[1]: Started Session 23 of User username.
Sep 15 13:42:49 arch kded6[964]: kf.networkmanagerqt: void NetworkManager::ConnectionPrivate::onPropertiesChanged(const QVariantMap&) Unhandled property "VersionId"
Sep 15 13:42:49 arch plasmashell[997]: kf.networkmanagerqt: void NetworkManager::ConnectionPrivate::onPropertiesChanged(const QVariantMap&) Unhandled property "VersionId"
Sep 15 13:42:49 arch systemd[1]: Finished System Suspend.
Sep 15 13:42:49 arch systemd[1]: systemd-suspend.service: Deactivated successfully.
Sep 15 13:42:49 arch plasmashell[997]: kf.networkmanagerqt: void NetworkManager::ConnectionPrivate::onPropertiesChanged(const QVariantMap&) Unhandled property "VersionId"
Sep 15 13:42:49 arch systemd-sleep[27866]: Successfully thawed unit 'user.slice'.
Sep 15 13:42:49 arch kded6[964]: kf.networkmanagerqt: void NetworkManager::ConnectionPrivate::onPropertiesChanged(const QVariantMap&) Unhandled property "VersionId"
Sep 15 13:42:49 arch kernel: PM: suspend exit
Sep 15 13:42:49 arch bluetoothd[623]: Controller resume with wake event 0x0
Sep 15 13:42:49 arch systemd-sleep[27866]: System returned from sleep operation 'suspend'.
Sep 15 13:42:49 arch (o-bridge)[27871]: pam_unix(login:session): session opened for user username(uid=1000) by username(uid=0)
Sep 15 13:42:49 arch NetworkManager[622]: <info>  [1726400569.4004] device (proton0): state change: activated -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
Sep 15 13:42:31 arch wpa_supplicant[676]: nl80211: deinit ifname=wlp2s0 disabled_11b_rates=0
Sep 15 13:42:49 arch kernel: random: crng reseeded on system resumption
Sep 15 13:42:49 arch kernel: done.

This is an excerpt from earlier when I resumed from suspend-then-hibernate (also in reverse):

Sep 15 12:05:23 arch systemd-logind[625]: Operation 'suspend-then-hibernate' finished.
Sep 15 12:05:23 arch systemd[1]: Failed to start Manage sleep.target of user session.
Sep 15 12:05:23 arch systemd[1]: sleep@username.service: Failed with result 'exit-code'.
Sep 15 12:05:23 arch systemd[1]: sleep@username.service: Main process exited, code=exited, status=1/FAILURE
Sep 15 12:05:23 arch systemctl[23631]: See user logs and 'systemctl --user status sleep.target' for details.
Sep 15 12:05:23 arch systemctl[23631]: Failed to start sleep.target: Transport endpoint is not connected
Sep 15 12:05:23 arch systemd[1]: Stopped target Suspend; Hibernate if not used for a period of time.
Sep 15 12:05:23 arch systemd[1]: Reached target Suspend; Hibernate if not used for a period of time.
Sep 15 12:05:23 arch systemd[1]: Stopped target Sleep.
Sep 15 12:05:23 arch systemd[1]: Finished System Suspend then Hibernate.
Sep 15 12:05:23 arch systemd[1]: systemd-suspend-then-hibernate.service: Deactivated successfully.
Sep 15 12:05:23 arch systemd[1]: run-u561.service: Failed with result 'exit-code'.
Sep 15 12:05:23 arch kded6[964]: kf.networkmanagerqt: void NetworkManager::ConnectionPrivate::onPropertiesChanged(const QVariantMap&) Unhandled property "VersionId"
Sep 15 12:05:23 arch systemd[1]: run-u561.service: Main process exited, code=exited, status=1/FAILURE
Sep 15 12:05:23 arch systemd-sleep[23632]: Successfully thawed unit 'user.slice'.
Sep 15 12:05:23 arch (sd-pam)[23719]: pam_unix(login:session): session closed for user username
Sep 15 12:05:23 arch systemctl[23634]: Failed to start bus client: No such file or directory
Sep 15 12:05:23 arch kernel: PM: suspend exit
Sep 15 12:05:23 arch systemd-sleep[23632]: System returned from sleep operation 'suspend-then-hibernate'.
Sep 15 12:05:23 arch (o-bridge)[23634]: run-u561.service: Referenced but unset environment variable evaluates to an empty string: XDG_RUNTIME_DIR
Sep 15 12:05:23 arch (o-bridge)[23634]: pam_systemd(login:session): Failed to create session: Job 15486 for unit 'session-22.scope' failed with 'frozen'
Sep 15 12:05:23 arch systemd[1]: Failed to realize cgroups for queued unit user-1000.slice, ignoring: Device or resource busy
Sep 15 12:05:23 arch systemd[1]: user-1000.slice: Cannot realize cgroup for frozen unit.
Sep 15 12:05:23 arch systemd[1]: Failed to realize cgroups for queued unit session-2.scope, ignoring: Device or resource busy
Sep 15 12:05:23 arch systemd[1]: session-2.scope: Cannot realize cgroup for frozen unit.
Sep 15 12:05:23 arch systemd[1]: Failed to realize cgroups for queued unit user@1000.service, ignoring: Device or resource busy
Sep 15 12:05:23 arch systemd[1]: user@1000.service: Cannot realize cgroup for frozen unit.
Sep 15 12:05:23 arch systemd[1]: Cannot start frozen unit Session 22 of User username.
Sep 15 12:05:23 arch (o-bridge)[23634]: pam_unix(login:session): session opened for user username(uid=1000) by username(uid=0)
Sep 15 12:05:23 arch systemd[1]: Started Verify integrity of password and group files.
Sep 15 12:05:23 arch wpa_supplicant[676]: nl80211: deinit ifname=wlp2s0 disabled_11b_rates=0
Sep 15 12:05:23 arch wpa_supplicant[676]: wlp2s0: CTRL-EVENT-DSCP-POLICY clear_all
Sep 15 12:05:23 arch NetworkManager[622]: <info>  [1726394723.3918] device (proton0): state change: activated -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
Sep 15 12:05:23 arch wpa_supplicant[676]: wlp2s0: CTRL-EVENT-DSCP-POLICY clear_all
Sep 15 12:05:23 arch kernel: random: crng reseeded on system resumption
Sep 15 12:05:23 arch kernel: done.

What is the difference in how a user session or slice (what is that?) is handled between suspend and suspend-then-hibernate?

Offline

#3 2024-09-15 12:43:48

tillo.eaux
Member
Registered: 2024-09-14
Posts: 3

Re: [SOLVED] systemd sleep hook error after suspend-then-hibernate

So, since I figured my user session must be missing to start anything on the user level, I checked the wiki again and enabled user session lingering with

loginctl enable-linger username

That actually fixed my issue. After systemctl suspend-then-hibernate this is the relevant journal excerpt:

Sep 15 14:35:29 arch systemd[763]: Stopped target User session sleep.target.
Sep 15 14:35:29 arch systemd[763]: Reached target User session sleep.target.
Sep 15 14:35:29 arch NetworkManager[622]: <info>  [1726403729.5323] device (enp0s31f6): state change: unavail>
Sep 15 14:35:29 arch NetworkManager[622]: <info>  [1726403729.5322] manager: sleep: wake requested (sleeping:>
Sep 15 14:35:29 arch systemd-logind[625]: Operation 'suspend-then-hibernate' finished.
Sep 15 14:35:29 arch kernel: usb 1-9: new full-speed USB device number 33 using xhci_hcd
Sep 15 14:35:29 arch systemd[1]: Stopped target Suspend; Hibernate if not used for a period of time.
Sep 15 14:35:29 arch systemd[1]: Reached target Suspend; Hibernate if not used for a period of time.
Sep 15 14:35:29 arch systemd[1]: Stopped target Sleep.
Sep 15 14:35:29 arch plasmashell[997]: kf.networkmanagerqt: void NetworkManager::ConnectionPrivate::onPropert>
Sep 15 14:35:29 arch systemd[1]: Finished System Suspend then Hibernate.
Sep 15 14:35:29 arch systemd[1]: systemd-suspend-then-hibernate.service: Deactivated successfully.
Sep 15 14:35:29 arch systemd[1]: Started Session 34 of User username.
Sep 15 14:35:29 arch kded6[964]: kf.networkmanagerqt: void NetworkManager::ConnectionPrivate::onPropertiesCha>
Sep 15 14:35:29 arch systemd-sleep[33199]: Successfully thawed unit 'user.slice'.
Sep 15 14:35:29 arch plasmashell[997]: kf.networkmanagerqt: void NetworkManager::ConnectionPrivate::onPropert>
Sep 15 14:35:29 arch kded6[964]: kf.networkmanagerqt: void NetworkManager::ConnectionPrivate::onPropertiesCha>
Sep 15 14:35:29 arch bluetoothd[623]: Controller resume with wake event 0x0
Sep 15 14:35:29 arch kernel: PM: suspend exit
Sep 15 14:35:29 arch systemd-sleep[33199]: System returned from sleep operation 'suspend-then-hibernate'.
Sep 15 14:35:29 arch NetworkManager[622]: <info>  [1726403729.4010] device (proton0): state change: activated>
Sep 15 14:35:29 arch kernel: usb 1-9: USB disconnect, device number 32
Sep 15 14:35:29 arch kernel: random: crng reseeded on system resumption
Sep 15 14:35:29 arch kernel: done.

If anyone stumbles across this, I hope this helps and fixes whatever you're trying as well!

Offline

Board footer

Powered by FluxBB