Skip to contentSkip to conversation

rpc-statd.service: Stop rpcbind and rpc.stat in an exit race

PATCH In review Steve Dickson 2 participants 4 messages Jul 27, 2022 – Aug 1, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpc-statd.service: Stop rpcbind and rpc.stat in an exit race

From: Benjamin Coddington <[email protected]>

When systemctl stop rpcbind.socket is run, the dependency means that systemd first sends SIGTERM to rpcbind, then sigterm to rpc.statd.

On SIGTERM, rpcbind tears down /var/run/rpcbind.sock. However, rpc-statd on SIGTERM attempts to unregister from rpcbind

systemd needs to wait for rpc.statd to exit before sending SIGTERM to rpcbind

---
 systemd/rpc-statd.service | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
systemd/rpc-statd.service +1 -1
index 095629f2..392750da 100644
@@ -5,7 +5,7 @@ Conflicts=umount.target
 Requires=nss-lookup.target rpcbind.socket
 Wants=network-online.target
 Wants=rpc-statd-notify.service
-After=network-online.target nss-lookup.target rpcbind.socket
+After=network-online.target nss-lookup.target rpcbind.service
 
 PartOf=nfs-utils.service
 IgnoreOnIsolate=yes
Signature · 1 line
2.34.1
#1 lore raw
Quoted 32 lines · Steve Dickson

From: Benjamin Coddington <[email protected]>

When systemctl stop rpcbind.socket is run, the dependency means that systemd first sends SIGTERM to rpcbind, then sigterm to rpc.statd.

On SIGTERM, rpcbind tears down /var/run/rpcbind.sock. However, rpc-statd on SIGTERM attempts to unregister from rpcbind

systemd needs to wait for rpc.statd to exit before sending SIGTERM to rpcbind

---
 systemd/rpc-statd.service | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
systemd/rpc-statd.service +1 -1
index 095629f2..392750da 100644
@@ -5,7 +5,7 @@ Conflicts=umount.target
 Requires=nss-lookup.target rpcbind.socket
 Wants=network-online.target
 Wants=rpc-statd-notify.service
-After=network-online.target nss-lookup.target rpcbind.socket
+After=network-online.target nss-lookup.target rpcbind.service
 
 PartOf=nfs-utils.service
 IgnoreOnIsolate=yes
Signature · 1 line
2.34.1

Hey Steve - thanks for patchifying this - I should have sent a proper patch, but the reason I didn't is that I didn't understand why we have the rpcbind.socket unit, and why that unit isn't sufficient to enforce the ordering.

I don't remember the history. Will changing the After= here create a problem where rpcbind.service is up, but the socket isn't there yet, and then rpc.statd comes up and can't find the socket?

Ben

#2 lore raw

Hey!

Quoted 30 lines · Benjamin Coddington
Quoted 28 lines · Steve Dickson

From: Benjamin Coddington <[email protected]>

When systemctl stop rpcbind.socket is run, the dependency means that systemd first sends SIGTERM to rpcbind, then sigterm to rpc.statd.

On SIGTERM, rpcbind tears down /var/run/rpcbind.sock. However, rpc-statd on SIGTERM attempts to unregister from rpcbind

systemd needs to wait for rpc.statd to exit before sending SIGTERM to rpcbind

---
  systemd/rpc-statd.service | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
systemd/rpc-statd.service +1 -1
index 095629f2..392750da 100644
@@ -5,7 +5,7 @@ Conflicts=umount.target
  Requires=nss-lookup.target rpcbind.socket
  Wants=network-online.target
  Wants=rpc-statd-notify.service
-After=network-online.target nss-lookup.target rpcbind.socket
+After=network-online.target nss-lookup.target rpcbind.service
 
Quoted 9 lines
Quoted 4 lines
systemd/rpc-statd.service +0 -0
  PartOf=nfs-utils.service
  IgnoreOnIsolate=yes
Signature · 1 line
2.34.1

Hey Steve - thanks for patchifying this - I should have sent a proper patch, but the reason I didn't is that I didn't understand why we have the rpcbind.socket unit, and why that unit isn't sufficient to enforce the ordering.

The whole idea be the rpcbind.socket unit was the Fedora or systemd people did not want daemons running when the are not needed. So they came up with "on-demand" daemons, meaning a daemon would be started when a process connect to the socket.

Quoted 4 lines

I don't remember the history. Will changing the After= here create a problem where rpcbind.service is up, but the socket isn't there yet, and then rpc.statd comes up and can't find the socket?

I don't think so... That After= line, in rpc-statd.service, was a result of a bug fix I did for bz1419351 (commit 09e5c6c2a3). Why I used rpcbind.socket instead of rpcbind.service is not clear, since rpcbind.service Requires rpcbind.socket.

So I'm thinking this is a valid bug fix... Thanks
for doing the debugging!!!

steved.

#3 lore raw
In reply to Steve Dickson
Quoted 16 lines · Steve Dickson

Subject:
[PATCH] rpc-statd.service: Stop rpcbind and rpc.stat in an exit race From:
Steve Dickson <[email protected]>
Date:
7/27/22, 1:24 PM

To:
Linux NFS Mailing list <[email protected]>

From: Benjamin Coddington<[email protected]>

When systemctl stop rpcbind.socket is run, the dependency means that systemd first sends SIGTERM to rpcbind, then sigterm to rpc.statd.

Quoted 8 lines

On SIGTERM, rpcbind tears down /var/run/rpcbind.sock. However, rpc-statd on SIGTERM attempts to unregister from rpcbind

systemd needs to wait for rpc.statd to exit before sending SIGTERM to rpcbind

Committed...

steved.

Quoted 19 lines
---
  systemd/rpc-statd.service | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
systemd/rpc-statd.service +1 -2
index 095629f2..392750da 100644
@@ -5,7 +5,7 @@ Conflicts=umount.target
  Requires=nss-lookup.target rpcbind.socket
  Wants=network-online.target
  Wants=rpc-statd-notify.service
-After=network-online.target nss-lookup.target rpcbind.socket
+After=network-online.target nss-lookup.target rpcbind.service
 
  PartOf=nfs-utils.service
  IgnoreOnIsolate=yes
-- 2.34.1