Bug 2240171 - Timer with WakeSystem=true doesn't count down in system suspend
Summary: Timer with WakeSystem=true doesn't count down in system suspend
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 39
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL: https://github.com/systemd/systemd/is...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-09-22 08:31 UTC by navrasy+fedora
Modified: 2023-09-26 08:36 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-26 08:36:37 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github systemd systemd issues 29245 0 None open Timer with WakeSystem=true doesn't count down in system suspend 2023-09-26 08:36:36 UTC

Description navrasy+fedora 2023-09-22 08:31:35 UTC
The transient system timer created using systemd-run doesn't count down during suspend, which led to the command not being executed at the expected time after system wakes up. (System wakes at the specified time correctly.) However the timer properties specified do exist in the timer file created, so it might not be specific to systemd-run.
The additional information section demonstrates the case where the timer doesn't elapse after system wakes up, as it's easiest to show without ambiguity (delays in suspend and entering command).

For more context, see:
https://github.com/systemd/systemd/issues/29245
https://discussion.fedoraproject.org/t/systemd-timer-with-wakesystem-true-not-counting-down-when-system-is-suspended/90261
https://unix.stackexchange.com/questions/757134/systemd-timer-with-wakesystem-true-not-counting-down-during-suspend
https://askubuntu.com/questions/1356413/systemd-timer-with-wakesystem-true-waiting-for-twice-the-specified-time

The report was closed as non-issue, so I'm not really certain it's a bug, but it does seem to be...

P.S. The original command uses GUI app to visually indicate when the command is run, but introduced the ambiguity of user session, so bash is used instead.

Reproducible: Always

Steps to Reproduce:
1.systemd-run --system --on-active="1m" --timer-property=WakeSystem=true --timer-property=AccuracySec=1s bash
2.systemctl suspend
3.Wake the system after 20s
4.systemctl list-timers --all
5.Observe timer has not counted down by 20s

Alternatively:
At step 3: Wait 1min for system to wake up by itself
At step 5: Observed the timer has not elapsed
Actual Results:  
Timer does not count down in suspend. Command is not executed when system wakes from suspend but after the remaining time of the frozen timer elapses during wake.

Expected Results:  
System wakes up and executes the command after timer with WakeSystem=true elaspes.

$ systemd-run --system --on-active="1m" --timer-property=WakeSystem=true --timer-property=AccuracySec=1s bash
Running timer as unit: run-u966.timer
Will run service as unit: run-u966.service
$ timedatectl
               Local time: Fri 2023-09-22 08:12:26 UTC
           Universal time: Fri 2023-09-22 08:12:26 UTC
                 RTC time: Fri 2023-09-22 08:12:26
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
$ systemctl list-timers --all
NEXT                             LEFT LAST                           PASSED UNIT                         ACTIVATES                     
Fri 2023-09-22 08:13:24 UTC       55s -                                   - run-u966.timer               run-u966.service

8 timers listed.
$ systemctl suspend
$ timedatectl
               Local time: Fri 2023-09-22 08:13:33 UTC
           Universal time: Fri 2023-09-22 08:13:33 UTC
                 RTC time: Fri 2023-09-22 08:13:33
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no
$ systemctl list-timers --all
NEXT                             LEFT LAST                           PASSED UNIT                         ACTIVATES                     
Fri 2023-09-22 08:14:16 UTC       41s -                                   - run-u966.timer               run-u966.service

8 timers listed.


Note You need to log in before you can comment on or make changes to this bug.