ldap/servers/plugins/dna/dna.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
New commits:
commit d1d2ed05e405a711682e43c465712e0b153a209f
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Jun 19 16:19:28 2013 -0700
Ticket #47400 - MMR stress test with dna enabled causes a deadlock
Bug description: Under the heavy add/delete posix user entries,
dna_update_config_event causes a deadlock.
Fix description: dna_update_config_event starts transaction
before updating the shared config entry to avoid the deadlock
situation.
https://fedorahosted.org/389/ticket/47400
Reviewed by Rich (Thank you!!)
(cherry picked from commit c6a72a50e6c948647b220e4a44978f2c9c7e8466)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 8e5bec8..a631208 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1273,6 +1273,22 @@ dna_update_config_event(time_t event_time, void *arg)
/* If a shared config dn is set, update the shared config. */
if (config_entry->shared_cfg_dn != NULL) {
+ int rc = 0;
+ Slapi_PBlock *dna_pb = NULL;
+ Slapi_DN *sdn =
slapi_sdn_new_normdn_byref(config_entry->shared_cfg_dn);
+ Slapi_Backend *be = slapi_be_select(sdn);
+ slapi_sdn_free(&sdn);
+ if (be) {
+ dna_pb = slapi_pblock_new();
+ slapi_pblock_set(dna_pb, SLAPI_BACKEND, be);
+ /* We need to start transaction to avoid the deadlock */
+ rc = slapi_back_transaction_begin(dna_pb);
+ if (rc) {
+ slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
+ "dna_update_config_event: failed to start
transaction\n");
+ }
+ }
+
slapi_lock_mutex(config_entry->lock);
/* First delete the existing shared config entry. This
@@ -1288,6 +1304,12 @@ dna_update_config_event(time_t event_time, void *arg)
dna_update_shared_config(config_entry);
slapi_unlock_mutex(config_entry->lock);
+ if (dna_pb) {
+ if (0 == rc) {
+ slapi_back_transaction_commit(dna_pb);
+ }
+ slapi_pblock_destroy(dna_pb);
+ }
slapi_pblock_init(pb);
}
@@ -1536,7 +1558,7 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList
**servers)
}
}
if(!inserted){
- dna_free_shared_server(&server);
+ dna_free_shared_server(&server);
}
}
}