From 2ecfe571faf9291eab7ffacea2a1e94d5be0d689 Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Wed, 12 Sep 2012 09:40:06 +0200 Subject: Run index task in ldap updater only when needed When LDAP updater detected an update instruction in indexing tree, it run an indexing task and waited until it ends. However, the task was run regardless of the update instruction result. This lead to unnecessary index tasks being defined and waited for which makes the whole LDAP last longer. Execute indexing task only when an index add/update instruction is successful. https://fedorahosted.org/freeipa/ticket/2866 --- ipaserver/install/ldapupdate.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'ipaserver/install/ldapupdate.py') diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py index 528e349d..eb95858f 100644 --- a/ipaserver/install/ldapupdate.py +++ b/ipaserver/install/ldapupdate.py @@ -754,6 +754,8 @@ class LDAPUpdate: self.print_entity(entry, "Final value after applying updates") + added = False + updated = False if not found: # New entries get their orig_data set to the entry itself. We want to # empty that so that everything appears new when generating the @@ -773,13 +775,13 @@ class LDAPUpdate: self.info("Parent DN of %s may not exist, cannot create the entry", entry.dn) return + added = True self.modified = True except Exception, e: self.error("Add failure %s", e) else: # Update LDAP try: - updated = False changes = self.conn.generateModList(entry.origDataDict(), entry.toDict()) if (entry.dn == DN(('cn', 'schema'))): d = dict() @@ -805,13 +807,14 @@ class LDAPUpdate: self.error("Update failed: %s", e) updated = False - if (DN(('cn', 'index')) in entry.dn and - DN(('cn', 'userRoot')) in entry.dn): - taskid = self.create_index_task(entry.getValue('cn')) - self.monitor_index_task(taskid) - if updated: self.modified = True + + if entry.dn.endswith(DN(('cn', 'index'), ('cn', 'userRoot'), + ('cn', 'ldbm database'), ('cn', 'plugins'), + ('cn', 'config'))) and (added or updated): + taskid = self.create_index_task(entry.getValue('cn')) + self.monitor_index_task(taskid) return def _delete_record(self, updates): -- cgit