Repository navigation
core/service: reload fixlets - #39376
Conversation
838b2ee to
074cbac
Compare
074cbac to
c7c7e57
Compare
c7c7e57 to
9ef3ca5
Compare
|
Updated the man page now. Should be complete. PTAL! |
yuwata
left a comment
There was a problem hiding this comment.
Could you add test cases for the original issue and the new feature?
| readonly a(sasbttttuii) ExecReloadPost = [...]; | ||
| @org.freedesktop.DBus.Property.EmitsChangedSignal("invalidates") |
There was a problem hiding this comment.
That's questionable we should introduce ExecRelaodPost (non-Ex version)...
There was a problem hiding this comment.
Yeah, annoyed me for a while too. But our internal logic determines the type based on whether the property ends with "Ex", and it creates more churn to restructure all that...
There was a problem hiding this comment.
hmm, but why not keep just the Ex version, and kill the non-Ex version?
There was a problem hiding this comment.
Actually we can't - bus_append_exec_command tries to patch Ex back to non-Ex properties if no new exec flags are used :/
I'll just add tests for the issue for now. I'd like @poettering 's blessing before doing tedious work for ExecReloadPost= |
9ef3ca5 to
3d713d0
Compare
52c0bbb to
9e96073
Compare
| /* If notify state is still in dangling NOTIFY_RELOADING, reset it so service_enter_running() | ||
| * won't get confused (see #37515) */ | ||
| if (s->notify_state == NOTIFY_RELOADING) | ||
| s->notify_state = _NOTIFY_STATE_INVALID; |
There was a problem hiding this comment.
i wonder if this is racy? i.e. let's say an ExecReload= cmd fails with an unclean exit code, and we now end up here, but in the time the cmd failed and we come here the user already tried to reload the service another way, so we get another RELOADING=1 here. We'll now ignore htat, and miss the state change.
we could probably make this airtight, by only resetting things here if the timestamp of the msg predate the actual state change to reloading state?
or am i overthinking this?
There was a problem hiding this comment.
My conclusion so far is that ExecReload= is inherently racy. We simply don't know if the RELOADING=1 the main process sent us is due to ExecReload= doing its thing or from extrinsic event. It could be sent before executor handoff - sure we have handoff timestamps now but that's just part of the problem.
To main goal of this patchset is to make sure ExecReload= and ReloadSignal= work together consistently. Previously some states in between are ill-formed, now ExecReload= can be used for e.g. pre-reload businesses (config check?) as well as signaling the actual reload. If it's the former, the notify-reload protocol fires which is not racy; for the latter it's all about creativity ;)
|
i am not totally against the ExecReloadPost= stuff, but would like to hear some usecase. Looks great otherwise. |
|
Hmm, the idea is that previously ExecReload= is invoked in parallel with ReloadSignal=, so the custom reload command can in theory do post-reload tasks. That would be invalidated if ExecReload= is brought upfront. I don't have any concrete examples in mind. Happy to drop the addition of ExecReloadPost=. I was just trying to make the impact of last commit more visible. |
9e96073 to
e411d43
Compare
They don't take pointers, hence are eligible for stronger guarantees.
The impl is directly visible to the compiler so it can apply all sorts of optimizations wherever it sees fit. And with the previous commit they are actually "const".
reload_begin_usec is a barrier for determining whether RELOADING=1 came after the main process got signaled, unrelated to refreshing.
Not sure why dfdeb0b touched it at all.
{service,socket}_unwatch_control_pid() -> unit_unwatch_pidref_done()
is unconditionally called everywhere.
If we're changing state anyways, service_set_state() -> unit_notify() will take care of dbus signaling for us.
We usually use _INVALID enum value as placeholder. While at it, reset notify_state in service_enter_dead() for consistency.
This really should be persisted across daemon-reload since it might contain deferred state transitions.
No functional change, preparation for later changes.
We don't permit state transition from STOPPING back to RUNNING, hence refrain from resetting notify_state too.
…d ExecReloadPost=
When Type=notify-reload got introduced, it wasn't intended to be
mutually exclusive with ExecReload=. However, currently ExecReload=
is immediately forked off after the service main process is signaled,
leaving states in between essentially undefined. Given so broken
it is I doubt any sane user is using this setup, hence I took a stab
to rework everything:
1. Extensions are refreshed (unchanged)
2. ExecReload= is forked off without signaling the process
3a. If RELOADING=1 is sent during the ExecReload= invocation,
we'd refrain from signaling the process again, instead
just transition to SERVICE_RELOAD_NOTIFY directly and
wait for READY=1
3b. If not, signal the process after ExecReload= finishes
(from now on the same as Type=notify-reload w/o ExecReload=)
4. To accomodate the use case of performing post-reload tasks,
ExecReloadPost= is introduced which executes after READY=1
The new model greatly simplifies things, as no control processes
will be around in SERVICE_RELOAD_SIGNAL and SERVICE_RELOAD_NOTIFY
states.
See also: systemd#37515 (comment)
e411d43 to
ca86581
Compare
Fixes #37515