Fix lock-order-inversion (potential deadlock) in dns_resolver_createfetch

There's a lock-order-inversion when running `zone_maintenance()` from
the timer while shutting down the server `shutdown_server()`.  This only
happens when the taskmgr scheduling is more relaxed and paralellized,
but the issue is real nevertheless.

The associated ThreadSanitizer warning:

    WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock)
      Cycle in lock order graph: M1 (0x000000000001) => 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:1326:2
	#2 fctx_create lib/dns/resolver.c:5144:13
	#3 dns_resolver_createfetch lib/dns/resolver.c:10977:12
	#4 zone_refreshkeys lib/dns/zone.c:10830:13
	#5 zone_maintenance lib/dns/zone.c:11065:5
	#6 zone_timer lib/dns/zone.c:14652:2
	#7 task_run lib/isc/task.c:857:5
	#8 isc_task_run lib/isc/task.c:944:10
	#9 isc__nm_async_task lib/isc/netmgr/netmgr.c:730:24
	#10 process_netievent lib/isc/netmgr/netmgr.c
	#11 process_queue lib/isc/netmgr/netmgr.c:885:8
	#12 process_tasks_queue lib/isc/netmgr/netmgr.c:756:10
	#13 process_queues lib/isc/netmgr/netmgr.c:772:7
	#14 async_cb lib/isc/netmgr/netmgr.c:671:2
	#15 uv__async_io /home/ondrej/Projects/tsan/libuv/src/unix/async.c:163:5
	#16 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:462:11
	#17 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:392:5
	#18 nm_thread lib/isc/netmgr/netmgr.c:597:11
	#19 isc__trampoline_run lib/isc/trampoline.c:184:11

      Mutex M1 previously acquired by the same thread here:
	#0 pthread_mutex_lock <null>
	#1 zone_refreshkeys lib/dns/zone.c:10717:2
	#2 zone_maintenance lib/dns/zone.c:11065:5
	#3 zone_timer lib/dns/zone.c:14652:2
	#4 task_run lib/isc/task.c:857:5
	#5 isc_task_run lib/isc/task.c:944:10
	#6 isc__nm_async_task lib/isc/netmgr/netmgr.c:730:24
	#7 process_netievent lib/isc/netmgr/netmgr.c
	#8 process_queue lib/isc/netmgr/netmgr.c:885:8
	#9 process_tasks_queue lib/isc/netmgr/netmgr.c:756:10
	#10 process_queues lib/isc/netmgr/netmgr.c:772:7
	#11 async_cb lib/isc/netmgr/netmgr.c:671:2
	#12 uv__async_io /home/ondrej/Projects/tsan/libuv/src/unix/async.c:163:5
	#13 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:462:11
	#14 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:392:5
	#15 nm_thread lib/isc/netmgr/netmgr.c:597:11
	#16 isc__trampoline_run lib/isc/trampoline.c:184:11

      Mutex M1 acquired here while holding mutex M2 in thread T2:
	#0 pthread_mutex_lock <null>
	#1 dns_zone_flush lib/dns/zone.c:11443:2
	#2 view_flushanddetach lib/dns/view.c:657:5
	#3 dns_view_flushanddetach lib/dns/view.c:690:2
	#4 shutdown_server bin/named/server.c:10056:4
	#5 task_run lib/isc/task.c:857:5
	#6 isc_task_run lib/isc/task.c:944:10
	#7 isc__nm_async_task lib/isc/netmgr/netmgr.c:730:24
	#8 process_netievent lib/isc/netmgr/netmgr.c
	#9 process_queue lib/isc/netmgr/netmgr.c:885:8
	#10 process_tasks_queue lib/isc/netmgr/netmgr.c:756:10
	#11 process_queues lib/isc/netmgr/netmgr.c:772:7
	#12 async_cb lib/isc/netmgr/netmgr.c:671:2
	#13 uv__async_io /home/ondrej/Projects/tsan/libuv/src/unix/async.c:163:5
	#14 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:462:11
	#15 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:392:5
	#16 nm_thread lib/isc/netmgr/netmgr.c:597:11
	#17 isc__trampoline_run lib/isc/trampoline.c:184:11

      Mutex M2 previously acquired by the same thread here:
	#0 pthread_mutex_lock <null>
	#1 view_flushanddetach lib/dns/view.c:645:3
	#2 dns_view_flushanddetach lib/dns/view.c:690:2
	#3 shutdown_server bin/named/server.c:10056:4
	#4 task_run lib/isc/task.c:857:5
	#5 isc_task_run lib/isc/task.c:944:10
	#6 isc__nm_async_task lib/isc/netmgr/netmgr.c:730:24
	#7 process_netievent lib/isc/netmgr/netmgr.c
	#8 process_queue lib/isc/netmgr/netmgr.c:885:8
	#9 process_tasks_queue lib/isc/netmgr/netmgr.c:756:10
	#10 process_queues lib/isc/netmgr/netmgr.c:772:7
	#11 async_cb lib/isc/netmgr/netmgr.c:671:2
	#12 uv__async_io /home/ondrej/Projects/tsan/libuv/src/unix/async.c:163:5
	#13 uv__io_poll /home/ondrej/Projects/tsan/libuv/src/unix/linux-core.c:462:11
	#14 uv_run /home/ondrej/Projects/tsan/libuv/src/unix/core.c:392:5
	#15 nm_thread lib/isc/netmgr/netmgr.c:597:11
	#16 isc__trampoline_run lib/isc/trampoline.c:184:11

      Thread T2 (running) created by main thread at:
	#0 pthread_create <null>
	#1 isc_thread_create lib/isc/pthreads/thread.c:79:8
	#2 isc_nm_start lib/isc/netmgr/netmgr.c:303:3
	#3 create_managers bin/named/main.c:957:15
	#4 setup bin/named/main.c:1267:11
	#5 main bin/named/main.c:1558:2

      Thread T2 (running) created by main thread at:
	#0 pthread_create <null>
	#1 isc_thread_create lib/isc/pthreads/thread.c:79:8
	#2 isc_nm_start lib/isc/netmgr/netmgr.c:303:3
	#3 create_managers bin/named/main.c:957:15
	#4 setup bin/named/main.c:1267:11
	#5 main bin/named/main.c:1558:2

    SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) in __interceptor_pthread_mutex_lock
70 jobs for !4909 with 2637-threadsanitizer-lock-order-inversion-potential-deadlock-in-zone_refreshkeys in 19 minutes and 38 seconds (queued for 8 seconds)
latest detached
Status Job ID Name Coverage
  Autoconf
passed #1651285
amd64 linux
autoreconf

00:00:17

 
  Precheck
passed #1651287
amd64 linux
clang-format

00:00:16

passed #1651288
amd64 linux
coccinelle

00:03:34

passed #1651289
amd64 linux
danger

00:00:17

passed #1651286
amd64 linux
misc

00:00:22

passed #1651290
amd64 linux
tarball-create

00:01:31

 
  Build
passed #1651301
amd64 linux
clang:asan

00:02:02

passed #1651305
amd64 linux
clang:buster:amd64

00:00:58

passed #1651308
amd64 libvirt
clang:freebsd11:amd64

00:01:14

passed #1651309
amd64 libvirt
clang:freebsd12:amd64

00:01:12

passed #1651310
amd64 libvirt
clang:openbsd:amd64

00:02:18

passed #1651303
amd64 linux
clang:tsan

00:01:12

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

00:01:11

passed #1651300
amd64 linux
gcc:asan

00:01:39

passed #1651295
amd64 linux
gcc:buster:amd64

00:00:44

passed #1651292
amd64 linux
gcc:centos7:amd64

00:00:47

passed #1651293
amd64 linux
gcc:centos8:amd64

00:00:53

passed #1651299
amd64 linux
gcc:focal:amd64

00:00:57

passed #1651304
amd64 linux
gcc:mutexatomics

00:00:52

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

00:00:55

passed #1651296
amd64 linux
gcc:sid:amd64

00:01:19

passed #1651306
amd64 linux
gcc:softhsm2.4

00:00:53

passed #1651307
amd64 linux
gcc:softhsm2.6

00:00:53

passed #1651294
amd64 linux
gcc:stretch:amd64

00:00:59

passed #1651302
amd64 linux
gcc:tsan

00:01:15

passed #1651298
amd64 linux
gcc:tumbleweed:amd64

00:00:56

passed #1651311
amd64 windows
msvc:windows:amd64

00:01:03

 
  Unit
passed #1651321
amd64 linux
unit:clang:asan

00:02:13

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

00:01:23

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

00:02:12

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

00:01:47

passed #1651330
amd64 libvirt
unit:clang:openbsd:amd64

00:03:44

passed #1651323
amd64 linux
unit:clang:tsan

00:03:47

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

00:01:42

passed #1651320
amd64 linux
unit:gcc:asan

00:01:55

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

00:02:30

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

00:01:26

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

00:01:29

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

00:01:32

passed #1651324
amd64 linux
unit:gcc:mutexatomics

00:01:31

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

00:01:20

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

00:01:22

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

00:01:24

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

00:00:16

passed #1651322
amd64 linux
unit:gcc:tsan

00:04:38

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

00:01:33

 
  System
passed #1651340
amd64 linux
system:clang:asan

00:14:34

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

00:13:21

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

00:12:52

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

00:12:45

failed #1651342
amd64 linux
system:clang:tsan

00:16:39

failed #1651331
amd64 linux
system:gcc:alpine3.13:amd64

00:13:37

passed #1651339
amd64 linux
system:gcc:asan

00:14:34

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

00:14:23

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

00:13:12

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

00:13:05

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

00:13:58

passed #1651343
amd64 linux
system:gcc:mutexatomics

00:14:06

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

00:13:33

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

00:13:16

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

00:13:29

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

00:12:57

failed #1651341
amd64 linux
system:gcc:tsan

00:17:32

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

00:13:28

 
  Docs
passed #1651349
amd64 linux
docs

00:00:54

 
  Postcheck
passed #1651353
amd64 linux
cppcheck

00:00:52

passed #1651350
amd64 linux
flake8

00:00:24

passed #1651354
amd64 linux
gcov

00:00:34

77.0%
passed #1651351
amd64 linux
pylint

00:00:28

passed #1651352
amd64 linux
scan-build

00:04:30

 
Name Stage Failure
failed
system:gcc:tsan System
No job log
failed
system:clang:tsan System
No job log
failed
system:gcc:alpine3.13:amd64 System
No job log
failed
system:gcc:softhsm2.6 System
No job log