From 9295966f1f7e7235f13215b756398915df54fa6a Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Dec 16 2014 18:13:24 +0000 Subject: Ticket 47750 - Need to refresh cache entry after called betxn postop plugins Bug Description: If deleting an entry triggers multiple betxn plugins, the entry might not be removed the cache - which prevents that same entry(same dn) from being re-added(error 68). For example, the RI and memberOf plugins are enabled. Then we add a user to a group. This adds the memberOf attribute to the entry. We then delete that user, which triggers the RI plugin, which then triggers the memberOf plugin. So the entry that is deleted gets modified in bvetxn postop, and has its its cache entry replaced. This then confuses the cache logic at the end of the delete operation, and the entry is not removed from the cache. Fix Description: Refresh the cache entry after calling the betxn postop plugins. If the entry has changed, return the old old entry and proceed with the new one. https://fedorahosted.org/389/ticket/47750 Reviewed by: nhosoi & rmeggins (Thanks!!) (cherry picked from commit 4a5eee63f45ed290375440827c92af9b2347a177) --- diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c index ba2af26..89710d4 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c @@ -1199,6 +1199,13 @@ ldbm_back_delete( Slapi_PBlock *pb ) /* delete from cache and clean up */ if (e) { + struct backentry *old_e = e; + + e = cache_find_id(&inst->inst_cache,e->ep_id); + if(e != old_e){ + /* return the old entry, and proceed with the new one */ + CACHE_RETURN(&inst->inst_cache, &old_e); + } if (cache_is_in_cache(&inst->inst_cache, e)) { ep_id = e->ep_id; /* Otherwise, e might have been freed. */ CACHE_REMOVE(&inst->inst_cache, e);