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

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