Skip to content

Type=notify-reload units that don't send READY=1 after RELOADING=1 stay stuck reloading instead of timing out after TimeoutStartSec= seconds #37515

Closed

Description

@arianvp

systemd version the issue has been seen with

257.5

Used distribution

NixOS unstable

Linux kernel version used

6.6.89

CPU architectures issue was seen on

aarch64

Component

systemd

Expected behaviour you didn't see

After TimeoutStartSec seconds; the reload should time-out and systemctl reload should exit with a non-zero exit code.

As documented in https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#TimeoutStartSec=

Note that the start timeout is also applied to service reloads, regardless if implemented through ExecReload= or via the reload logic enabled via Type=notify-reload. If the reload does not complete within the configured time, the reload will be considered failed and the service will continue running with the old configuration. This will not affect the running service, but will be logged and will cause e.g. systemctl reload to fail.

Unexpected behaviour you saw

systemctl reload never returns and systemd keeps logging Reload operation timed out. Killing reload process. every TimeoutStartSec= seconds

Steps to reproduce the problem

I took the C code from https://www.freedesktop.org/software/systemd/man/latest/sd_notify.html#Standalone%20Implementations and removed the r = notify_ready(); line in the if (reloading) branch and then ran:

$ cc -o reproducer reproducer.c
$ sudo systemd-run --unit=reproducer --service-type=notify-reload -pTimeoutStartSec=10 ./reproducer\
$ sudo systemctl reload reproducer

Additional program output to the terminal or log subsystem illustrating the issue

$ journalctl -xefu reproducer.service
May 19 12:43:59 utm systemd[1]: Starting [systemd-run] /home/arian/Projects/reloading/reproducer...
May 19 12:43:59 utm systemd[1]: Started [systemd-run] /home/arian/Projects/reloading/reproducer.
May 19 12:44:21 utm systemd[1]: Reloading [systemd-run] /home/arian/Projects/reloading/reproducer...
May 19 12:44:31 utm systemd[1]: reproducer.service: Reload operation timed out. Killing reload process.
May 19 12:44:41 utm systemd[1]: reproducer.service: Reload operation timed out. Killing reload process.
May 19 12:44:51 utm systemd[1]: reproducer.service: Reload operation timed out. Killing reload process.
May 19 12:45:01 utm systemd[1]: reproducer.service: Reload operation timed out. Killing reload process.

Activity

  1. added
    bug 🐛
    on May 19, 2025
  2. changed the title [-]Type=notify-reload units that don't send READY=1 stay stuck reloading instead of timing out after `TimeoutStartSec=` seconds[/-] [+]Type=notify-reload units that don't send `READY=1` after `RELOADING=1` stay stuck reloading instead of timing out after `TimeoutStartSec=` seconds[/+] on May 19, 2025
  3. added this to the v258 milestone on May 19, 2025
  4. YHNdnzj commented on May 19, 2025

    @YHNdnzj
    Member

    Maybe @bluca was right after all (#33995 (comment)), that our state engine tries to handle Type=notify-reload + ExecReload= but currently in a vastly borked way. I'll do a refactor...

  5. bluca commented on May 19, 2025

    @bluca
    Member

    I'll do a refactor...

    Please wait until after #33995 as it's been almost a year of work by this point

  6. YHNdnzj commented on May 19, 2025

    @YHNdnzj
    Member

    Yeah, I'll just comment down what came to my mind now:

    service_enter_running() called from service_dispatch_timer() in SERVICE_RELOAD_NOTIFY state catches s->notify_state == NOTIFY_RELOADING again and enters an infinite loop -> service_enter_reload_by_notify().

    We have a variety of possible modes of operation and it gets hairy without explicit ordering:

    1. Type=notify-reload protocol
    2. Main process issuing RELOADING=1 and READY=1 spontaneously
    3. ExecReload=
    4. 1 + 2/3: this one is very problematic as it is now, as we signal the main process and directly transition to SERVICE_RELOAD with ExecReload= for 3, or enter SERVICE_RELOAD_NOTIFY directly for 2. In either case, service_enter_running() can't properly distinguish a deferred NOTIFY_RELOADING from timing out notify-reload protocol.

    To make the semantics clear, ExecReload= should probably be executed first and the ReloadSignal= is sent only when that finishes. Then, introduce ExecReloadPost= a la ExecStopPost= to carry out post-reload businesses.

  7. YHNdnzj commented on May 19, 2025

    @YHNdnzj
    Member

    This of course is going to become a breaking change, but nevertheless we should clean things up thoroughly and as discussed (thankfully) not so many people are using a mix of Type=notify-reload for now.

  8. self-assigned this
    on May 19, 2025
  9. YHNdnzj commented on May 19, 2025

    @YHNdnzj
    Member

    And if we get RELOADING=1 during ExecReload= execution already, don't try to signal the main process anymore.

  10. bluca commented on May 20, 2025

    @bluca
    Member

    I'll do a refactor...

    Please wait until after #33995 as it's been almost a year of work by this point

    Ok that's merged now, so all yours!

    As mentioned many times there I really think mixing these workflows as a supported feature would be a mistake, as it makes everything so much more complicated, and literally nobody uses it. As you have found out, notify+execreload really do not work together. But if you want to spend your time on it, I certainly won't stop you. Just don't break my stuff ;-)

  11. modified the milestones: v258, v259 on Jul 8, 2025
  12. added a commit that references this issue on Oct 20, 2025
    0a097b7
  13. 12 remaining items

  14. added 6 commits that reference this issue on Oct 30, 2025
    2bdfd7e
    7cad59b
    e411d43
    5fb8387
    b03e1b0
    ca86581
  15. added a commit that references this issue on Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛pid1

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions