[nsd-users] NSD as slave leaves a child process behind

Ville Mattila vmattila at csc.fi
Tue Sep 15 12:31:05 UTC 2009


Hi,

On Tue, 15 Sep 2009, Matthijs Mekking wrote:

> It may look like a child process is not killed after a reload, but isn't
> the process you are referring to (20933), the xfrd process? By default,
> NSD has three processes: a parent process, a child process (answering
> queries) and a xfrd process. During a NSD reload, the xfrd process
> should not be killed, merely the communication channels with the parent
> are updated.

I see.  The process 20933 sure looks like xfrd, even though it's CMD
label in 'ps -ef' output is nsd.  (BTW, is there a BSD's setproctitle()
equivalent in Linux that NSD perhaps could use to indicate the roles of
each process?)

Perhaps this is irrelevant, but one thing that stands out still is how
come the xfrd process becomes permanently the owner of all NSD listen
sockets (as shown by 'netstat -anp' in my original message) after reload
and not the main process?

> Of course, if you run nsdc stop, no processes should be kept alive. Is
> this the case?

Yes.  'nsdc stop' leaves xfrd process running and returns ok.

> What does nsdc stop output?

Nothing really:

% sudo /usr/sbin/nsdc -c /v/net/ns-secondary.funet.fi/etc/nsd/nsd-isar.conf stop
% echo $?
0

> Notice that nsdc stop && nsdc start differs from nsdc restart. The
> latter attempts to start nsd after all processes are shut down.

Yes I've noticed..   But using 'nsdc restart' makes no difference in this
case, because it only makes sure the main nsd process (main = the
one whose pid is stored in pidfile and used from there by nscd) has died.

Could you please consider either of the following patches attached inline
for nsdc.  They could be useful because I think many users want
to run 'nsdc patch' every time NSD is stopped and that seems to cause
some problems also:
   FreeBSD Ports bug report 'dns/nsd: fix race when stopping nsd'
   http://www.freebsd.org/cgi/query-pr.cgi?pr=130294

Option 1: Make 'nsdc stop' use do_controlled_stop() instead of do_stop():

---8<------8<------8<------8<---
--- nsdc.sh.in.orig     2009-09-09 12:10:55.000000000 +0300
+++ nsdc.sh.in  2009-09-09 12:15:05.000000000 +0300
@@ -356,7 +356,7 @@
         fi
         ;;
  stop)
-       do_stop
+       do_controlled_stop
         ;;
  stats)
         signal "USR1"
---8<------8<------8<------8<---

Option 2: Do not change 'nsdc stop' implementation, but let users run
'nsdc controlled-stop' if they wish to make sure nsd main process has
exited before nsdc returns:

---8<------8<------8<------8<---
--- nsdc.sh.in.orig     2009-09-15 14:45:10.000000000 +0300
+++ nsdc.sh.in  2009-09-15 14:47:51.000000000 +0300
@@ -73,6 +73,7 @@
         echo "commands:"
         echo "  start           Start nsd server."
         echo "  stop            Stop nsd server."
+       echo "  controlled-stop Stop nsd server and try to make sure it
really exits."
         echo "  reload          Nsd server reloads database file."
         echo "  rebuild         Compile database file from zone files."
         echo "  restart         Stop the nsd server and start it again."
@@ -358,6 +359,9 @@
  stop)
         do_stop
         ;;
+controlled-stop)
+       do_controlled_stop
+       ;;
  stats)
         signal "USR1"
         ;;
---8<------8<------8<------8<---

Regards,
Ville Mattila

-- 
Ville Mattila, System Specialist, Funet network, CSC
PO Box 405, FIN-02101 Espoo, Finland, fax +358 9 457 2302
CSC is the Finnish IT Center for Science, http://www.csc.fi/, email:
ville.mattila at csc.fi



More information about the nsd-users mailing list