From 4fdae3cb17501086e4e426919cfd66b2764055af Mon Sep 17 00:00:00 2001 From: Ludwig Krispenz Date: Feb 22 2018 15:06:20 +0000 Subject: ticket 49551 - correctly handle subordinates and tombstone numsubordinates Additional fix for a case where an ADD is directly turned into a tombstone and teh tombstone is resurrected as conflict Reviewed by: Mark, thanks --- diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c index f0a3262..412e1d3 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_add.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c @@ -849,7 +849,12 @@ ldbm_back_add(Slapi_PBlock *pb) subordinate count specifically */ if (parententry) { int op = is_resurect_operation ? PARENTUPDATE_RESURECT : PARENTUPDATE_ADD; - if (is_cenotaph_operation ) op |= PARENTUPDATE_CREATE_TOMBSTONE; + if (is_cenotaph_operation || (is_tombstone_operation && !is_ruv)) { + /* if we directly add a tombstone the tombstone numsubordinates have to be increased + * (does not apply to adding the RUV) + */ + op |= PARENTUPDATE_CREATE_TOMBSTONE; + } retval = parent_update_on_childchange(&parent_modify_c, op, NULL); slapi_log_err(SLAPI_LOG_BACKLDBM, "ldbm_back_add", "conn=%lu op=%d parent_update_on_childchange: old_entry=0x%p, new_entry=0x%p, rc=%d\n", diff --git a/ldap/servers/slapd/back-ldbm/parents.c b/ldap/servers/slapd/back-ldbm/parents.c index 1afc795..4583885 100644 --- a/ldap/servers/slapd/back-ldbm/parents.c +++ b/ldap/servers/slapd/back-ldbm/parents.c @@ -141,9 +141,11 @@ parent_update_on_childchange(modify_context *mc, int op, size_t *new_sub_count) } /* tombstoneNumSubordinates has to be updated if a tombstone child has been - * deleted or a tombstone has been directly added (cenotaph) */ + * deleted or a tombstone has been directly added (cenotaph) + * or a tombstone is resurrected + */ current_sub_count = LDAP_MAXINT; - if (repl_op) { + if (repl_op || (PARENTUPDATE_RESURECT == op)) { ret = slapi_entry_attr_find(mc->old_entry->ep_entry, tombstone_numsubordinates, &read_attr); if (0 == ret) {