|
|
@@ -98,7 +98,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
|
|
|
int opreturn = 0;
|
|
|
int free_delete_existing_entry = 0;
|
|
|
int not_an_error = 0;
|
|
|
- int updated_num = 0;
|
|
|
|
|
|
slapi_pblock_get( pb, SLAPI_BACKEND, &be);
|
|
|
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
|
|
|
@@ -459,14 +458,37 @@ ldbm_back_delete( Slapi_PBlock *pb )
|
|
|
* (find_entry2modify_only_ext), a wrong parent could be found,
|
|
|
* and numsubordinate count could get confused.
|
|
|
*/
|
|
|
- ID pid = (ID)strtol(pid_str, (char **)NULL, 10);
|
|
|
+ ID pid;
|
|
|
+ int cache_retry_count = 0;
|
|
|
+ int cache_retry = 0;
|
|
|
+
|
|
|
+ pid = (ID)strtol(pid_str, (char **)NULL, 10);
|
|
|
slapi_ch_free_string(&pid_str);
|
|
|
- parent = id2entry(be, pid ,NULL, &retval);
|
|
|
- if (parent && cache_lock_entry(&inst->inst_cache, parent)) {
|
|
|
- /* Failed to obtain parent entry's entry lock */
|
|
|
- CACHE_RETURN(&(inst->inst_cache), &parent);
|
|
|
- retval = -1;
|
|
|
- goto error_return;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Its possible that the parent entry retrieved from the cache in id2entry
|
|
|
+ * could be removed before we lock it, because tombstone purging updated/replaced
|
|
|
+ * the parent. If we fail to lock the entry, just try again.
|
|
|
+ */
|
|
|
+ while(1){
|
|
|
+ parent = id2entry(be, pid ,NULL, &retval);
|
|
|
+ if (parent && (cache_retry = cache_lock_entry(&inst->inst_cache, parent))) {
|
|
|
+ /* Failed to obtain parent entry's entry lock */
|
|
|
+ if(cache_retry == RETRY_CACHE_LOCK &&
|
|
|
+ cache_retry_count < LDBM_CACHE_RETRY_COUNT)
|
|
|
+ {
|
|
|
+ /* try again */
|
|
|
+ DS_Sleep(PR_MillisecondsToInterval(100));
|
|
|
+ cache_retry_count++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ retval = -1;
|
|
|
+ CACHE_RETURN(&(inst->inst_cache), &parent);
|
|
|
+ goto error_return;
|
|
|
+ } else {
|
|
|
+ /* entry locked, move on */
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (NULL == parent) {
|
|
|
@@ -502,8 +524,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
|
|
|
retval = -1;
|
|
|
goto error_return;
|
|
|
}
|
|
|
- /* MARK */
|
|
|
- updated_num = 1;
|
|
|
+
|
|
|
/*
|
|
|
* Replication urp_post_delete will delete the parent entry
|
|
|
* if it is a glue entry without any more children.
|
|
|
@@ -519,7 +540,6 @@ ldbm_back_delete( Slapi_PBlock *pb )
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- slapi_sdn_done(&parentsdn);
|
|
|
|
|
|
if(create_tombstone_entry)
|
|
|
{
|
|
|
@@ -1291,14 +1311,12 @@ diskfull_return:
|
|
|
slapi_ch_free((void**)&errbuf);
|
|
|
slapi_sdn_done(&nscpEntrySDN);
|
|
|
slapi_ch_free_string(&e_uniqueid);
|
|
|
+ slapi_sdn_done(&parentsdn);
|
|
|
if (pb->pb_conn)
|
|
|
{
|
|
|
slapi_log_error (SLAPI_LOG_TRACE, "ldbm_back_delete", "leave conn=%" NSPRIu64 " op=%d\n",
|
|
|
(long long unsigned int)pb->pb_conn->c_connid, operation->o_opid);
|
|
|
}
|
|
|
|
|
|
- if(!updated_num && ldap_result_code != 32){
|
|
|
- slapi_log_error (SLAPI_LOG_FATAL,"MARK", "Failed to update numsubordinates\n");
|
|
|
- }
|
|
|
return rc;
|
|
|
}
|