andykimpe / rpms / 389-ds-base

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

Blame 0284-Ticket-47750-Need-to-refresh-cache-entry-after-calle.patch

dc8c34
From b4ef87c201238452b4f7653cce127d4b23ea4106 Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Tue, 16 Dec 2014 10:37:02 -0500
dc8c34
Subject: [PATCH 284/305] Ticket 47750 - Need to refresh cache entry after
dc8c34
 called betxn postop plugins
dc8c34
dc8c34
Bug Description:  If deleting an entry triggers multiple betxn plugins, the
dc8c34
                  entry might not be removed the cache - which prevents that
dc8c34
                  same entry(same dn) from being re-added(error 68).  For
dc8c34
                  example, the RI and memberOf plugins are enabled.  Then we
dc8c34
                  add a user to a group.  This adds the memberOf attribute
dc8c34
                  to the entry.  We then delete that user, which triggers the
dc8c34
                  RI plugin, which then triggers the memberOf plugin.  So the
dc8c34
                  entry that is deleted gets modified in bvetxn postop, and
dc8c34
                  has its its cache entry replaced.  This then confuses the
dc8c34
                  cache logic at the end of the delete operation, and the entry
dc8c34
                  is not removed from the cache.
dc8c34
dc8c34
Fix Description:  Refresh the cache entry after calling the betxn postop plugins.
dc8c34
                  If the entry has changed, return the old old entry and proceed
dc8c34
                  with the new one.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47750
dc8c34
dc8c34
Reviewed by: nhosoi & rmeggins (Thanks!!)
dc8c34
dc8c34
(cherry picked from commit 4a5eee63f45ed290375440827c92af9b2347a177)
dc8c34
(cherry picked from commit 5ef3183a434e694c120536c073a6f9f6e4cfa898)
dc8c34
---
dc8c34
 ldap/servers/slapd/back-ldbm/ldbm_delete.c | 7 +++++++
dc8c34
 1 file changed, 7 insertions(+)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
dc8c34
index e06f241..e86d45f 100644
dc8c34
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
dc8c34
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
dc8c34
@@ -1116,6 +1116,13 @@ ldbm_back_delete( Slapi_PBlock *pb )
dc8c34
 
dc8c34
 	/* delete from cache and clean up */
dc8c34
 	if (e) {
dc8c34
+		struct backentry *old_e = e;
dc8c34
+
dc8c34
+		e = cache_find_id(&inst->inst_cache,e->ep_id);
dc8c34
+		if(e != old_e){
dc8c34
+			/* return the old entry, and proceed with the new one */
dc8c34
+			CACHE_RETURN(&inst->inst_cache, &old_e);
dc8c34
+		}
dc8c34
 		if (cache_is_in_cache(&inst->inst_cache, e)) {
dc8c34
 			ep_id = e->ep_id;
dc8c34
 			CACHE_REMOVE(&inst->inst_cache, e);
dc8c34
-- 
dc8c34
1.9.3
dc8c34