From 59a3cc8efdd6ffd129a59df846ef2d9fa44dff0e Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Thu, 15 Jan 2009 22:44:40 +0000 Subject: Resolves: #469800 Summary: Slow import post-processing with large number of non-leaf entries (comment #15) Change description: Fixed ldbm_ancestorid_new_idl_create_index so that the ancestor key has the value including all the descendent ids in the IDlist. The code checked in previously only stores the direct children and their children. --- ldap/servers/slapd/back-ldbm/ancestorid.c | 49 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/ldap/servers/slapd/back-ldbm/ancestorid.c b/ldap/servers/slapd/back-ldbm/ancestorid.c index 51647506..c3edea06 100644 --- a/ldap/servers/slapd/back-ldbm/ancestorid.c +++ b/ldap/servers/slapd/back-ldbm/ancestorid.c @@ -455,35 +455,38 @@ static int ldbm_ancestorid_new_idl_create_index(backend *be) /* Insert into ancestorid for this node */ ret = idl_store_block(be, db_aid, &key, children, txn, ai_aid); - if (ret != 0) { - idl_free(children); - break; - } - - /* Get parentid for this entry */ - ret = ldbm_parentid(be, txn, id, &parentid); if (ret != 0) { idl_free(children); break; } - /* A suffix entry does not have a parent */ - if (parentid == NOID) { - idl_free(children); - continue; + /* Get parentid(s) for this entry */ + while (1) { + ret = ldbm_parentid(be, txn, id, &parentid); + if (ret != 0) { + idl_free(children); + goto out; + } + + /* A suffix entry does not have a parent */ + if (parentid == NOID) { + idl_free(children); + break; + } + + /* Reset the key to the parent id */ + key.size = PR_snprintf(key.data, key.ulen, "%c%lu", + EQ_PREFIX, (u_long)parentid); + key.size++; + + /* Insert into ancestorid for this node's parent */ + ret = idl_store_block(be, db_aid, &key, children, txn, ai_aid); + if (ret != 0) { + idl_free(children); + goto out; + } + id = parentid; } - - /* Reset the key to the parent id */ - key.size = PR_snprintf(key.data, key.ulen, "%c%lu", - EQ_PREFIX, (u_long)parentid); - key.size++; - - /* Insert into ancestorid for this node's parent */ - ret = idl_store_block(be, db_aid, &key, children, txn, ai_aid); - idl_free(children); - if (ret != 0) { - break; - } } while (nids > 0); if (ret != 0) { -- cgit