From b4ef87c201238452b4f7653cce127d4b23ea4106 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Feb 16 2015 23:18:41 +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) (cherry picked from commit 5ef3183a434e694c120536c073a6f9f6e4cfa898) --- diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c index e06f241..e86d45f 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c @@ -1116,6 +1116,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; CACHE_REMOVE(&inst->inst_cache, e);