bind9/lib/dns
Aram Sargsyan aed9cafd5c Lock the catalog zone when reconfiguring it
A catalog zone is updated in an offloaded thread, which is not
stopped during a reconfiguration in an exclusive mode, and so
can cause a race condition with it.

Waiting for the offloaded threads to complete their work before
entering into the exclusive mode can potentially cause unwanted
delays, because offloaded threads are generally "allowed" to take
a longer amount of time before they complete.

Add a dns_catz_zone_prereconfig()/dns_catz_zone_postreconfig() pair
of functions which currently just lock the catalog zone when
reconfiguring it. The change should eliminate the race.

As a side note, there was already a similar pair of functions,
dns_catz_prereconfig() and dns_catz_postreconfig() which are called
before and after reconfiguring a 'dns_catz_zones_t' object.

Below are the stack traces of the reconfiguration thread which has
asserted, and a catalog zone update thread which was caught in the
middle of its work despite the fact that the exclusive mode is
turned on.

                Stack trace of thread 23859:
                #0  0x00007f80e7b8e52f raise (libc.so.6)
                #1  0x00007f80e7b61e65 abort (libc.so.6)
                #2  0x0000000000422558 assertion_failed (named)
                #3  0x00007f80eaa6799e isc_assertion_failed (libisc-9.18.41.so)
                #4  0x00007f80ea5bc788 dns_catz_entry_getname (libdns-9.18.41.so)
                #5  0x000000000042ce0e catz_reconfigure (named)
                #6  0x000000000042d3c5 configure_catz_zone (named)
                #7  0x000000000042d7a4 configure_catz (named)
                #8  0x0000000000430645 configure_view (named)
                #9  0x000000000043d998 load_configuration (named)
                #10 0x000000000044184f loadconfig (named)
                #11 0x0000000000442525 named_server_reconfigcommand (named)
                #12 0x000000000041b277 named_control_docommand (named)
                #13 0x000000000041c74a control_command (named)
                #14 0x00007f80eaa912ae task_run (libisc-9.18.41.so)
                #15 0x00007f80eaa914cd isc_task_run (libisc-9.18.41.so)
                #16 0x00007f80eaa46435 isc__nm_async_task (libisc-9.18.41.so)
                #17 0x00007f80eaa467aa process_netievent (libisc-9.18.41.so)
                #18 0x00007f80eaa475a6 process_queue (libisc-9.18.41.so)
                #19 0x00007f80eaa46227 process_all_queues (libisc-9.18.41.so)
                #20 0x00007f80eaa462a1 async_cb (libisc-9.18.41.so)
                #21 0x00007f80e8d01893 uv__async_io.part.3 (libuv.so.1)
                #22 0x00007f80e8d13ac4 uv__io_poll (libuv.so.1)
                #23 0x00007f80e8d023fb uv_run (libuv.so.1)
                #24 0x00007f80eaa45ced nm_thread (libisc-9.18.41.so)
                #25 0x00007f80eaa9bda3 isc__trampoline_run (libisc-9.18.41.so)
                #26 0x00007f80e7f1e1ca start_thread (libpthread.so.0)
                #27 0x00007f80e7b798d3 __clone (libc.so.6)
    ...
    ...
                Stack trace of thread 23912:
                #0  0x00007f80ea5bc2da dns_catz_options_setdefault (libdns-9.18.41.so)
                #1  0x00007f80ea5bd411 dns__catz_zones_merge (libdns-9.18.41.so)
                #2  0x00007f80ea5c3c2f dns__catz_update_cb (libdns-9.18.41.so)
                #3  0x00007f80eaa4fee9 isc__nm_work_run (libisc-9.18.41.so)
                #4  0x00007f80eaa9bda3 isc__trampoline_run (libisc-9.18.41.so)
                #5  0x00007f80eaa4ff48 isc__nm_work_cb (libisc-9.18.41.so)
                #6  0x00007f80e8cfc75e worker (libuv.so.1)
                #7  0x00007f80e7f1e1ca start_thread (libpthread.so.0)
                #8  0x00007f80e7b798d3 __clone (libc.so.6)
2025-12-17 14:54:49 +00:00
..
include Lock the catalog zone when reconfiguring it 2025-12-17 14:54:49 +00:00
rdata switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
.gitignore Add support for User Statically Defined Tracing (USDT) probes 2023-08-21 18:39:53 +02:00
acl.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
acl_p.h Move the library init and shutdown to executables 2025-02-22 16:19:00 +01:00
adb.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
badcache.c Apply the changes from updated set_if_not_null semantic patch 2025-10-08 17:44:50 +02:00
byaddr.c Share reverse (ARPA) domain names 2025-10-01 12:16:05 +02:00
cache.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
callbacks.c Convert all categories and modules into static lists 2024-08-20 12:50:39 +00:00
catz.c Lock the catalog zone when reconfiguring it 2025-12-17 14:54:49 +00:00
client.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
clientinfo.c refactor dns_clientinfo_init(); use separate function to set ECS 2023-02-07 23:48:22 -08:00
compress.c remove the 'name_coff' parameter in dns_name_towire() 2025-02-25 12:53:25 -08:00
db.c Fix formatting 2025-12-09 13:32:24 +01:00
db_p.h Switch qpzone to rdatavec 2025-12-10 12:18:34 +01:00
dbiterator.c Implement dns_dbiterator_seek3 2025-12-10 14:18:52 +01:00
diff.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
dispatch.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
dlz.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
dlz_p.h Move the library init and shutdown to executables 2025-02-22 16:19:00 +01:00
dns64.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
dnssec.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
dnstap.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
ds.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
dst_api.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
dst_internal.h Minor refactor of dst code 2025-10-01 12:25:53 +00:00
dst_openssl.h Remove C++ support from the public header 2024-12-18 13:10:39 +01:00
dst_parse.c Use isc_result_t more consistently 2025-12-03 13:45:43 -08:00
dst_parse.h Remove C++ support from the public header 2024-12-18 13:10:39 +01:00
dyndb.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
dyndb_p.h Move the library init and shutdown to executables 2025-02-22 16:19:00 +01:00
ecs.c Remove redundant parentheses from the return statement 2024-11-19 12:27:22 +01:00
ede.c add dns_message API to add EDNS options 2025-11-21 11:13:18 -08:00
fixedname.c Simplify dns_name_init() 2025-02-25 12:17:34 +01:00
forward.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00
gen.c Silence "may be truncated" warnings 2025-08-04 15:38:17 +02:00
geoip2.c Remove redundant parentheses from the return statement 2024-11-19 12:27:22 +01:00
gssapi_link.c Deprecate max-rsa-exponent-size, always use 4096 instead 2025-05-21 00:50:08 +02:00
gssapictx.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
hmac_link.c Rename isc_result_t ret; to isc_result_t result; 2025-12-03 13:45:43 -08:00
ipkeylist.c Simplify dns_name_init() 2025-02-25 12:17:34 +01:00
iptable.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
journal.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
kasp.c Rename isc_result_t ret; to isc_result_t result; 2025-12-03 13:45:43 -08:00
key.c Cleanup the DST cryptographic API 2025-05-20 09:52:35 +02:00
keydata.c Remove redundant parentheses from the return statement 2024-11-19 12:27:22 +01:00
keymgr.c Make keymgr state machine more robust 2025-12-05 12:14:14 +01:00
keystore.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
keytable.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00
lib.c Replace per-zone lock buckets with global buckets 2025-07-09 15:27:38 +02:00
master.c Fix formatting 2025-12-09 13:32:24 +01:00
masterdump.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
meson.build Add rdatavec 2025-12-10 12:18:34 +01:00
message.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
name.c dns_name_totext() can now resize dynamic buffers 2025-12-09 12:26:30 -08:00
nametree.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00
ncache.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
notify.c switch to CHECK where it wasn't being used 2025-12-03 13:45:42 -08:00
nsec.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
nsec3.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
nta.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
openssl_link.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
openssl_shim.h Move the dst__openssl_toresult to isc_tls unit 2024-08-08 11:59:41 +02:00
opensslecdsa_link.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
openssleddsa_link.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
opensslrsa_link.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
order.c Use ControlStatementsExceptControlMacros for SpaceBeforeParens 2025-08-19 07:58:33 +02:00
peer.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
private.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
probes-dns.d Use unique names for probes.d files 2025-09-24 13:18:13 +02:00
qp.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00
qp_p.h Fix formatting after refactor 2025-12-10 11:28:10 +01:00
qpcache.c Implement dns_dbiterator_seek3 2025-12-10 14:18:52 +01:00
qpcache_p.h Remove C++ support from the public header 2024-12-18 13:10:39 +01:00
qpzone.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
qpzone_p.h Replace per-zone lock buckets with global buckets 2025-07-09 15:27:38 +02:00
rcode.c standardize CHECK and RETERR macros 2025-12-03 13:26:28 -08:00
rdata.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
rdatalist.c dns_rdatalist functions are not for general use 2025-09-15 16:11:50 +00:00
rdataset.c Switch qpzone to rdatavec 2025-12-10 12:18:34 +01:00
rdatasetiter.c add DNS_DBITERATOR_FOREACH and DNS_RDATASETITER_FOREACH 2025-05-27 21:08:09 -07:00
rdataslab.c Copy only the raw data when we are copying dns_slab{header,vec} 2025-12-16 18:09:09 +01:00
rdataslab_p.h Use ISC_UxxTOyy_BE macros for {peek,get,put}_uint16 macros 2025-08-18 12:36:47 +02:00
rdatavec.c Copy only the raw data when we are copying dns_slab{header,vec} 2025-12-16 18:09:09 +01:00
rdatavec_p.h Fix formatting 2025-12-10 12:18:34 +01:00
remote.c simplify code around isc_mem_put() and isc_mem_free() 2025-05-28 17:22:32 -07:00
request.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
resconf.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
resolver.c Cleanup the extra dns_rdataset_disassociate() code 2025-12-17 15:19:55 +01:00
result.c clean up result codes that are never used 2025-01-23 15:54:57 -08:00
rootns.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
rpz.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00
rriterator.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
rrl.c Use ControlStatementsExceptControlMacros for SpaceBeforeParens 2025-08-19 07:58:33 +02:00
sdlz.c Cleanup the extra dns_rdataset_disassociate() code 2025-12-17 15:19:55 +01:00
skr.c use a standard CLEANUP macro 2025-12-03 13:45:43 -08:00
soa.c Simplify dns_name_init() 2025-02-25 12:17:34 +01:00
ssu.c Use ControlStatementsExceptControlMacros for SpaceBeforeParens 2025-08-19 07:58:33 +02:00
ssu_external.c Remove redundant parentheses from the return statement 2024-11-19 12:27:22 +01:00
stats.c Use clang-format-20 to update formatting 2025-06-25 12:44:22 +10:00
tests Move all the unit tests to /tests/<libname>/ 2022-05-28 14:53:02 -07:00
time.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
tkey.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
transport.c switch to CHECK where it wasn't being used 2025-12-03 13:45:42 -08:00
tsig.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
tsig_p.h Remove C++ support from the public header 2024-12-18 13:10:39 +01:00
ttl.c standardize CHECK and RETERR macros 2025-12-03 13:26:28 -08:00
unreachcache.c Change the loopmgr to be singleton 2025-07-23 22:44:16 +02:00
update.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
validator.c Cleanup the extra dns_rdataset_disassociate() code 2025-12-17 15:19:55 +01:00
view.c Cleanup the extra dns_rdataset_disassociate() code 2025-12-17 15:19:55 +01:00
xfrin.c Implement qpzone specific update path 2025-12-09 12:55:30 +01:00
zone.c Cleanup the extra dns_rdataset_disassociate() code 2025-12-17 15:19:55 +01:00
zone_p.h Export zone functions 2025-11-06 10:54:54 +01:00
zonefetch.c Apply the dns_rdataset_cleanup patch through the codebase 2025-12-17 15:19:55 +01:00
zoneverify.c Cleanup the extra dns_rdataset_disassociate() code 2025-12-17 15:19:55 +01:00
zt.c Fix formatting after refactor 2025-12-10 11:28:10 +01:00