Blame SOURCES/0020-Ticket-50117-after-certain-failed-import-operation-i.patch

769039
From 90ba52ac8f655cb5d6cfd3f201c15f8004eb8414 Mon Sep 17 00:00:00 2001
769039
From: Thierry Bordaz <tbordaz@redhat.com>
769039
Date: Fri, 4 Jan 2019 12:24:56 +0100
769039
Subject: [PATCH] Ticket 50117 - after certain failed import operation,
769039
 impossible to replay an import operation
769039
769039
Bug Description:
769039
	At the beginning of an import, a flag is set to mark the target backend is busy.
769039
	Then import tests if there are pending operations. If such operations exist the import can not proceed and fails.
769039
	The problem is that in such case of pending operations, the import fails without resetting the busy flag.
769039
	It let the backend busy (until next reboot) and prevent new import.
769039
769039
Fix Description:
769039
	It needs to reset the busy flag if there are pending operations
769039
769039
https://pagure.io/389-ds-base/issue/50117
769039
769039
Reviewed by: Mark Reynolds, William Brown
769039
769039
Platforms tested: F27
769039
769039
Flag Day: no
769039
769039
Doc impact: no
769039
769039
(cherry picked from commit ff00b07402747aac403478a157adab75e306d7d1)
769039
(cherry picked from commit 630940ec119a90c3bbfc7cd3464eb02ab779b474)
769039
---
769039
 ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 14 ++++++++++++--
769039
 1 file changed, 12 insertions(+), 2 deletions(-)
769039
769039
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
769039
index 16b87ee6b..69a2af9cf 100644
769039
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
769039
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
769039
@@ -704,12 +704,22 @@ ldbm_back_ldif2ldbm(Slapi_PBlock *pb)
769039
     }
769039
 
769039
     /* check if an import/restore is already ongoing... */
769039
-    if ((instance_set_busy(inst) != 0) ||
769039
-        (slapi_counter_get_value(inst->inst_ref_count) > 0)) {
769039
+    if ((instance_set_busy(inst) != 0)) {
769039
         slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_ldif2ldbm", "ldbm: '%s' is already in the middle of "
769039
                                                             "another task and cannot be disturbed.\n",
769039
                       inst->inst_name);
769039
         return -1;
769039
+    } else {
769039
+        uint64_t refcnt;
769039
+        refcnt = slapi_counter_get_value(inst->inst_ref_count);
769039
+        if (refcnt > 0) {
769039
+            slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_ldif2ldbm", "ldbm: '%s' there are %d pending operation(s)."
769039
+                    " Import can not proceed until they are completed.\n",
769039
+                    inst->inst_name,
769039
+                    refcnt);
769039
+            instance_set_not_busy(inst);
769039
+            return -1;
769039
+        }
769039
     }
769039
 
769039
     if ((task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE)) {
769039
-- 
769039
2.17.2
769039