a35f00
Adapted patch for ipatests/test_integration/test_installation.py due to
a35f00
missing commit 930f4b3d1dc03f9e365b007b027d65e146a08f05 (Prevent local account
a35f00
takeover).
a35f00
a35f00
From 87e5c0500b76b7cbeecedc0c28d44095c7063186 Mon Sep 17 00:00:00 2001
a35f00
From: Christian Heimes <cheimes@redhat.com>
a35f00
Date: Thu, 24 Sep 2020 12:32:37 +0200
a35f00
Subject: [PATCH] Fix nsslapd-db-lock tuning of BDB backend
a35f00
a35f00
nsslapd-db-lock was moved from cn=config,cn=ldbm database,cn=plugins,cn=config
a35f00
entry to cn=bdb subentry. Manual patching of dse.ldif was no longer
a35f00
working. Installations with 389-DS 1.4.3 and newer are affected.
a35f00
a35f00
Low lock count can affect performance during high load, e.g. mass-import
a35f00
of users or lots of concurrent connections.
a35f00
a35f00
Bump minimal DS version to 1.4.3. Fedora 32 and RHEL 8.3 have 1.4.3.
a35f00
a35f00
Fixes: https://pagure.io/freeipa/issue/8515
a35f00
See: https://pagure.io/freeipa/issue/5914
a35f00
Signed-off-by: Christian Heimes <cheimes@redhat.com>
a35f00
Reviewed-By: Francois Cami <fcami@redhat.com>
a35f00
Reviewed-By: Francois Cami <fcami@redhat.com>
a35f00
---
a35f00
 freeipa.spec.in                               | 17 ++++++-----------
a35f00
 install/share/Makefile.am                     |  1 +
a35f00
 install/share/ldbm-tuning.ldif                |  4 ++++
a35f00
 install/updates/10-db-locks.update            | 10 ++++++++++
a35f00
 install/updates/Makefile.am                   |  1 +
a35f00
 ipapython/ipaldap.py                          |  1 +
a35f00
 ipaserver/install/dsinstance.py               |  9 ++++-----
a35f00
 .../test_customized_ds_config_install.py      |  3 ++-
a35f00
 .../test_integration/test_installation.py     | 19 +++++++++++++++++++
a35f00
 9 files changed, 48 insertions(+), 17 deletions(-)
a35f00
 create mode 100644 install/share/ldbm-tuning.ldif
a35f00
 create mode 100644 install/updates/10-db-locks.update
a35f00
a35f00
diff --git a/freeipa.spec.in b/freeipa.spec.in
a35f00
index 1db7d6457..8e6736b60 100755
a35f00
--- a/freeipa.spec.in
a35f00
+++ b/freeipa.spec.in
a35f00
@@ -55,10 +55,9 @@
a35f00
 %global selinux_policy_version 3.14.3-21
a35f00
 %global slapi_nis_version 0.56.1-4
a35f00
 %global python_ldap_version 3.1.0-1
a35f00
-# python3-lib389
a35f00
-# Fix for "Installation fails: Replica Busy"
a35f00
-# https://pagure.io/389-ds-base/issue/49818
a35f00
-%global ds_version 1.4.0.16
a35f00
+# 1.4.3 moved nsslapd-db-locks to cn=bdb sub-entry
a35f00
+# https://pagure.io/freeipa/issue/8515
a35f00
+%global ds_version 1.4.3
a35f00
 # Fix for TLS 1.3 PHA, RHBZ#1775158
a35f00
 %global httpd_version 2.4.37-21
a35f00
 
a35f00
@@ -89,13 +88,9 @@
a35f00
 
a35f00
 # fix for segfault in python3-ldap, https://pagure.io/freeipa/issue/7324
a35f00
 %global python_ldap_version 3.1.0-1
a35f00
-# Fix for create suffix
a35f00
-# https://pagure.io/389-ds-base/issue/49984
a35f00
-%if 0%{?fedora} >= 30
a35f00
-%global ds_version 1.4.1.1
a35f00
-%else
a35f00
-%global ds_version 1.4.0.21
a35f00
-%endif
a35f00
+# 1.4.3 moved nsslapd-db-locks to cn=bdb sub-entry
a35f00
+# https://pagure.io/freeipa/issue/8515
a35f00
+%global ds_version 1.4.3
a35f00
 
a35f00
 # Fix for TLS 1.3 PHA, RHBZ#1775146
a35f00
 %if 0%{?fedora} >= 31
a35f00
diff --git a/install/share/Makefile.am b/install/share/Makefile.am
a35f00
index 53bd8f5d5..53485edfa 100644
a35f00
--- a/install/share/Makefile.am
a35f00
+++ b/install/share/Makefile.am
a35f00
@@ -102,6 +102,7 @@ dist_app_DATA =				\
a35f00
 	ipaca_default.ini		\
a35f00
 	ipaca_customize.ini		\
a35f00
 	ipaca_softhsm2.ini		\
a35f00
+	ldbm-tuning.ldif		\
a35f00
 	$(NULL)
a35f00
 
a35f00
 kdcproxyconfdir = $(IPA_SYSCONF_DIR)/kdcproxy
a35f00
diff --git a/install/share/ldbm-tuning.ldif b/install/share/ldbm-tuning.ldif
a35f00
new file mode 100644
a35f00
index 000000000..765ccb01a
a35f00
--- /dev/null
a35f00
+++ b/install/share/ldbm-tuning.ldif
a35f00
@@ -0,0 +1,4 @@
a35f00
+dn: cn=bdb,cn=config,cn=ldbm database,cn=plugins,cn=config
a35f00
+changetype: modify
a35f00
+replace: nsslapd-db-locks
a35f00
+nsslapd-db-locks: 50000
a35f00
diff --git a/install/updates/10-db-locks.update b/install/updates/10-db-locks.update
a35f00
new file mode 100644
a35f00
index 000000000..31d2e4352
a35f00
--- /dev/null
a35f00
+++ b/install/updates/10-db-locks.update
a35f00
@@ -0,0 +1,10 @@
a35f00
+# Fix nsslapd-db-locks move
a35f00
+# https://pagure.io/freeipa/issue/8515
a35f00
+
a35f00
+# replace 389-DS default with 50000 locks
a35f00
+dn: cn=bdb,cn=config,cn=ldbm database,cn=plugins,cn=config
a35f00
+replace: nsslapd-db-locks:10000::50000
a35f00
+
a35f00
+# remove setting from old location
a35f00
+dn: cn=config,cn=ldbm database,cn=plugins,cn=config
a35f00
+remove: nsslapd-db-locks: 50000
a35f00
diff --git a/install/updates/Makefile.am b/install/updates/Makefile.am
a35f00
index 8a4d9cc6c..957ad4fa2 100644
a35f00
--- a/install/updates/Makefile.am
a35f00
+++ b/install/updates/Makefile.am
a35f00
@@ -4,6 +4,7 @@ appdir = $(IPA_DATA_DIR)/updates
a35f00
 app_DATA =				\
a35f00
 	05-pre_upgrade_plugins.update	\
a35f00
 	10-config.update		\
a35f00
+	10-db-locks.update		\
a35f00
 	10-enable-betxn.update		\
a35f00
 	10-ipapwd.update		\
a35f00
 	10-selinuxusermap.update	\
a35f00
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
a35f00
index 3eac95a87..5c43413cc 100644
a35f00
--- a/ipapython/ipaldap.py
a35f00
+++ b/ipapython/ipaldap.py
a35f00
@@ -753,6 +753,7 @@ class LDAPClient:
a35f00
         'nsslapd-anonlimitsdn': True,
a35f00
         'nsslapd-minssf-exclude-rootdse': True,
a35f00
         'nsslapd-enable-upgrade-hash': True,
a35f00
+        'nsslapd-db-locks': True,
a35f00
     })
a35f00
 
a35f00
     time_limit = -1.0   # unlimited
a35f00
diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py
a35f00
index 3fc0de371..065c6f78f 100644
a35f00
--- a/ipaserver/install/dsinstance.py
a35f00
+++ b/ipaserver/install/dsinstance.py
a35f00
@@ -226,6 +226,7 @@ class DsInstance(service.Service):
a35f00
 
a35f00
         self.step("creating directory server instance", self.__create_instance)
a35f00
         self.step("configure autobind for root", self.__root_autobind)
a35f00
+        self.step("tune ldbm plugin", self.__tune_ldbm)
a35f00
         self.step("stopping directory server", self.__stop_instance)
a35f00
         self.step("updating configuration in dse.ldif", self.__update_dse_ldif)
a35f00
         self.step("starting directory server", self.__start_instance)
a35f00
@@ -592,6 +593,9 @@ class DsInstance(service.Service):
a35f00
         # Done!
a35f00
         logger.debug("completed creating DS instance")
a35f00
 
a35f00
+    def __tune_ldbm(self):
a35f00
+        self._ldap_mod("ldbm-tuning.ldif")
a35f00
+
a35f00
     def __update_dse_ldif(self):
a35f00
         """
a35f00
         This method updates dse.ldif right after instance creation. This is
a35f00
@@ -610,11 +614,6 @@ class DsInstance(service.Service):
a35f00
             temp_filename = new_dse_ldif.name
a35f00
             with open(dse_filename, "r") as input_file:
a35f00
                 parser = installutils.ModifyLDIF(input_file, new_dse_ldif)
a35f00
-                parser.replace_value(
a35f00
-                        'cn=config,cn=ldbm database,cn=plugins,cn=config',
a35f00
-                        'nsslapd-db-locks',
a35f00
-                        [b'50000']
a35f00
-                        )
a35f00
                 if self.config_ldif:
a35f00
                     # parse modifications from ldif file supplied by the admin
a35f00
                     with open(self.config_ldif, "r") as config_ldif:
a35f00
diff --git a/ipatests/test_integration/test_customized_ds_config_install.py b/ipatests/test_integration/test_customized_ds_config_install.py
a35f00
index a2fcc7dd2..95195a014 100644
a35f00
--- a/ipatests/test_integration/test_customized_ds_config_install.py
a35f00
+++ b/ipatests/test_integration/test_customized_ds_config_install.py
a35f00
@@ -4,7 +4,8 @@ from ipatests.pytest_ipa.integration import tasks
a35f00
 
a35f00
 DIRSRV_CONFIG_MODS = """
a35f00
 # https://fedorahosted.org/freeipa/ticket/4949
a35f00
-dn: cn=config,cn=ldbm database,cn=plugins,cn=config
a35f00
+# https://pagure.io/freeipa/issue/8515
a35f00
+dn: cn=bdb,cn=config,cn=ldbm database,cn=plugins,cn=config
a35f00
 changetype: modify
a35f00
 replace: nsslapd-db-locks
a35f00
 nsslapd-db-locks: 100000
a35f00
diff --git a/ipatests/test_integration/test_installation.py b/ipatests/test_integration/test_installation.py
a35f00
index c939c6450..ec826edb7 100644
a35f00
--- a/ipatests/test_integration/test_installation.py
a35f00
+++ b/ipatests/test_integration/test_installation.py
a35f00
@@ -972,6 +972,25 @@ class TestInstallMaster(IntegrationTest):
a35f00
         )
a35f00
         assert "nsslapd-enable-upgrade-hash: off" in result.stdout_text
a35f00
 
a35f00
+    def test_ldbm_tuning(self):
a35f00
+        # check db-locks in new cn=bdb subentry (1.4.3+)
a35f00
+        result = tasks.ldapsearch_dm(
a35f00
+            self.master,
a35f00
+            "cn=bdb,cn=config,cn=ldbm database,cn=plugins,cn=config",
a35f00
+            ["nsslapd-db-locks"],
a35f00
+            scope="base"
a35f00
+        )
a35f00
+        assert "nsslapd-db-locks: 50000" in result.stdout_text
a35f00
+
a35f00
+        # no db-locks configuration in old global entry
a35f00
+        result = tasks.ldapsearch_dm(
a35f00
+            self.master,
a35f00
+            "cn=config,cn=ldbm database,cn=plugins,cn=config",
a35f00
+            ["nsslapd-db-locks"],
a35f00
+            scope="base"
a35f00
+        )
a35f00
+        assert "nsslapd-db-locks" not in result.stdout_text
a35f00
+
a35f00
 
a35f00
 class TestInstallMasterKRA(IntegrationTest):
a35f00
 
a35f00
-- 
a35f00
2.26.2
a35f00