Browse Source

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!!)
Noriko Hosoi 12 năm trước cách đây
mục cha
commit
c6a72a50e6
1 tập tin đã thay đổi với 23 bổ sung1 xóa
  1. 23 1
      ldap/servers/plugins/dna/dna.c

+ 23 - 1
ldap/servers/plugins/dna/dna.c

@@ -1352,6 +1352,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
@@ -1367,6 +1383,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);
             }
 
@@ -1659,7 +1681,7 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
                         }
                     }
                     if(!inserted){
-                    	dna_free_shared_server(&server);
+                        dna_free_shared_server(&server);
                     }
                 }
             }