Merge branch '3801-reduce-memory-bloat-caused-by-delayed-view-detach-v9_18' into 'v9_18'

[9.18] Detach the views in zone_shutdown(), not in zone_free()

See merge request isc-projects/bind9!7388
This commit is contained in:
Ondřej Surý 2023-01-17 22:17:29 +00:00
commit 29bc0daed1
4 changed files with 19 additions and 7 deletions

View file

@ -1,3 +1,7 @@
6069. [bug] Detach from the view in zone_shutdown() to
release the memory held by the dead view
early. [GL #3801]
6068. [bug] Downloading a zone via TLS from a server which does
not negotiate "dot" ALPN token could crash BIND
on shutdown. That has been fixed. [GL #3767]

View file

@ -6919,6 +6919,7 @@ add_keydata_zone(dns_view_t *view, const char *directory, isc_mem_t *mctx) {
dns_zone_attach(pview->managed_keys,
&view->managed_keys);
dns_zone_setview(pview->managed_keys, view);
dns_zone_setviewcommit(pview->managed_keys);
dns_view_detach(&pview);
dns_zone_synckeyzone(view->managed_keys);
return (ISC_R_SUCCESS);

View file

@ -35,7 +35,9 @@ Feature Changes
Bug Fixes
~~~~~~~~~
- None.
- A constant stream of zone additions and deletions via ``rndc reconfig`` could
cause increased memory consumption due to delayed cleaning of view memory.
This has been fixed. :gl:`#3801`
Known Issues
~~~~~~~~~~~~

View file

@ -1236,6 +1236,8 @@ zone_free(dns_zone_t *zone) {
INSIST(zone->readio == NULL);
INSIST(zone->statelist == NULL);
INSIST(zone->writeio == NULL);
INSIST(zone->view == NULL);
INSIST(zone->prev_view == NULL);
if (zone->task != NULL) {
isc_task_detach(&zone->task);
@ -1243,12 +1245,6 @@ zone_free(dns_zone_t *zone) {
if (zone->loadtask != NULL) {
isc_task_detach(&zone->loadtask);
}
if (zone->view != NULL) {
dns_view_weakdetach(&zone->view);
}
if (zone->prev_view != NULL) {
dns_view_weakdetach(&zone->prev_view);
}
/* Unmanaged objects */
while (!ISC_LIST_EMPTY(zone->setnsec3param_queue)) {
@ -15023,6 +15019,15 @@ zone_shutdown(isc_task_t *task, isc_event_t *event) {
LOCK_ZONE(zone);
INSIST(zone != zone->raw);
/* Detach the views early, we don't need them anymore */
if (zone->view != NULL) {
dns_view_weakdetach(&zone->view);
}
if (zone->prev_view != NULL) {
dns_view_weakdetach(&zone->prev_view);
}
if (linked) {
isc_refcount_decrement(&zone->irefs);
}