Address TSAN error between dns_rbt_findnode() and subtractrdataset().

Having dns_rbt_findnode() in previous_closest_nsec() check of
node->data is a optimisation that triggers a TSAN error with
subtractrdataset().  find_closest_nsec() still needs to check if
the NSEC record are active or not and look for a earlier NSEC records
if it isn't.  Set DNS_RBTFIND_EMPTYDATA so node->data isn't referenced
without the node lock being held.

    WARNING: ThreadSanitizer: data race
    Read of size 8 at 0x000000000001 by thread T1 (mutexes: read M1, read M2):
    #0 dns_rbt_findnode lib/dns/rbt.c:1708
    #1 previous_closest_nsec lib/dns/rbtdb.c:3760
    #2 find_closest_nsec lib/dns/rbtdb.c:3942
    #3 zone_find lib/dns/rbtdb.c:4091
    #4 dns_db_findext lib/dns/db.c:536
    #5 query_lookup lib/ns/query.c:5582
    #6 ns__query_start lib/ns/query.c:5505
    #7 query_setup lib/ns/query.c:5229
    #8 ns_query_start lib/ns/query.c:11380
    #9 ns__client_request lib/ns/client.c:2166
    #10 processbuffer netmgr/tcpdns.c:230
    #11 dnslisten_readcb netmgr/tcpdns.c:309
    #12 read_cb netmgr/tcp.c:832
    #13 <null> <null>
    #14 <null> <null>

    Previous write of size 8 at 0x000000000001 by thread T2 (mutexes: write M3):
    #0 subtractrdataset lib/dns/rbtdb.c:7133
    #1 dns_db_subtractrdataset lib/dns/db.c:742
    #2 diff_apply lib/dns/diff.c:368
    #3 dns_diff_apply lib/dns/diff.c:459
    #4 do_one_tuple lib/dns/update.c:247
    #5 update_one_rr lib/dns/update.c:275
    #6 delete_if_action lib/dns/update.c:689
    #7 foreach_rr lib/dns/update.c:471
    #8 delete_if lib/dns/update.c:716
    #9 dns_update_signaturesinc lib/dns/update.c:1948
    #10 receive_secure_serial lib/dns/zone.c:15637
    #11 dispatch lib/isc/task.c:1152
    #12 run lib/isc/task.c:1344
    #13 <null> <null>

    Location is heap block of size 130 at 0x000000000028 allocated by thread T3:
    #0 malloc <null>
    #1 default_memalloc lib/isc/mem.c:713
    #2 mem_get lib/isc/mem.c:622
    #3 mem_allocateunlocked lib/isc/mem.c:1268
    #4 isc___mem_allocate lib/isc/mem.c:1288
    #5 isc__mem_allocate lib/isc/mem.c:2453
    #6 isc___mem_get lib/isc/mem.c:1037
    #7 isc__mem_get lib/isc/mem.c:2432
    #8 create_node lib/dns/rbt.c:2239
    #9 dns_rbt_addnode lib/dns/rbt.c:1202
    #10 dns_rbtdb_create lib/dns/rbtdb.c:8668
    #11 dns_db_create lib/dns/db.c:118
    #12 receive_secure_db lib/dns/zone.c:16154
    #13 dispatch lib/isc/task.c:1152
    #14 run lib/isc/task.c:1344
    #15 <null> <null>

    Mutex M1 (0x000000000040) created at:
    #0 pthread_rwlock_init <null>
    #1 isc_rwlock_init lib/isc/rwlock.c:39
    #2 dns_rbtdb_create lib/dns/rbtdb.c:8527
    #3 dns_db_create lib/dns/db.c:118
    #4 receive_secure_db lib/dns/zone.c:16154
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Mutex M2 (0x000000000044) created at:
    #0 pthread_rwlock_init <null>
    #1 isc_rwlock_init lib/isc/rwlock.c:39
    #2 dns_rbtdb_create lib/dns/rbtdb.c:8600
    #3 dns_db_create lib/dns/db.c:118
    #4 receive_secure_db lib/dns/zone.c:16154
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Mutex M3 (0x000000000046) created at:
    #0 pthread_rwlock_init <null>
    #1 isc_rwlock_init lib/isc/rwlock.c:39
    #2 dns_rbtdb_create lib/dns/rbtdb.c:8600
    #3 dns_db_create lib/dns/db.c:118
    #4 receive_secure_db lib/dns/zone.c:16154
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_nm_start netmgr/netmgr.c:232
    #3 create_managers bin/named/main.c:909
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

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

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

    SUMMARY: ThreadSanitizer: data race lib/dns/rbt.c:1708 in dns_rbt_findnode

(cherry picked from commit 244f84a8)
81 jobs for !4384 with 2211-tsan-error-previous_closest_nsec-dns_rbt_findnode-vs-subtractrdataset-v9_16 in 18 minutes and 38 seconds (queued for 12 seconds)
detached
Status Job ID Name Coverage
  Precheck
passed #1289374
amd64 linux
autoreconf

00:00:16

passed #1289376
amd64 linux
clang-format

00:00:17

passed #1289377
amd64 linux
coccinelle

00:03:34

passed #1289454
linux amd64
danger

00:00:12

passed #1289375
amd64 linux
misc

00:00:13

failed #1289378
amd64 linux
danger

00:00:14

 
  Build
passed #1289392
amd64 linux
clang:asan

00:04:00

passed #1289396
amd64 linux
clang:buster:amd64

00:01:47

passed #1289399
amd64 libvirt
clang:freebsd11:amd64

00:02:16

passed #1289400
amd64 libvirt
clang:freebsd12:amd64

00:01:42

passed #1289401
amd64 libvirt
clang:openbsd:amd64

00:03:55

passed #1289394
amd64 linux
clang:tsan

00:02:27

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

00:01:45

passed #1289391
amd64 linux
gcc:asan

00:03:32

passed #1289384
amd64 linux
gcc:buster:amd64

00:01:37

passed #1289380
amd64 linux
gcc:centos6:amd64

00:01:28

passed #1289381
amd64 linux
gcc:centos7:amd64

00:01:36

passed #1289382
amd64 linux
gcc:centos8:amd64

00:01:38

passed #1289390
amd64 linux
gcc:focal:amd64

00:01:41

passed #1289395
amd64 linux
gcc:mutexatomics

00:01:44

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

00:01:27

passed #1289385
amd64 linux
gcc:sid:amd64

00:02:18

passed #1289387
i386 linux
gcc:sid:i386

00:01:37

passed #1289397
amd64 linux
gcc:softhsm2.4

00:01:43

passed #1289398
amd64 linux
gcc:softhsm2.6

00:01:41

passed #1289383
amd64 linux
gcc:stretch:amd64

00:01:57

passed #1289393
amd64 linux
gcc:tsan

00:02:09

passed #1289388
amd64 linux
gcc:tumbleweed:amd64

00:01:42

passed #1289389
amd64 linux
gcc:xenial:amd64

00:01:42

passed #1289403
amd64 windows
msvc:windows:amd64

00:01:24

passed #1289402
amd64 linux
nolibtool:sid:amd64

00:02:03

 
  Unit
passed #1289416
amd64 linux
unit:clang:asan

00:00:52

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

00:00:36

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

00:01:10

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

00:01:07

passed #1289418
amd64 linux
unit:clang:tsan

00:01:32

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

00:00:50

passed #1289415
amd64 linux
unit:gcc:asan

00:00:50

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

00:00:55

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

00:00:38

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

00:00:37

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

00:00:36

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

00:00:34

passed #1289419
amd64 linux
unit:gcc:mutexatomics

00:00:38

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

00:00:35

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

00:00:40

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

00:00:39

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

00:00:38

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

00:00:38

passed #1289417
amd64 linux
unit:gcc:tsan

00:01:58

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

00:00:36

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

00:00:40

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

00:00:50

 
  System
passed #1289438
amd64 linux
system:clang:asan

00:12:18

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

00:10:41

failed #1289445
amd64 libvirt
system:clang:freebsd11:amd64

00:10:28

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

00:10:02

passed #1289440
amd64 linux
system:clang:tsan

00:15:06

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

00:12:13

passed #1289437
amd64 linux
system:gcc:asan

00:12:36

failed #1289431
amd64 linux
system:gcc:buster:amd64

00:11:57

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

00:11:20

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

00:11:35

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

00:11:22

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

00:11:25

passed #1289441
amd64 linux
system:gcc:mutexatomics

00:11:26

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

00:10:43

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

00:10:24

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

00:10:55

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

00:11:15

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

00:11:23

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

00:15:49

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

00:11:01

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

00:10:47

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

00:11:46

 
  Docs
passed #1289448
amd64 linux
docs

00:02:07

 
  Postcheck
passed #1289452
amd64 linux
cppcheck

00:00:20

passed #1289449
amd64 linux
flake8

00:00:19

skipped #1289453
amd64 linux
gcov
passed #1289450
amd64 linux
pylint

00:00:23

passed #1289451
amd64 linux
scan-build

00:09:00

 
Name Stage Failure
failed
system:gcc: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 1462 files

Uploading artifacts as "archive" to coordinator... ok
id=1289439 responseStatus=201 Created token=SosQxX2n
Cleaning up file based variables
ERROR: Job failed: exit code 1
failed
system:gcc:buster:amd64 System
I:The following system tests failed:
I: kasp
make: *** [Makefile:491: test] Error 1
Uploading artifacts for failed job
Uploading artifacts...
untracked: found 5375 files

Uploading artifacts as "archive" to coordinator... ok
id=1289431 responseStatus=201 Created token=7sUV4e4B
Cleaning up file based variables
ERROR: Job failed: exit code 1
failed
system:clang:freebsd11:amd64 System
make: stopped in /builds/isc-projects/bind9/bin/tests/system
Uploading artifacts for failed job
Uploading artifacts...
Runtime platform
arch=amd64 os=freebsd pid=57684 revision=ece86343 version=13.5.0
untracked: found 4387 files

Uploading artifacts as "archive" to coordinator... ok
id=1289445 responseStatus=201 Created token=EstsnxHn
Cleaning up file based variables
Unsupported run stage 'cleanup_file_variables'
ERROR: Job failed: exit status 1