SDP-575

roadkills_r_us (roadkills_r_us)
roadkills_r_us created this job , modified by C. Thomas Tyler
Closed
The stop_p4d() function reports 'missing server.pid' error with systemd.

On systems on which systemd is used, there is some healthily paranoid
logic in the stop_p4d() function in backup_functions.sh. On systems
that use systemd, stop_p4d first stops the server using the systemd
method.  That sets the systemd status correctly if the service was
running and systemd was able to shut it down.

However, if the service was not started with systemd, then then the
systemd status mechanism will not be aware that e p4d service is
running.  Worse, if systemd is asked to stop a service, and it
doesn't know it was running due to the faulty status indication, it
will not attempt to call the underlying init script to stop the
service, and thus the service will be left running. This could
contribute to database and/or journal corruption in a simple
reboot situation.

Because systemd is thus not terribly reliable at shutting down
services, the SDP script calls the underlying p4d init script
directly after trying it the systemd way, to be darn sure p4d is
well and truly stopped and thus prevent any bad outcomes.

It is this second call that generates the error about the missing
server.pid file, since p4d might already down at that point (but
only if the systemd call succeeded).

So, while the SDP init mechanism will stop p4d reliably, it
generates scary error messages that show up in log files, which
can be disconcerting, and hence this is a bug.

The desired behavior would be to preserve the assurance that p4d
is stopped reliably (regardless of whether the systemd or SysV init
mechanism is used), but avoid generating scary error messages in
the log when the shutdown occurs normally.
27092Refined logic so that if a shutdown is attempted and there is no
server.pid file, the 'fallback/2nd pass/assured shutdown' logic
to do a 'p4 admin stop' files only if a 'p4 info' command can
reach the server. Otherwise, the stop command is silently
ignored.

Refined exit code handling and fixed log interaciton issues.
Fixed issue with systemd status not indicating successful startup.

The systemd unit files now specify the Type as simple rather than
forking, and defer to systemd to handle the forking. When systemd is
used, the -d/--daemonsafe flags are removed from service start commands
for p4p/p4broker/p4d, and for p4dtg the & is removed so the process is
not started in the background. For compatibility with non-systemd systems,
the -d/--daemonsafe flags are still applied when systemd is not in use.

With this change, systemd's concept of whether the service is running should
now be reliable.  If you try to start without using systemd on a system for
which a systemd unit file exists, an error is displayed -- a big, hopefully
useful and informative error message.
27109Refined logic so that if a shutdown is attempted and there is no
server.pid file, the 'fallback/2nd pass/assured shutdown' logic
to do a 'p4 admin stop' files only if a 'p4 info' command can
reach the server. Otherwise, the stop command is silently
ignored.

Refined exit code handling and fixed log interaciton issues.
Fixed issue with systemd status not indicating successful startup.

The systemd unit files now specify the Type as simple rather than
forking, and defer to systemd to handle the forking. When systemd is
used, the -d/--daemonsafe flags are removed from service start commands
for p4p/p4broker/p4d, and for p4dtg the & is removed so the process is
not started in the background. For compatibility with non-systemd systems,
the -d/--daemonsafe flags are still applied when systemd is not in use.

With this change, systemd's concept of whether the service is running should
now be reliable.  If you try to start without using systemd on a system for
which a systemd unit file exists, an error is displayed -- a big, hopefully
useful and informative error message.

#review
  • Details
  • Comments -
Status
Closed
Project
perforce-software-sdp
Severity
C
Reported By
roadkills_r_us
Reported Date
Modified By
C. Thomas Tyler
Modified Date
Owned By
tom_tyler
Dev Notes
Fixing this may require that p4d_base exit codes be reviewed.
Component
core-unix
Type
Bug