Address lock order inversions.

    WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock)
    Cycle in lock order graph: M1 (0x000000000000) => M2 (0x000000000000) => M1

    Mutex M2 acquired here while holding mutex M1 in thread T1:
    #0 pthread_mutex_lock <null>
    #1 dns_view_findzonecut lib/dns/view.c:1310:2
    #2 fctx_create lib/dns/resolver.c:5070:13
    #3 dns_resolver_createfetch lib/dns/resolver.c:10813:12
    #4 dns_resolver_prime lib/dns/resolver.c:10442:12
    #5 dns_view_find lib/dns/view.c:1176:4
    #6 dbfind_name lib/dns/adb.c:3833:11
    #7 dns_adb_createfind lib/dns/adb.c:3155:12
    #8 findname lib/dns/resolver.c:3497:11
    #9 fctx_getaddresses lib/dns/resolver.c:3808:3
    #10 fctx_try lib/dns/resolver.c:4197:12
    #11 fctx_start lib/dns/resolver.c:4824:4
    #12 dispatch lib/isc/task.c:1152:7
    #13 run lib/isc/task.c:1344:2

    Mutex M1 previously acquired by the same thread here:
    #0 pthread_mutex_lock <null>
    #1 dns_resolver_createfetch lib/dns/resolver.c:10767:2
    #2 dns_resolver_prime lib/dns/resolver.c:10442:12
    #3 dns_view_find lib/dns/view.c:1176:4
    #4 dbfind_name lib/dns/adb.c:3833:11
    #5 dns_adb_createfind lib/dns/adb.c:3155:12
    #6 findname lib/dns/resolver.c:3497:11
    #7 fctx_getaddresses lib/dns/resolver.c:3808:3
    #8 fctx_try lib/dns/resolver.c:4197:12
    #9 fctx_start lib/dns/resolver.c:4824:4
    #10 dispatch lib/isc/task.c:1152:7
    #11 run lib/isc/task.c:1344:2

    Mutex M1 acquired here while holding mutex M2 in thread T1:
    #0 pthread_mutex_lock <null>
    #1 dns_resolver_shutdown lib/dns/resolver.c:10530:4
    #2 view_flushanddetach lib/dns/view.c:632:4
    #3 dns_view_detach lib/dns/view.c:689:2
    #4 qctx_destroy lib/ns/query.c:5152:2
    #5 fetch_callback lib/ns/query.c:5749:3
    #6 dispatch lib/isc/task.c:1152:7
    #7 run lib/isc/task.c:1344:2

    Mutex M2 previously acquired by the same thread here:
    #0 pthread_mutex_lock <null>
    #1 view_flushanddetach lib/dns/view.c:630:3
    #2 dns_view_detach lib/dns/view.c:689:2
    #3 qctx_destroy lib/ns/query.c:5152:2
    #4 fetch_callback lib/ns/query.c:5749:3
    #5 dispatch lib/isc/task.c:1152:7
    #6 run lib/isc/task.c:1344:2

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:73:8
    #2 isc_taskmgr_create lib/isc/task.c:1434:3
    #3 create_managers bin/named/main.c:915:11
    #4 setup bin/named/main.c:1223:11
    #5 main bin/named/main.c:1523:2

    SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) in pthread_mutex_lock

(cherry picked from commit a669c919)
80 jobs for !4170 with 2156-threadsanitizer-lock-order-inversion-potential-deadlock-in-pthread_mutex_lock-v9_16 in 18 minutes and 27 seconds (queued for 9 seconds)
latest detached
Status Job ID Name Coverage
  Precheck
passed #1176104
amd64 linux
autoreconf

00:00:14

passed #1176106
amd64 linux
clang-format

00:00:16

passed #1176107
amd64 linux
coccinelle

00:03:26

passed #1176108
amd64 linux
danger

00:00:12

passed #1176105
amd64 linux
misc

00:00:11

 
  Build
passed #1176122
amd64 linux
clang:asan

00:04:07

passed #1176126
amd64 linux
clang:buster:amd64

00:01:53

passed #1176129
amd64 libvirt
clang:freebsd11:amd64

00:01:48

passed #1176130
amd64 libvirt
clang:freebsd12:amd64

00:01:38

passed #1176131
amd64 libvirt
clang:openbsd:amd64

00:04:05

passed #1176124
amd64 linux
clang:tsan

00:02:07

passed #1176109
amd64 linux
gcc:alpine3.12:amd64

00:01:35

passed #1176121
amd64 linux
gcc:asan

00:03:25

passed #1176114
amd64 linux
gcc:buster:amd64

00:01:42

passed #1176110
amd64 linux
gcc:centos6:amd64

00:01:20

passed #1176111
amd64 linux
gcc:centos7:amd64

00:01:28

passed #1176112
amd64 linux
gcc:centos8:amd64

00:01:43

passed #1176120
amd64 linux
gcc:focal:amd64

00:01:39

passed #1176125
amd64 linux
gcc:mutexatomics

00:01:33

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

00:01:37

passed #1176115
amd64 linux
gcc:sid:amd64

00:02:06

passed #1176117
i386 linux
gcc:sid:i386

00:01:37

passed #1176127
amd64 linux
gcc:softhsm2.4

00:01:39

passed #1176128
amd64 linux
gcc:softhsm2.6

00:01:36

passed #1176113
amd64 linux
gcc:stretch:amd64

00:01:46

passed #1176123
amd64 linux
gcc:tsan

00:01:55

passed #1176118
amd64 linux
gcc:tumbleweed:amd64

00:01:30

passed #1176119
amd64 linux
gcc:xenial:amd64

00:01:51

passed #1176133
amd64 windows
msvc:windows:amd64

00:00:54

passed #1176132
amd64 linux
nolibtool:sid:amd64

00:02:12

 
  Unit
passed #1176146
amd64 linux
unit:clang:asan

00:00:50

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

00:00:35

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

00:00:57

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

00:01:01

passed #1176148
amd64 linux
unit:clang:tsan

00:01:30

passed #1176134
amd64 linux
unit:gcc:alpine3.12:amd64

00:00:38

passed #1176145
amd64 linux
unit:gcc:asan

00:00:52

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

00:00:34

passed #1176135
amd64 linux
unit:gcc:centos6:amd64

00:00:36

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

00:00:36

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

00:00:45

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

00:00:35

passed #1176149
amd64 linux
unit:gcc:mutexatomics

00:00:34

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

00:00:34

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

00:00:44

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

00:00:35

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

00:00:35

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

00:00:34

passed #1176147
amd64 linux
unit:gcc:tsan

00:01:50

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

00:00:33

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

00:00:36

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

00:00:48

failed #1176153
amd64 libvirt
unit:clang:freebsd11:amd64

00:06:06

 
  System
passed #1176168
amd64 linux
system:clang:asan

00:12:20

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

00:10:07

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

00:10:08

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

00:10:10

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

00:14:46

passed #1176156
amd64 linux
system:gcc:alpine3.12:amd64

00:11:28

passed #1176167
amd64 linux
system:gcc:asan

00:12:46

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

00:10:46

passed #1176157
amd64 linux
system:gcc:centos6:amd64

00:10:43

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

00:10:32

failed #1176159
amd64 linux
system:gcc:centos8:amd64

00:11:48

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

00:10:45

passed #1176171
amd64 linux
system:gcc:mutexatomics

00:10:07

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

00:10:03

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

00:09:51

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

00:09:59

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

00:11:12

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

00:10:12

failed #1176169
amd64 linux allowed to fail
system:gcc:tsan

00:14:18

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

00:10:31

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

00:09:48

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

00:11:21

 
  Docs
passed #1176178
amd64 linux
docs

00:01:58

 
  Postcheck
passed #1176182
amd64 linux
cppcheck

00:00:19

passed #1176179
amd64 linux
flake8

00:00:17

passed #1176180
amd64 linux
pylint

00:00:21

passed #1176181
amd64 linux
scan-build

00:08:13

 
Name Stage Failure
failed
system:clang:tsan System
make: *** [Makefile:491: test] Error 1
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 10126 files

Uploading artifacts as "archive" to coordinator... ok
id=1176170 responseStatus=201 Created token=E7yuZBpp
ERROR: Job failed: exit code 1
failed
system:gcc:tsan System
make: *** [Makefile:491: test] Error 1
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 7232 files

Uploading artifacts as "archive" to coordinator... ok
id=1176169 responseStatus=201 Created token=hHUzLzM6
ERROR: Job failed: exit code 1
failed
system:gcc:centos8:amd64 System
I:      zero
I:Core dumps were found for the following system tests:
I: zero
make: *** [Makefile:491: test] Error 1
Uploading artifacts for failed job
Uploading artifacts...
untracked: found 1541 files

Uploading artifacts as "archive" to coordinator... ok
id=1176159 responseStatus=201 Created token=8jnuk3Mm
ERROR: Job failed: exit code 1