Blob Blame History Raw
From 2566e87a956938a6be3addc586fb2fe53cc8b9f8 Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Mon, 8 Sep 2014 14:29:29 -0700
Subject: [PATCH 1/7] Ticket #47834 - Tombstone_to_glue: if parents are also
 converted to glue, the target entry's DN must be adjusted.

Description: Previous fix for the ticket #47834 broke the CI test case
47815.

The fix for 47815 removed the addingentry from the entry cache if
SLAPI_PLUGIN_BE_TXN_POST_ADD_FN failed.  The #47834 patch accidentally
deleted the code.

Instead of adding it back, this patch moves the deletion of the entry
from the entry cache to cover both cases SLAPI_PLUGIN_BE_TXN_POST_ADD
_FN successes or fails.

https://fedorahosted.org/389/ticket/47834

Reviewed by mreynolds@redhat.com (Thank you, Mark!!)

(cherry picked from commit 7db4fa90caa543b59352046138f453236c0fd652)
(cherry picked from commit 78fdd6165cb2c9da4e30452ebdcdcf7aad3d30c7)
---
 ldap/servers/slapd/back-ldbm/ldbm_add.c | 59 ++++++++++++++++++++++++---------
 1 file changed, 43 insertions(+), 16 deletions(-)

diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 2f1b398..b74154a 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -1209,21 +1209,6 @@ error_return:
 	{
 		next_id_return( be, addingentry->ep_id );
 	}
-	if ( addingentry )
-	{
-		if (inst && cache_is_in_cache(&inst->inst_cache, addingentry)) {
-			CACHE_REMOVE(&inst->inst_cache, addingentry);
-			/* tell frontend not to free this entry */
-			slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
-		}
-		else if (!cache_has_otherref(&inst->inst_cache, addingentry))
-		{
-			if (!is_resurect_operation) { /* if resurect, tombstoneentry is dupped. */
-				backentry_clear_entry(addingentry); /* e is released in the frontend */
-			}
-		}
-		CACHE_RETURN( &inst->inst_cache, &addingentry );
-	}
 	if (rc == DB_RUNRECOVERY) {
 		dblayer_remember_disk_filled(li);
 		ldbm_nasty("Add",80,rc);
@@ -1244,6 +1229,20 @@ error_return:
 	}
 diskfull_return:
 	if (disk_full) {
+		if ( addingentry ) {
+			if (inst && cache_is_in_cache(&inst->inst_cache, addingentry)) {
+				CACHE_REMOVE(&inst->inst_cache, addingentry);
+				/* tell frontend not to free this entry */
+				slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+			}
+			else if (!cache_has_otherref(&inst->inst_cache, addingentry))
+			{
+				if (!is_resurect_operation) { /* if resurect, tombstoneentry is dupped. */
+					backentry_clear_entry(addingentry); /* e is released in the frontend */
+				}
+			}
+			CACHE_RETURN( &inst->inst_cache, &addingentry );
+		}
 		rc = return_on_disk_full(li);
 	} else {
 		/* It is safer not to abort when the transaction is not started. */
@@ -1277,13 +1276,41 @@ diskfull_return:
 				}
 				slapi_pblock_get(pb, SLAPI_PB_RESULT_TEXT, &ldap_result_message);
 			}
-
+			if ( addingentry ) {
+				if (inst && cache_is_in_cache(&inst->inst_cache, addingentry)) {
+					CACHE_REMOVE(&inst->inst_cache, addingentry);
+					/* tell frontend not to free this entry */
+					slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+				}
+				else if (!cache_has_otherref(&inst->inst_cache, addingentry))
+				{
+					if (!is_resurect_operation) { /* if resurect, tombstoneentry is dupped. */
+						backentry_clear_entry(addingentry); /* e is released in the frontend */
+					}
+				}
+				CACHE_RETURN( &inst->inst_cache, &addingentry );
+			}
 			/* Release SERIAL LOCK */
 			if (!noabort) {
 				dblayer_txn_abort(be, &txn); /* abort crashes in case disk full */
 			}
 			/* txn is no longer valid - reset the txn pointer to the parent */
 			slapi_pblock_set(pb, SLAPI_TXN, parent_txn);
+		} else {
+			if ( addingentry ) {
+				if (inst && cache_is_in_cache(&inst->inst_cache, addingentry)) {
+					CACHE_REMOVE(&inst->inst_cache, addingentry);
+					/* tell frontend not to free this entry */
+					slapi_pblock_set(pb, SLAPI_ADD_ENTRY, NULL);
+				}
+				else if (!cache_has_otherref(&inst->inst_cache, addingentry))
+				{
+					if (!is_resurect_operation) { /* if resurect, tombstoneentry is dupped. */
+						backentry_clear_entry(addingentry); /* e is released in the frontend */
+					}
+				}
+				CACHE_RETURN( &inst->inst_cache, &addingentry );
+			}
 		}
 		if (!not_an_error) {
 			rc = SLAPI_FAIL_GENERAL;
-- 
1.9.3