Subject: bug#46712: Removed service extensions are not unloaded from Shepherd upon reconfiguring

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 22 Feb 2021 15:37:25 -0500

Hello Guix!

After fixing https://issues.guix.gnu.org/36117 and reconfiguring my
system with it, one thing bothered me: the 'ps -eFww | grep guix-daemon'
would still show something like:

--8<---------------cut here---------------start------------->8---
root     32139     1  0  3434  3504   0 10:28 ?        00:00:00
/gnu/store/rqif4yxa6ny4nxrdq6whnva2r089jm0c-guix-1.2.0-13.a53f711/bin/guix-daemon
11422               guixbuild --max-silent-time 0 --timeout 0
--log-compression none --discover=no --substitute-urls
http://127.0.0.1:8080 https://ci.guix.gnu.org --max-jobs=4
--chroot-directory
/gnu/store/mmhimfwmmidf09jw1plw3aw1g1zn2nkh-bash-static-5.0.16
--chroot-directory
/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31
--chroot-directory
/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib
--chroot-directory
/gnu/store/zzkly5rbfvahwqgcs7crz0ilpi7x5g5p-ncurses-6.2
--chroot-directory
/gnu/store/z1iyvbvnkd7zkjxsx157n6qx2iwzxq7p-alsa-lib-1.2.4
--chroot-directory
/gnu/store/yg1qj1kzf7wwkvls8n5p9cjq96xrwx03-libcap-ng-0.8.2
--chroot-directory
/gnu/store/xwl0p4m34bcan0v9vkjkyzwi6znsv4dm-pixman-0.38.4
--chroot-directory
/gnu/store/zqr3v3czlqlsamlp5kvvf15q0h13g6jn-orc-0.4.32
--chroot-directory
/gnu/store/vfr3y4j0hqrf2vg8cdb7999604gg6xwc-libjpeg-turbo-2.0.5
--chroot-directory
/gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11
--chroot-directory
/gnu/store/pwcp239kjf7lnj5i4lkdzcfcxwcfyk72-bash-minimal-5.0.16
--chroot-directory
/gnu/store/q5s876bc5yghh6na3ibvfxlvj6fcj17l-mit-krb5-1.18
--chroot-directory
/gnu/store/jdsrgf5k9xys81z4mwnwm94mk73h160h-opus-1.3.1
--chroot-directory
/gnu/store/knp4rkdm39ph4brkbzsp07q248nfffi1-readline-8.0.4
--chroot-directory
/gnu/store/imh5xxqw10dql4crlngbbjh4r24raf4j-expat-2.2.9
--chroot-directory
/gnu/store/bw15z9kh9c65ycc2vbhl2izwfwfva7p1-libffi-3.3
--chroot-directory
/gnu/store/a9f7wmc75hbpg520phw9z4l9asm3qvsw-bzip2-1.0.8
--chroot-directory
/gnu/store/9h9153akbd6g2520mcl2d0vgbvyfi5qm-openssl-1.1.1i
--chroot-directory /gnu/store/9860f1abqj8wjjnwl8a9v54pdcc3bhgf-xz-5.2.4
--chroot-directory
/gnu/store/807c6g9xqrxdjyhm8wm1r6jjjmc8q4vs-sqlite-3.31.1
--chroot-directory
/gnu/store/5yjp2rlvhjbxn02w5vby35ymrs0fmcjb-gdbm-1.18.1
--chroot-directory
/gnu/store/rz42ba0my9vrgbkjpkzr2drmnjk5ah50-python-3.8.2
--chroot-directory /gnu/store/k0aqiy7yx8n28dvm3f0a04ka5sd8y950-pcre-8.44
--chroot-directory
/gnu/store/8nh0hbrr8iaz6qkwavcnzi0824f3xb68-libsepol-3.0
--chroot-directory
/gnu/store/mp73dgyk8r3nhzk4dyx0iyvak9nk8y4n-libselinux-3.0
--chroot-directory
/gnu/store/a45p39mgqvfd8kjwibyr0q42k1mw7gmf-util-linux-2.35.1-lib
--chroot-directory
/gnu/store/h7sy4hr7arjknbyy1aq0xwv6fksnzw9n-libxau-1.0.9
--chroot-directory
/gnu/store/cqwj25wxzzs8frz5c9alqns24bcfspqz-libbsd-0.10.0
--chroot-directory
/gnu/store/6cdl970wcv4jhvpgbh8sdj54a5gwhmwj-libxdmcp-1.1.3
--chroot-directory
/gnu/store/3x6y8kpbwjmzpndjfhdbn654g7dm85cp-libxcb-1.14
--chroot-directory
/gnu/store/fx3979c88s9yxdbchyf36qryawgzpwb5-libx11-1.6.10
--chroot-directory
/gnu/store/12ws549m1rj0ca3ara0fxvnms7yi6bpx-dbus-1.12.16
--chroot-directory
/gnu/store/4vmhbc31cpbnlw3c96kcc094ihmaf7dv-glib-2.62.6
--chroot-directory
/gnu/store/9if71w58d5mkxfxyc7fpz289qssnkqsv-gstreamer-1.18.2
--chroot-directory
/gnu/store/yrb8dfcf1ay6wfaqcr3y9k4bb94cyxld-cdparanoia-10.2
--chroot-directory
/gnu/store/qrs0p8j3wq6q5a4dm0ndjdavk9gyal5q-libxext-1.3.4
--chroot-directory
/gnu/store/krpyb0zi700dcrg9cc8932w4v0qivdg9-pkg-config-0.29.2
--chroot-directory
/gnu/store/i8h2pcxqdq07ijm3ibkka8f4smn1w48v-bzip2-1.0.8
--chroot-directory
/gnu/store/3x2kak8abb6z2klch72kfff2qxzv00pj-libpng-1.6.37
--chroot-directory
/gnu/store/j3f5hx6yvhlj3sapiipigkwg05b49nwn-freetype-2.10.4
--chroot-directory
/gnu/store/7y3lvk3xf4im8n44337mc6y0ccysvfia-font-dejavu-2.37
--chroot-directory
/gnu/store/skxf0dmvgrw84pb2yzi1g1hwn0swv9kx-fontconfig-2.13.1
--chroot-directory
/gnu/store/cw69is9wbbllwx95wky4pmbcsk4vvbpd-libxrender-0.9.10
--chroot-directory
/gnu/store/na0x00biq02fm5cyj5a8r67qwsnsskw8-cairo-1.16.0
--chroot-directory
/gnu/store/16v7w5z5h5dxvi23q096qarhdngvkwmh-libogg-1.3.4
--chroot-directory
/gnu/store/lksia9ig14j9xb7nib531nhli2yf2g74-libtheora-1.1.1
--chroot-directory
/gnu/store/kvdycbqq60r6wsqcwjsbj97r3pkrn44p-libxv-1.0.11
--chroot-directory
/gnu/store/zravcm0vwdj733ipalw07cg2gwzjlljh-libxft-2.3.3
--chroot-directory
/gnu/store/izyah9qg6d7y1l4w8h01qh15grqn5d8x-graphite2-1.3.13
--chroot-directory
/gnu/store/ckwyq3y43i33s5fl9hb6c51418rh1qwj-icu4c-66.1
--chroot-directory
/gnu/store/rfdjzqvdawlz68ikd7zqn325h7xs716j-harfbuzz-2.6.4
--chroot-directory
/gnu/store/llccvnpm1dm94d7lndrhs2m6421p45pd-fribidi-1.0.9
--chroot-directory
/gnu/store/6afij9jsvy30gk0yswd1n5f3xg5wx9mj-pango-1.44.7
--chroot-directory
/gnu/store/36jss745s64r1xrzi2f463y4j522f977-libvorbis-1.3.7
--chroot-directory
/gnu/store/6yayj1vy1k76rmf06izwxk4kfd5klgdf-gst-plugins-base-1.18.2
--chroot-directory /gnu/store/6hffmlj7g2961fxs0gkgqax4s8ykc4rp-lz4-1.9.3
--chroot-directory
/gnu/store/20bgydwiszx3wrdqg7py2lby20dz09bg-cyrus-sasl-2.1.27
--chroot-directory
/gnu/store/xfmwvyclihlbzc6qssgwsy505gsins73-spice-0.14.3
--chroot-directory
/gnu/store/n10y99pf7pq8qh7sfb7fg80yyjjy1g32-libusb-1.0.24
--chroot-directory
/gnu/store/wra4kly9j4hb1lay28f077cczljz9b77-usbredir-0.8.0
--chroot-directory
/gnu/store/w668dl13dac6gpxvyhic21dnifrrijp6-libseccomp-2.5.1
--chroot-directory
/gnu/store/57xj5gcy1jbl9ai2lnrqnpr0dald9i65-coreutils-8.32
--chroot-directory
/gnu/store/8zvc5mvk0xm3ygrxsgpyy5ilxb5rzjry-perl-5.30.2
--chroot-directory /gnu/store/pi8p64hkx6mwmpyskc5hr8jqx924p55i-nspr-4.29
--chroot-directory /gnu/store/i7vlz7adx5aapdg9cgwjqwvaqlacxh14-nss-3.59
--chroot-directory
/gnu/store/w44ijf3y2bfwr02l03q9rs4c9xjq448v-libcacard-2.7.0
--chroot-directory
/gnu/store/rv567nsh90bqz5gfh6sh1g84jccxcifa-llvm-11.0.0
--chroot-directory /gnu/store/r7k859hmcnkazf492fasqvk25jflnfk6-xz-5.2.4
--chroot-directory
/gnu/store/c8w9z48vvx2a3q3k44ch9yn00wk1qwhb-libxml2-2.9.10
--chroot-directory
/gnu/store/qwxfy2jyhq2744s4ljcqk3hwcpsf93aq-wayland-1.18.0
--chroot-directory
/gnu/store/lgcdxkgj7ld2pwilncc2z9gyzrc7nr4a-elfutils-0.182
--chroot-directory /gnu/store/i363a64l5kd77z3q91v5gh3hh4214byp-kmod-27
--chroot-directory
/gnu/store/6libjsymzjbmq96mbx3hbbgxad588g6h-pciutils-3.7.0
--chroot-directory
/gnu/store/vkwzprr8pdmyb9vapfqcq3zp3ylaiddb-libpciaccess-0.16
--chroot-directory
/gnu/store/kx58xc3hxa9b0mp1hl7pzz43bl7gh18h-libdrm-2.4.103
--chroot-directory
/gnu/store/jwga98k68l0h5c45jx7z4jdjzhfc34vm-libxshmfence-1.3
--chroot-directory
/gnu/store/c3zbbynb590yxrpwcxrkll80mn66h3kf-libxxf86vm-1.1.4
--chroot-directory
/gnu/store/acv2khs5q9c8azzyq93dakzbkjdl0glb-libxvmc-1.0.12
--chroot-directory
/gnu/store/9z9gd76la5bww3sqgg2ax0h00msl28k6-libxfixes-5.0.3
--chroot-directory
/gnu/store/2wysr1lr7b5mc444m39qz107n92xm5xq-libxdamage-1.1.5
--chroot-directory
/gnu/store/1jjl5ggl676malqkx9nxfvnm5wmnv70m-libxrandr-1.5.2
--chroot-directory
/gnu/store/7disnxqw8i3n4zhw5s0xj9kkdckkmr1p-mesa-20.2.4
--chroot-directory
/gnu/store/jk6cs3bvrg1hr3w6zz8vpqn3zcllvzwi-libepoxy-1.5.4
--chroot-directory
/gnu/store/sr1smpijax5kk8256c5vsv7hhzzghwh7-virglrenderer-0.6.0
--chroot-directory
/gnu/store/ngfzj8sjvavwqvnmxi4l27xi9sgayqr1-libevent-2.1.11
--chroot-directory
/gnu/store/hgr362nvsjrm8nli47waxl8q7ymi6h9s-libcap-2.31
--chroot-directory
/gnu/store/ggwz99h5m080bkgyj1w653ps5864vqiy-libdaemon-0.14
--chroot-directory /gnu/store/s69jhnl7avgcp8bnmhj82nm93hc8nipx-avahi-0.8
--chroot-directory
/gnu/store/q0111brhf73if977f8c31rpjnwjvzsrd-libpaper-1.1.24
--chroot-directory
/gnu/store/hbqlzgd8hcf6ndcmx7q7miqrsxb4dmkk-gs-fonts-8.11
--chroot-directory
/gnu/store/d80nhbm9g2y246ajx7q6mpmwh5fssiwq-libtiff-4.1.0
--chroot-directory
/gnu/store/zg126cjicrpm2p6zc08ra5vh4ddag7ww-libgc-8.0.4
--chroot-directory
/gnu/store/vb12knxd3cdrgnk548l4f6m628ikg8pf-libtasn1-4.16.0
--chroot-directory
/gnu/store/4i9lvjz9z9j4kj412jpqv4zxjcik9qcb-libunistring-0.9.10
--chroot-directory
/gnu/store/pzm72ywfyqv1g0h4571p6zlhg566cwwd-libidn2-2.3.0
--chroot-directory /gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0
--chroot-directory
/gnu/store/mz5fvdfks10rmwxf29n95bp9bim6wq7g-nettle-3.5.1
--chroot-directory
/gnu/store/i5a9qb07y9xjh9ry8hp6km43kji16nmd-libltdl-2.4.6
--chroot-directory
/gnu/store/fvhj74pghapbjvsvj27skvkra1by1965-bash-minimal-5.0.16
--chroot-directory
/gnu/store/18hp7flyb3yid3yp49i6qcdq0sbi5l1n-guile-3.0.2
--chroot-directory
/gnu/store/198dw01d3mp26ghdxym5hsi60lfynm9m-gnutls-3.6.15
--chroot-directory
/gnu/store/78rc8isxy90n5xs0ci84ym14fxkpc2ap-cups-minimal-2.3.3
--chroot-directory
/gnu/store/4gwakx3vkmyzpk72dap8mpckyzhlf1jk-jbig2dec-0.18
--chroot-directory
/gnu/store/yf81h4xdajc6jbxs5amqajai9w0yfixb-ghostscript-with-cups-9.52
--chroot-directory
/gnu/store/yav4zlcwczvpq26s8q149if8n6amvkyi-qpdf-10.0.1
--chroot-directory /gnu/store/86p77x91sx6a702f9s4a3a43yf0i03kj-lcms-2.9
--chroot-directory
/gnu/store/vywzrxkjrna28jmdjc4crl4hyf7gpghc-openjpeg-2.3.1
--chroot-directory
/gnu/store/06waislc8ix5xy6xli5ibcgc9753991v-cairo-1.16.0
--chroot-directory
/gnu/store/fc1rxw5sfzxyrxbgami9yr4mylhqas91-poppler-0.86.1
--chroot-directory
/gnu/store/dxsdv7nnq2in28ppbh07hli0p17znjni-cups-filters-1.27.4
--chroot-directory
/gnu/store/yndxxc2b9lyfdsvwwlxz2piy1k4p98zf-cups-2.3.3
--chroot-directory
/gnu/store/x3sgkg38hrawbwnlmvv6k2lq9hkbq631-libxcursor-1.2.0
--chroot-directory
/gnu/store/k1nzzz06q1byj60n3m8m6wx4kp3i4x47-libxi-1.7.10
--chroot-directory
/gnu/store/j8r1yfa36g3vlxlbrmkx4q3m5r53s5d7-libcroco-0.6.13
--chroot-directory
/gnu/store/6x1fca88scbzql6844xpf7pk1hs6xacp-pango-1.42.4
--chroot-directory
/gnu/store/0676qmb2pdi3kh37sjgba3g826sqzfsk-gdk-pixbuf-2.40.0
--chroot-directory
/gnu/store/3a6vlmijrccam7m1xbds13xq35lxv8a0-librsvg-2.40.21
--chroot-directory
/gnu/store/irjan5wq7j25fa2m6n2xhl8mglsaqxn4-gdk-pixbuf+svg-2.40.0
--chroot-directory
/gnu/store/dkm59bch3zdnhsxdqv13gvx7sf9h0zp0-atk-2.34.1
--chroot-directory
/gnu/store/qz3zdrz12rxawlkvah9qjhjyf6fh1v98-xkeyboard-config-2.31
--chroot-directory
/gnu/store/dgs5apgmmbhgy9r901akix1h122dlh3g-libxkbcommon-1.0.3
--chroot-directory
/gnu/store/bnfwds89wf2ffsagmpmq2m769p52s4i2-libxtst-1.2.3
--chroot-directory
/gnu/store/s73zsgfawx0vrizi50y4jhwdq7k41f51-at-spi2-core-2.34.0
--chroot-directory
/gnu/store/8jhflv0lv1vaa058ydzwdy64daw3s64m-at-spi2-atk-2.34.1
--chroot-directory
/gnu/store/53j0cm2ws9g67a318bs5gplyiyjbnyqr-libxinerama-1.1.4
--chroot-directory
/gnu/store/n2cnp2fivxq10kxqalcv2q41wzsyj9yd-gtk+-3.24.24
--chroot-directory
/gnu/store/svplp9wl0g2ahlv5rf6bhmq3xvp4zzh3-eudev-3.2.9
--chroot-directory
/gnu/store/pc6dg1giwmy8fx20rm0hmxs29h9b1ad1-libcap-2.45
--chroot-directory
/gnu/store/k0qs5d487wvgcd0qy32fxi01xb8iryqb-speexdsp-1.2.0
--chroot-directory
/gnu/store/cv3xvkpxdfkf5sm4yzn4cwfkhx37p5dh-bdb-6.2.32
--chroot-directory
/gnu/store/8d016xp69bzag8vc4r3w3fg6y1p1gcn2-libsndfile-1.0.30
--chroot-directory
/gnu/store/6j0110bhafaxy9ja1apldszpjjg57fja-libice-1.0.10
--chroot-directory /gnu/store/66qbwqdaw53pfim2yqqhjx5pbkdygdha-sbc-1.5
--chroot-directory
/gnu/store/30lpkdz8bvs13ps2qf55mjzv09v08741-libsm-1.2.3
--chroot-directory
/gnu/store/2rc3mpcdrc7ywrhpxyhx1rjpmifdw4md-jack-0.125.0
--chroot-directory
/gnu/store/02z5vgdhgxw4gcjvhx51mvy1ax4lzxmp-fftwf-3.3.8
--chroot-directory
/gnu/store/lpdwh8j6xpfgg716d4lny6j0mjdn1fis-pulseaudio-14.0
--chroot-directory
/gnu/store/vkvsf3g91sfpxz9imlairxqm2hh8qlwb-libpcap-1.9.1
--chroot-directory
/gnu/store/003ny8nsfmcbpm6mmivggyzj58ld9fzd-openssl-1.0.2u
--chroot-directory
/gnu/store/bymn22y4irfn9hkp6z8jc03xxbz3i6ly-vde2-2.3.2
--chroot-directory
/gnu/store/6j8k26az3603pabrkgq5rilj07jmvxy9-libaio-0.3.112
--chroot-directory
/gnu/store/2zq80i8hbhxv2z35h03hpyghlclsqfch-sdl2-2.0.12
--chroot-directory
/gnu/store/xji0gbq0axvbk9fvk7hry48sshcji5y5-qemu-5.1.0
--8<---------------cut here---------------end--------------->8---

Even after restarting both the guix-daemon and qemu-binfmt services.

The guix-daemon.scm service definition referenced by my system is this:

$ guix gc -R /run/current-system | grep guix-daemon.scm
/gnu/store/m3b1d3awnnjal093hqc5qjxhxskn5px2-shepherd-guix-daemon.scm

--8<---------------cut here---------------start------------->8---
(eval-when
    (expand load eval)
  (let
      ((extensions
        (quote
         ()))
       (prepend
        (lambda
            (items lst)
          (let loop
              ((items items)
               (lst lst))
            (if
             (null? items)
             lst
             (loop
              (cdr items)
              (cons
               (car items)
               (delete
                (car items)
                lst))))))))
    (set! %load-path
          (prepend
           (cons "/gnu/store/hbvk7jym815f4xqhpkpjhqs3rh30y437-module-import"
                 (map
                  (lambda
                      (extension)
                    (string-append extension "/share/guile/site/"
                                   (effective-version)))
                  extensions))
           %load-path))
    (set! %load-compiled-path
          (prepend
           (cons "/gnu/store/viyhk32c77k0bz0ww2r9kq44gj30gq25-module-import-compiled"
                 (map
                  (lambda
                      (extension)
                    (string-append extension "/lib/guile/"
                                   (effective-version)
                                   "/site-ccache"))
                  extensions))
           %load-compiled-path))))
(begin
  (use-modules
   (srfi srfi-1)
   (ice-9 match)
   (gnu build shepherd))
  (make <service> #:docstring
        (quote "Run the Guix daemon.")
        #:provides
        (quote
         (guix-daemon))
        #:requires
        (quote
         (user-processes))
        #:one-shot?
        (quote #f)
        #:respawn?
        (quote #t)
        #:start
        (lambda args
          (define proxy
            (or
             (getenv "http_proxy")
             #f))
          (define discover?
            (or
             (getenv "discover")
             #f))
          (fork+exec-command/container
           (cons* "/gnu/store/rqif4yxa6ny4nxrdq6whnva2r089jm0c-guix-1.2.0-13.a53f711/bin/guix-daemon" "--build-users-group" "guixbuild" "--max-silent-time" "0" "--timeout" "0" "--log-compression" "none"
                  (string-append "--discover="
                                 (if discover? "yes" "no"))
                  "--substitute-urls" "http://127.0.0.1:8080 https://ci.guix.gnu.org" "--max-jobs=4"
                  (append-map
                   (lambda
                       (file)
                     (append-map
                      (lambda
                          (directory)
                        (list "--chroot-directory" directory))
                      (call-with-input-file file read)))
                   (quote
                    ())))
           #:pid
           (match args
             ((pid)
              (string->number pid))
             (else
              (getpid)))
           #:environment-variables
           (append
            (list
             (string-append "GUIX_LOCPATH=" "/gnu/store/395pvii4bcjqxvdv7h0drq10lxi01sv1-glibc-utf8-locales-2.31" "/lib/locale")
             "LC_ALL=en_US.utf8")
            (if proxy
                (list
                 (string-append "http_proxy=" proxy)
                 (string-append "https_proxy=" proxy))
                (quote
                 ())))
           #:log-file "/var/log/guix-daemon.log"))
        #:stop
        (make-kill-destructor)
        #:actions
        (make-actions
         (set-http-proxy "Change the HTTP(S) proxy used by 'guix-daemon' and restart it."
                         (lambda*
                             (_ #:optional proxy)
                           (let
                               ((environment
                                 (environ)))
                             (if proxy
                                 (begin
                                   (format #t "changing HTTP/HTTPS proxy of 'guix-daemon' to ~s...~%" proxy)
                                   (setenv "http_proxy" proxy))
                                 (begin
                                   (format #t "clearing HTTP/HTTPS proxy of 'guix-daemon'...~%")
                                   (unsetenv "http_proxy")))
                             (action
                              (quote guix-daemon)
                              (quote restart))
                             (environ environment)
                             #t)))
         (discover "Enable or disable substitute servers discovery and restart the\n'guix-daemon'."
                   (lambda*
                       (_ status)
                     (let
                         ((environment
                           (environ)))
                       (if
                        (and status
                             (string=? status "on"))
                        (begin
                          (format #t "enable substitute servers discovery~%")
                          (setenv "discover" "on"))
                        (begin
                          (format #t "disable substitute servers discovery~%")
                          (unsetenv "discover")))
                       (action
                        (quote guix-daemon)
                        (quote restart))
                       (environ environment)
                       #t))))))
--8<---------------cut here---------------end--------------->8---

It seems to be that service extensions are not unloaded when removed
from the services that caused them to be loaded?

Thanks,

Maxim