Skip to content

restarting service and socket triggers failure #13271

Closed

Description

@mbiebl

Version: 241-7

I originally filed this issue downstream as https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=933268 against the rpcbind package, but somehow this smells like it could be a systemd issue.

The rpcbind package ships the following two units:

$ systemctl cat rpcbind.service rpcbind.socket
# /lib/systemd/system/rpcbind.service
[Unit]
Description=RPC bind portmap service
Documentation=man:rpcbind(8)
DefaultDependencies=no
RequiresMountsFor=/run/rpcbind

# Make sure we use the IP addresses listed for
# rpcbind.socket, no matter how this unit is started.
Requires=rpcbind.socket
After=systemd-tmpfiles-setup.service
Wants=remote-fs-pre.target rpcbind.target
Before=remote-fs-pre.target rpcbind.target

[Service]
Environment="OPTIONS=-w"
ExecStart=/sbin/rpcbind -f $OPTIONS
EnvironmentFile=-/etc/rpcbind.conf
EnvironmentFile=-/etc/default/rpcbind
Type=notify
KillMode=process
Restart=on-failure

[Install]
Also=rpcbind.socket
WantedBy=multi-user.target

# /lib/systemd/system/rpcbind.socket
[Unit]
Description=RPCbind Server Activation Socket
DefaultDependencies=no

[Socket]
ListenStream=/run/rpcbind.sock

# RPC netconfig can't handle ipv6/ipv4 dual sockets
BindIPv6Only=ipv6-only
ListenStream=0.0.0.0:111
ListenDatagram=0.0.0.0:111
ListenStream=[::]:111
ListenDatagram=[::]:111

[Install]
WantedBy=sockets.target

Both are running

$ systemctl status rpcbind.service rpcbind.socket 
● rpcbind.service - RPC bind portmap service
   Loaded: loaded (/lib/systemd/system/rpcbind.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-08-06 09:54:14 CEST; 1s ago
     Docs: man:rpcbind(8)
 Main PID: 14866 (rpcbind)
    Tasks: 1 (limit: 4915)
   Memory: 656.0K
   CGroup: /system.slice/rpcbind.service
           └─14866 /sbin/rpcbind -f -w

Aug 06 09:54:14 pluto systemd[1]: Starting RPC bind portmap service...
Aug 06 09:54:14 pluto systemd[1]: Started RPC bind portmap service.

● rpcbind.socket - RPCbind Server Activation Socket
   Loaded: loaded (/lib/systemd/system/rpcbind.socket; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-08-06 09:54:08 CEST; 8s ago
   Listen: /run/rpcbind.sock (Stream)
           0.0.0.0:111 (Stream)
           0.0.0.0:111 (Datagram)
           [::]:111 (Stream)
           [::]:111 (Datagram)
    Tasks: 0 (limit: 4915)
   Memory: 188.0K
   CGroup: /system.slice/rpcbind.socket

Aug 06 09:54:08 pluto systemd[1]: Listening on RPCbind Server Activation Socket.

Now, trying to restart both will (sometimes) trigger this error:

$ sudo systemctl restart rpcbind.service rpcbind.socket 
$ sudo systemctl restart rpcbind.service rpcbind.socket 
Job for rpcbind.socket failed.
See "systemctl status rpcbind.socket" and "journalctl -xe" for details.
A dependency job for rpcbind.service failed. See 'journalctl -xe' for details.
michael@pluto:~$ systemctl status rpcbind.service rpcbind.socket 
● rpcbind.service - RPC bind portmap service
   Loaded: loaded (/lib/systemd/system/rpcbind.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-08-06 09:54:59 CEST; 3s ago
     Docs: man:rpcbind(8)
 Main PID: 14904 (rpcbind)
    Tasks: 1 (limit: 4915)
   Memory: 496.0K
   CGroup: /system.slice/rpcbind.service
           └─14904 /sbin/rpcbind -f -w

Aug 06 09:54:59 pluto systemd[1]: Starting RPC bind portmap service...
Aug 06 09:54:59 pluto systemd[1]: Dependency failed for RPC bind portmap service.
Aug 06 09:54:59 pluto systemd[1]: rpcbind.service: Job rpcbind.service/start failed with result 'dependency'.

● rpcbind.socket - RPCbind Server Activation Socket
   Loaded: loaded (/lib/systemd/system/rpcbind.socket; enabled; vendor preset: enabled)
   Active: inactive (dead) since Tue 2019-08-06 09:54:59 CEST; 3s ago
   Listen: /run/rpcbind.sock (Stream)
           0.0.0.0:111 (Stream)
           0.0.0.0:111 (Datagram)
           [::]:111 (Stream)
           [::]:111 (Datagram)

Aug 06 09:54:57 pluto systemd[1]: Listening on RPCbind Server Activation Socket.
Aug 06 09:54:59 pluto systemd[1]: rpcbind.socket: Succeeded.
Aug 06 09:54:59 pluto systemd[1]: Closed RPCbind Server Activation Socket.
Aug 06 09:54:59 pluto systemd[1]: Stopping RPCbind Server Activation Socket.
Aug 06 09:54:59 pluto systemd[1]: rpcbind.socket: Socket service rpcbind.service already active, refusing.
Aug 06 09:54:59 pluto systemd[1]: Failed to listen on RPCbind Server Activation Socket.

As you can see, it doesn't happen all the time, but it's relatively easy to trigger. This looks like there is a race condition somewhere.
I tried with v232 on a Debian stretch system and was not able to reproduce the issue there.

Activity

  1. Werkov commented on Aug 7, 2019

    @Werkov
    Contributor

    Yes, there is a race. Multiple jobs issued by systemctl call aren't grouped in the same transaction. I wonder why you didn't see that in v232 though.

    BTW is this causing troubles? Would systemctl stop rpcbind.service && systemctl restart rpcbind.socket work for you?

    Edit: systemctl restart rpcbind.socket should suffice (thanks to Requires=rpcbind.socket).

  2. mbiebl commented on Aug 7, 2019

    @mbiebl
    ContributorAuthor

    If it's a race condition, it's likely I simply didn't hit it on my test system. But I was informed by the maintainer of rpcbind that this problem apparently already existed during stretch upgrades, i.e. with v232.

  3. mbiebl commented on Aug 7, 2019

    @mbiebl
    ContributorAuthor

    BTW is this causing troubles?

    It is. See the referenced Debian bug report where the upgrade fails because it uses
    systemctl restart rpcbind.service rpcbind.socket

  4. added
    bug 🐛
    on Sep 26, 2019
  5. poettering commented on Aug 31, 2020

    @poettering
    Member

    Yeah, this is a race, we don't turn this into a single transaction, but two. To change that is tracked in #8102, which means I guess we can close this issue, since there's no need to track this twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions