Blame SOURCES/0006-Ticket-50741-bdb_start-Detected-Disorderly-Shutdown-.patch

8394b4
From b5d7a0b34d532335da7171dd7a308f95638c91c8 Mon Sep 17 00:00:00 2001
8394b4
From: Thierry Bordaz <tbordaz@redhat.com>
8394b4
Date: Tue, 19 Nov 2019 09:56:46 +0100
8394b4
Subject: [PATCH] Ticket 50741 - bdb_start - Detected Disorderly Shutdown last
8394b4
 time Directory Server was running
8394b4
8394b4
Bug description:
8394b4
	At startup plugins are started (plugin_dependency_startall) including ldbm database
8394b4
	that read/remove the guardian file (bdb_start).
8394b4
	If one of the plugin fails to start, for example because of a missing dependency,
8394b4
	the statup function just exits without recreating the guardian file.
8394b4
	The next restart will not find the guardian file, trigger a recovery and
8394b4
	log the alarming message "Detected Disorderly Shutdown last time Directory Server was running..."
8394b4
8394b4
Fix description:
8394b4
	In case the startup function fails it should call the closing function of all
8394b4
	started plugin: plugin_closeall
8394b4
	The fix also contains fixes for plugin acceptance tests. If DS startup is expected
8394b4
	to fail, it is caught by subprocess.CalledProcessError but actually the startup
8394b4
	function can also return ValueError exception
8394b4
8394b4
https://pagure.io/389-ds-base/issue/50741
8394b4
8394b4
Reviewed By: Mark Reynolds
8394b4
---
8394b4
 dirsrvtests/tests/suites/plugins/acceptance_test.py | 6 +++---
8394b4
 ldap/servers/slapd/plugin.c                         | 1 +
8394b4
 2 files changed, 4 insertions(+), 3 deletions(-)
8394b4
8394b4
diff --git a/dirsrvtests/tests/suites/plugins/acceptance_test.py b/dirsrvtests/tests/suites/plugins/acceptance_test.py
8394b4
index 8aacb74be..cdb629eef 100644
8394b4
--- a/dirsrvtests/tests/suites/plugins/acceptance_test.py
8394b4
+++ b/dirsrvtests/tests/suites/plugins/acceptance_test.py
8394b4
@@ -64,7 +64,7 @@ def check_dependency(inst, plugin, online=True):
8394b4
         acct_usability.remove('nsslapd-plugin-depends-on-named', plugin.rdn)
8394b4
     else:
8394b4
         plugin.disable()
8394b4
-        with pytest.raises(subprocess.CalledProcessError):
8394b4
+        with pytest.raises((subprocess.CalledProcessError, ValueError)):
8394b4
             inst.restart()
8394b4
         dse_ldif = DSEldif(inst)
8394b4
         dse_ldif.delete(acct_usability.dn, 'nsslapd-plugin-depends-on-named')
8394b4
@@ -1739,14 +1739,14 @@ def test_rootdn(topo, args=None):
8394b4
     # First, test that invalid plugin changes are rejected
8394b4
     if args is None:
8394b4
         plugin.replace('rootdn-deny-ip', '12.12.ZZZ.12')
8394b4
-        with pytest.raises(subprocess.CalledProcessError):
8394b4
+        with pytest.raises((subprocess.CalledProcessError, ValueError)):
8394b4
             inst.restart()
8394b4
         dse_ldif = DSEldif(inst)
8394b4
         dse_ldif.delete(plugin.dn, 'rootdn-deny-ip')
8394b4
         _rootdn_restart(inst)
8394b4
 
8394b4
         plugin.replace('rootdn-allow-host', 'host._.com')
8394b4
-        with pytest.raises(subprocess.CalledProcessError):
8394b4
+        with pytest.raises((subprocess.CalledProcessError, ValueError)):
8394b4
             inst.restart()
8394b4
         dse_ldif = DSEldif(inst)
8394b4
         dse_ldif.delete(plugin.dn, 'rootdn-allow-host')
8394b4
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
8394b4
index a77bb5aa7..b00c1bd8f 100644
8394b4
--- a/ldap/servers/slapd/plugin.c
8394b4
+++ b/ldap/servers/slapd/plugin.c
8394b4
@@ -1811,6 +1811,7 @@ plugin_dependency_startall(int argc, char **argv, char *errmsg __attribute__((un
8394b4
             }
8394b4
             i++;
8394b4
         }
8394b4
+        plugin_closeall(1 /* Close Backends */, 1 /* Close Globals */);
8394b4
         exit(1);
8394b4
     }
8394b4
 
8394b4
-- 
8394b4
2.21.1
8394b4