Avoid failures during unit tests

Unit tests fail always on builders with 56 cores. There is issue with
limit of threads count in netmgr. Internal counter in hp.c does not
reset on each unit tests teardown. With many cores, it can lead to
assertion failures during the test.
This commit is contained in:
Petr Menšík 2021-01-21 11:55:40 +01:00
parent f3d54bbf18
commit 21682d00a6
2 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,84 @@
From 0175b942efc2fb6a05a2c76d62a9fb9157141757 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
Date: Wed, 20 Jan 2021 01:01:52 +0100
Subject: [PATCH] Workaround errors in unit test on 56 CPU machine
hp.c should be just implementation detail, but unit tests use it
repeatedly without resetting tid_v_base. Reset the base counter, when
number of processors is configured. Configure it when creating network
manager.
Use id of current thread as a base. Should be usually 0, but must not be
below id of the main thread.
---
bin/named/main.c | 7 -------
lib/isc/hp.c | 1 +
lib/isc/netmgr/netmgr.c | 8 ++++++++
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/bin/named/main.c b/bin/named/main.c
index 9836de9d7f..d1be43a632 100644
--- a/bin/named/main.c
+++ b/bin/named/main.c
@@ -24,7 +24,6 @@
#include <isc/dir.h>
#include <isc/file.h>
#include <isc/hash.h>
-#include <isc/hp.h>
#include <isc/httpd.h>
#include <isc/netmgr.h>
#include <isc/os.h>
@@ -909,12 +908,6 @@ create_managers(void) {
"using %u UDP listener%s per interface", named_g_udpdisp,
named_g_udpdisp == 1 ? "" : "s");
- /*
- * We have ncpus network threads, ncpus worker threads, ncpus
- * old network threads - make it 4x just to be safe. The memory
- * impact is negligible.
- */
- isc_hp_init(4 * named_g_cpus);
named_g_nm = isc_nm_start(named_g_mctx, named_g_cpus);
if (named_g_nm == NULL) {
UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_nm_start() failed");
diff --git a/lib/isc/hp.c b/lib/isc/hp.c
index 3ea13bbe24..e4a98afc82 100644
--- a/lib/isc/hp.c
+++ b/lib/isc/hp.c
@@ -95,6 +95,7 @@ void
isc_hp_init(int max_threads) {
isc__hp_max_threads = max_threads;
isc__hp_max_retired = max_threads * HP_MAX_HPS;
+ atomic_store_release(&tid_v_base, tid());
}
isc_hp_t *
diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c
index 46f0758620..e3469f4c3a 100644
--- a/lib/isc/netmgr/netmgr.c
+++ b/lib/isc/netmgr/netmgr.c
@@ -17,6 +17,7 @@
#include <isc/buffer.h>
#include <isc/condition.h>
#include <isc/errno.h>
+#include <isc/hp.h>
#include <isc/magic.h>
#include <isc/mem.h>
#include <isc/netmgr.h>
@@ -238,6 +239,13 @@ isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
atomic_init(&mgr->keepalive, 30000);
atomic_init(&mgr->advertised, 30000);
+ /*
+ * We have ncpus network threads, ncpus worker threads, ncpus
+ * old network threads - make it 4x just to be safe. The memory
+ * impact is negligible.
+ */
+ isc_hp_init(4 * workers);
+
isc_mutex_init(&mgr->reqlock);
isc_mempool_create(mgr->mctx, sizeof(isc__nm_uvreq_t), &mgr->reqpool);
isc_mempool_setname(mgr->reqpool, "nm_reqpool");
--
2.26.2

View File

@ -118,6 +118,8 @@ Patch157:bind-9.11-fips-tests.patch
Patch164:bind-9.11-rh1666814.patch
Patch170:bind-9.11-feature-test-named.patch
Patch171:bind-9.11-tests-variants.patch
# https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/4582
Patch172:bind-9.16-unit-tests-multicore.patch
Requires(post): systemd
Requires(preun): systemd
@ -431,6 +433,7 @@ in HTML and PDF format.
%patch164 -p1 -b .rh1666814
%patch170 -p1 -b .featuretest-named
%patch171 -p1 -b .test-variant
%patch172 -p1 -b .multicore
%if %{with PKCS11}
%patch135 -p1 -b .config-pkcs11
@ -1157,6 +1160,7 @@ fi;
%changelog
* Thu Jan 21 2021 Petr Menšík <pemensik@redhat.com> - 32:9.16.11-1
- Update to 9.16.11 (#1827602)
- Avoid unit test failures on machines with many cores
* Thu Jan 14 2021 Petr Menšík <pemensik@redhat.com> - 32:9.16.10-2
- Update to 9.16.10