systemd Restart=on-failure and StartLimitBurst on CentOS without deduplication of writes
0 reputation · 07 Mar 2021, 09:44 UTC
Goal is to keep a CentOS service supervised by systemd with Restart=on-failure and RestartSec, and rate-limited by StartLimitIntervalSec and StartLimitBurst, so PID1 relaunches the unit after a failure.
The constraint is a non-idempotent side effect. The unit may append to a file, enqueue a job, or post to an API before exiting non-zero. Systemd supervision is process-oriented: it reacts to exit status, signals and cgroup events, but has no record of whether a previous invocation committed an external write.
The permission boundary is unclear. PID1 restarts the unit as root subject to User=, Group= and sandboxing directives, but it cannot decide whether a partially completed operation is safe to retry. Exactly-once semantics is the missing constraint, and systemd documentation describes restart policy, not transaction deduplication.
Does systemd provide any documented option to suppress or condition a restart based on a prior side effect, and where does the responsibility for retry safety lie between PID1 and the service wrapper? Is the interaction of RestartSec with StartLimitBurst treated identically on CentOS Stream and end-of-life CentOS Linux systemd versions?