andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0011-Ticket-49967-entry-cache-corruption-after-failed-MOD.patch

bc0d6c
From a7ee52bd4b0bce82402a581ee16659ebb2f8d96e Mon Sep 17 00:00:00 2001
bc0d6c
From: Thierry Bordaz <tbordaz@redhat.com>
bc0d6c
Date: Wed, 24 Oct 2018 15:31:25 +0200
bc0d6c
Subject: [PATCH 1/2] Ticket 49967 - entry cache corruption after failed MODRDN
bc0d6c
bc0d6c
Bug Description:
bc0d6c
	During a MODRDN the DN cache is updated to replace
bc0d6c
	source DN with the target DN (modrdn_rename_entry_update_indexes)
bc0d6c
	If later a failure occurs (for example if BETXN_POSTOP fails) and
bc0d6c
	the txn is aborted, the target DN (for the specific entryID) remains
bc0d6c
	in the DN cache.
bc0d6c
bc0d6c
	If the entry is returned in a search, to build the DN there is
bc0d6c
	a lookup of the DN cache with the entryID. It retrieves the target DN
bc0d6c
	rather than the source DN
bc0d6c
bc0d6c
Fix Description:
bc0d6c
	In case of failure of the operation, the entry (from the entryID)
bc0d6c
	need to be cleared from the DN cache
bc0d6c
bc0d6c
https://pagure.io/389-ds-base/issue/49967
bc0d6c
bc0d6c
Reviewed by: Mark Reynolds
bc0d6c
bc0d6c
Platforms tested: F27
bc0d6c
bc0d6c
Flag Day: no
bc0d6c
bc0d6c
Doc impact: no
bc0d6c
bc0d6c
(cherry picked from commit ab4af68ef49fcdc5f2f6d0c1f5c7b9a5333b1bee)
bc0d6c
---
bc0d6c
 ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 13 +++++++++++++
bc0d6c
 1 file changed, 13 insertions(+)
bc0d6c
bc0d6c
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
bc0d6c
index 71e2a8fe0..e2e9d1b46 100644
bc0d6c
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
bc0d6c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
bc0d6c
@@ -1400,6 +1400,19 @@ common_return:
bc0d6c
                 }
bc0d6c
             }
bc0d6c
         }
bc0d6c
+
bc0d6c
+        if (ec && retval) {
bc0d6c
+            /* if the operation failed, the destination entry does not exist
bc0d6c
+             * but it has been added in dncache during cache_add_tentative
bc0d6c
+             * we need to remove it. Else a retrieval from ep_id can give the wrong DN
bc0d6c
+             */
bc0d6c
+            struct backdn *bdn = dncache_find_id(&inst->inst_dncache, ec->ep_id);
bc0d6c
+            slapi_log_err(SLAPI_LOG_CACHE, "ldbm_back_modrdn",
bc0d6c
+                                      "operation failed, the target entry is cleared from dncache (%s)\n", slapi_entry_get_dn(ec->ep_entry));
bc0d6c
+            CACHE_REMOVE(&inst->inst_dncache, bdn);
bc0d6c
+            CACHE_RETURN(&inst->inst_dncache, &bdn;;
bc0d6c
+        }
bc0d6c
+
bc0d6c
         /* remove the new entry from the cache if the op failed -
bc0d6c
            otherwise, leave it in */
bc0d6c
         if (ec && inst) {
bc0d6c
-- 
bc0d6c
2.17.2
bc0d6c