andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From b5fb783fd4b1f5f34ef9956f0f93cbe3a3e14645 Mon Sep 17 00:00:00 2001
dc8c34
From: Thierry Bordaz <tbordaz@redhat.com>
dc8c34
Date: Mon, 19 Oct 2015 11:03:54 +0200
dc8c34
Subject: [PATCH 363/363] Ticket 47978: Deadlock between two MODs on the same
dc8c34
 entry between entry cache and backend lock
dc8c34
dc8c34
Bug Description:
dc8c34
	During a modify, the modified entry gets into the entry cache and is locked.
dc8c34
	If after the be_txn_postop/txn_commit and before the modify returns
dc8c34
	the modified entry gets out of the entry cache, the entry is not unlocked.
dc8c34
	It can lead to hang as soon as an other write operation hit that unlocked entry.
dc8c34
dc8c34
	This is a side effect of fix:
dc8c34
		#47834 - Tombstone_to_glue: if parents are also converted to glue, the target entry's DN must be adjusted.
dc8c34
dc8c34
Fix Description:
dc8c34
	When the entry is locked, set a flag so that can later be unlocked
dc8c34
	independently of its presence in the entry cache
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47978
dc8c34
dc8c34
Reviewed by: Noriko Hosoi (Thanks Noriko)
dc8c34
dc8c34
Platforms tested: F22 (IPA CI test test_integration/test_vault.py, one failure out 2-4)
dc8c34
dc8c34
Flag Day: no
dc8c34
dc8c34
Doc impact: no
dc8c34
dc8c34
(cherry picked from commit bdaed4e2fb4633d6fec16eb1ea55b7e2fcbd4df4)
dc8c34
---
dc8c34
 ldap/servers/slapd/back-ldbm/ldbm_modify.c | 4 +++-
dc8c34
 1 file changed, 3 insertions(+), 1 deletion(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modify.c b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
dc8c34
index 8b36e0f..15cfe2c 100644
dc8c34
--- a/ldap/servers/slapd/back-ldbm/ldbm_modify.c
dc8c34
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modify.c
dc8c34
@@ -387,6 +387,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
dc8c34
 	int repl_op;
dc8c34
 	int opreturn = 0;
dc8c34
 	int mod_count = 0;
dc8c34
+	int ec_locked = 0;
dc8c34
 
dc8c34
 	slapi_pblock_get( pb, SLAPI_BACKEND, &be);
dc8c34
 	slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
dc8c34
@@ -746,6 +747,7 @@ ldbm_back_modify( Slapi_PBlock *pb )
dc8c34
 
dc8c34
 	/* lock new entry in cache to prevent usage until we are complete */
dc8c34
 	cache_lock_entry( &inst->inst_cache, ec );
dc8c34
+	ec_locked = 1;
dc8c34
 
dc8c34
 	postentry = slapi_entry_dup( ec->ep_entry );
dc8c34
 	slapi_pblock_set( pb, SLAPI_ENTRY_POST_OP, postentry );
dc8c34
@@ -861,7 +863,7 @@ common_return:
dc8c34
 	slapi_mods_done(&smods);
dc8c34
 	
dc8c34
 	if(inst){
dc8c34
-		if (cache_is_in_cache( &inst->inst_cache, ec))
dc8c34
+		if (ec_locked || cache_is_in_cache( &inst->inst_cache, ec))
dc8c34
 		{
dc8c34
 			cache_unlock_entry( &inst->inst_cache, ec);
dc8c34
 		} else if (e) {
dc8c34
-- 
dc8c34
2.4.3
dc8c34