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
74 jobs for !4150 with 2156-threadsanitizer-lock-order-inversion-potential-deadlock-in-pthread_mutex_lock in 16 minutes and 33 seconds (queued for 10 seconds)
latest detached
Status Job ID Name Coverage
  Autoconf
passed #1175765
amd64 linux
autoreconf

00:00:18

 
  Precheck
passed #1175767
amd64 linux
clang-format

00:00:18

passed #1175768
amd64 linux
coccinelle

00:03:33

passed #1175769
amd64 linux
danger

00:00:18

passed #1175766
amd64 linux
misc

00:00:13

passed #1175770
amd64 linux
tarball-create

00:01:24

 
  Build
passed #1175783
amd64 linux
clang:asan

00:02:06

passed #1175787
amd64 linux
clang:buster:amd64

00:01:02

passed #1175790
amd64 libvirt
clang:freebsd11:amd64

00:01:25

passed #1175791
amd64 libvirt
clang:freebsd12:amd64

00:01:04

passed #1175792
amd64 libvirt
clang:openbsd:amd64

00:02:31

passed #1175785
amd64 linux
clang:tsan

00:01:22

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

00:00:50

passed #1175782
amd64 linux
gcc:asan

00:01:55

passed #1175775
amd64 linux
gcc:buster:amd64

00:00:47

passed #1175772
amd64 linux
gcc:centos7:amd64

00:00:46

passed #1175773
amd64 linux
gcc:centos8:amd64

00:00:58

passed #1175781
amd64 linux
gcc:focal:amd64

00:00:59

passed #1175786
amd64 linux
gcc:mutexatomics

00:00:54

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

00:00:54

passed #1175776
amd64 linux
gcc:sid:amd64

00:01:15

passed #1175778
i386 linux
gcc:sid:i386

00:01:04

passed #1175788
amd64 linux
gcc:softhsm2.4

00:00:56

passed #1175789
amd64 linux
gcc:softhsm2.6

00:01:06

passed #1175774
amd64 linux
gcc:stretch:amd64

00:01:05

passed #1175784
amd64 linux
gcc:tsan

00:01:07

passed #1175779
amd64 linux
gcc:tumbleweed:amd64

00:00:56

passed #1175780
amd64 linux
gcc:xenial:amd64

00:01:05

passed #1175793
amd64 windows
msvc:windows:amd64

00:01:10

 
  Unit
passed #1175805
amd64 linux
unit:clang:asan

00:01:14

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

00:01:00

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

00:01:28

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

00:01:18

passed #1175807
amd64 linux
unit:clang:tsan

00:03:12

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

00:00:55

passed #1175804
amd64 linux
unit:gcc:asan

00:01:18

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

00:00:57

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

00:00:55

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

00:01:01

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

00:00:58

passed #1175808
amd64 linux
unit:gcc:mutexatomics

00:00:55

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

00:01:01

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

00:00:59

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

00:00:57

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

00:00:58

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

00:00:59

passed #1175806
amd64 linux
unit:gcc:tsan

00:04:11

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

00:00:56

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

00:01:03

 
  System
passed #1175825
amd64 linux
system:clang:asan

00:12:49

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

00:10:58

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

00:10:42

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

00:10:10

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

00:14:00

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

00:12:12

passed #1175824
amd64 linux
system:gcc:asan

00:12:42

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

00:11:28

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

00:11:28

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

00:12:02

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

00:11:34

passed #1175828
amd64 linux
system:gcc:mutexatomics

00:10:47

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

00:11:05

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

00:12:30

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

00:12:15

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

00:11:46

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

00:11:05

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

00:14:24

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

00:11:24

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

00:10:54

 
  Docs
passed #1175834
amd64 linux
docs

00:00:38

 
  Postcheck
passed #1175838
amd64 linux
cppcheck

00:00:50

passed #1175835
amd64 linux
flake8

00:00:21

passed #1175836
amd64 linux
pylint

00:00:22

passed #1175837
amd64 linux
scan-build

00:04:24

 
Name Stage Failure
failed
system:gcc:tsan System
E:shutdown:2020-09-23T01:30:10+0000
FAIL shutdown (exit status: 1)

$ find bin -name 'tsan.*' -exec python3 util/parse_tsan.py {} \;
Uploading artifacts for failed job
Uploading artifacts...
untracked: found 7569 files

Uploading artifacts as "archive" to coordinator... ok
id=1175826 responseStatus=201 Created token=cK8HngSw
ERROR: Job failed: exit code 1
failed
system:clang:tsan System
E:shutdown:2020-09-23T01:29:51+0000
FAIL shutdown (exit status: 1)

$ find bin -name 'tsan.*' -exec python3 util/parse_tsan.py {} \;
Uploading artifacts for failed job
Uploading artifacts...
untracked: found 10992 files

Uploading artifacts as "archive" to coordinator... ok
id=1175827 responseStatus=201 Created token=15_1SPwK
ERROR: Job failed: exit code 1