Move cleanup of queries to later in the shutdown sequence

to avoid TSAN report

    WARNING: ThreadSanitizer: data race
      Write of size 8 at 0x000000000001 by main thread:
        #0 free <null>
        #1 default_memfree lib/isc/mem.c:440
        #2 mem_put lib/isc/mem.c:363
        #3 isc__mem_free lib/isc/mem.c:1012
        #4 main bin/tools/mdig.c:2231

      Previous read of size 1 at 0x000000000005 by thread T1:
        #0 dns_name_fromtext lib/dns/name.c:1121
        #1 sendquery bin/tools/mdig.c:596
        #2 sendqueries bin/tools/mdig.c:779
        #3 dispatch lib/isc/task.c:1153
        #4 run lib/isc/task.c:1345
        #5 isc__trampoline_run lib/isc/trampoline.c:184
        #6 <null> <null>

      Thread T1 (running) created by main thread at:
        #0 pthread_create <null>
        #1 isc_thread_create pthreads/thread.c:79
        #2 isc_taskmgr_create lib/isc/task.c:1435
        #3 main bin/tools/mdig.c:2148

    SUMMARY: ThreadSanitizer: data race in __interceptor_free

(cherry picked from commit 4015af02)
81 jobs for !4772 with 2533-mdig-move-cleanup-v9_16 in 34 minutes and 6 seconds (queued for 25 seconds)
latest detached
Status Job ID Name Coverage
  Precheck
passed #1551655
linux amd64
autoreconf

00:00:16

passed #1551657
linux amd64
clang-format

00:00:18

passed #1551658
linux amd64
coccinelle

00:03:42

passed #1551807
linux amd64
danger

00:00:15

passed #1551656
linux amd64
misc

00:00:15

failed #1551659
linux amd64
danger

00:00:19

 
  Build
passed #1551672
linux amd64
clang:asan

00:04:12

passed #1551676
linux amd64
clang:buster:amd64

00:02:02

passed #1551679
amd64 libvirt
clang:freebsd11:amd64

00:02:10

passed #1551680
amd64 libvirt
clang:freebsd12:amd64

00:01:51

passed #1551681
amd64 libvirt
clang:openbsd:amd64

00:04:28

passed #1551674
linux amd64
clang:tsan

00:02:24

passed #1551660
linux amd64
gcc:alpine3.13:amd64

00:01:53

passed #1551671
linux amd64
gcc:asan

00:03:34

passed #1551664
linux amd64
gcc:buster:amd64

00:01:34

passed #1551661
linux amd64
gcc:centos7:amd64

00:01:41

passed #1551662
linux amd64
gcc:centos8:amd64

00:01:44

passed #1551670
linux amd64
gcc:focal:amd64

00:01:44

passed #1551675
linux amd64
gcc:mutexatomics

00:01:48

passed #1551666
linux amd64
gcc:out-of-tree

00:01:42

passed #1551665
linux amd64
gcc:sid:amd64

00:02:17

passed #1551667
linux i386
gcc:sid:i386

00:01:50

passed #1551677
linux amd64
gcc:softhsm2.4

00:01:51

passed #1551678
linux amd64
gcc:softhsm2.6

00:01:49

passed #1551663
linux amd64
gcc:stretch:amd64

00:02:07

passed #1551673
linux amd64
gcc:tsan

00:02:10

passed #1551668
linux amd64
gcc:tumbleweed:amd64

00:01:49

passed #1551669
linux amd64
gcc:xenial:amd64

00:02:01

passed #1551683
amd64 windows
msvc:windows:amd64

00:00:59

passed #1551682
linux amd64
nolibtool:sid:amd64

00:02:13

 
  Unit
passed #1551695
linux amd64
unit:clang:asan

00:01:18

passed #1551699
linux amd64
unit:clang:buster:amd64

00:00:37

passed #1551702
amd64 libvirt
unit:clang:freebsd11:amd64

00:01:08

passed #1551703
amd64 libvirt
unit:clang:freebsd12:amd64

00:01:08

passed #1551697
linux amd64
unit:clang:tsan

00:01:43

passed #1551684
linux amd64
unit:gcc:alpine3.13:amd64

00:01:02

passed #1551694
linux amd64
unit:gcc:asan

00:01:10

passed #1551688
linux amd64
unit:gcc:buster:amd64

00:01:01

passed #1551685
linux amd64
unit:gcc:centos7:amd64

00:00:43

passed #1551686
linux amd64
unit:gcc:centos8:amd64

00:00:42

passed #1551693
linux amd64
unit:gcc:focal:amd64

00:00:38

passed #1551698
linux amd64
unit:gcc:mutexatomics

00:00:41

passed #1551689
linux amd64
unit:gcc:sid:amd64

00:00:39

passed #1551690
linux i386
unit:gcc:sid:i386

00:00:50

passed #1551700
linux amd64
unit:gcc:softhsm2.4

00:00:44

passed #1551701
linux amd64
unit:gcc:softhsm2.6

00:00:53

passed #1551687
linux amd64
unit:gcc:stretch:amd64

00:00:43

passed #1551696
linux amd64
unit:gcc:tsan

00:01:59

passed #1551691
linux amd64
unit:gcc:tumbleweed:amd64

00:00:39

passed #1551692
linux amd64
unit:gcc:xenial:amd64

00:00:44

passed #1551704
linux amd64
unit:nolibtool:sid:amd64

00:01:13

 
  System
passed #1551716
linux amd64
system:clang:asan

00:13:06

passed #1551720
linux amd64
system:clang:buster:amd64

00:12:30

passed #1551723
amd64 libvirt
system:clang:freebsd11:amd64

00:10:59

passed #1551813
amd64 libvirt
system:clang:freebsd12:amd64

00:10:46

failed #1551812
linux amd64 allowed to fail
system:clang:tsan

00:15:04

passed #1551705
linux amd64
system:gcc:alpine3.13:amd64

00:11:51

passed #1551715
linux amd64
system:gcc:asan

00:13:29

passed #1551709
linux amd64
system:gcc:buster:amd64

00:13:13

passed #1551706
linux amd64
system:gcc:centos7:amd64

00:11:37

passed #1551707
linux amd64
system:gcc:centos8:amd64

00:12:57

passed #1551714
linux amd64
system:gcc:focal:amd64

00:12:16

passed #1551719
linux amd64
system:gcc:mutexatomics

00:11:21

passed #1551710
linux amd64
system:gcc:sid:amd64

00:11:42

passed #1551711
linux i386
system:gcc:sid:i386

00:10:02

passed #1551721
linux amd64
system:gcc:softhsm2.4

00:11:34

passed #1551811
linux amd64
system:gcc:softhsm2.6

00:12:09

passed #1551708
linux amd64
system:gcc:stretch:amd64

00:11:18

passed #1551717
linux amd64
system:gcc:tsan

00:15:41

passed #1551712
linux amd64
system:gcc:tumbleweed:amd64

00:12:13

passed #1551713
linux amd64
system:gcc:xenial:amd64

00:10:45

passed #1551725
linux amd64
system:nolibtool:sid:amd64

00:11:43

failed #1551724
amd64 libvirt
system:clang:freebsd12:amd64

00:11:10

failed #1551718
linux amd64 allowed to fail
system:clang:tsan

00:14:45

failed #1551722
linux amd64
system:gcc:softhsm2.6

00:12:06

 
  Docs
passed #1551726
linux amd64
docs

00:02:39

 
  Postcheck
passed #1551730
linux amd64
cppcheck

00:00:27

passed #1551727
linux amd64
flake8

00:00:20

passed #1551731
linux amd64
gcov

00:00:34

76.0%
passed #1551728
linux amd64
pylint

00:00:25

passed #1551729
linux amd64
scan-build

00:10:01

 
Name Stage Failure
failed
system:clang:tsan System
Running after_script
Running after script...
$ find bin -name 'tsan.*' -exec python3 util/parse_tsan.py {} \;
Uploading artifacts for failed job
Uploading artifacts...
untracked: found 1401 files

Uploading artifacts as "archive" to coordinator... ok
id=1551812 responseStatus=201 Created token=uJ8swUxh
Cleaning up file based variables
ERROR: Job failed: exit code 1