From a150e8ea0db00dcea1f1320343fc9bca4b2526a4 Mon Sep 17 00:00:00 2001 From: Nathan Kinder Date: Aug 10 2011 22:14:26 +0000 Subject: Bug 728510 - Run dirsync after sending updates to AD There is currently a window of time between sending changes to AD and running a dirsync to get changes from AD that can cause problems. We rely on having the GUID from AD for certain operations on entries, such as deletes. When a new entry is synced to AD, we don't get the GUID back from AD until a dirsync is run, which is at a 5 minute interval by default. When changes that rely on DS having the GUID are performed during this window, things can get out of sync. This patch makes us run a dirsync immediately after sending updates to AD for both the total and incremental update sync protocols. This minimizes the window where we do not have the GUID for an entry, thus minimizing the chance of an update occuring in that window. --- diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c index f85699d..3bba77d 100644 --- a/ldap/servers/plugins/replication/windows_inc_protocol.c +++ b/ldap/servers/plugins/replication/windows_inc_protocol.c @@ -473,6 +473,9 @@ windows_inc_run(Private_Repl_Protocol *prp) dev_debug("windows_inc_run(STATE_WAIT_CHANGES): EVENT_TRIGGERING_CRITERIA_MET received -> STATE_READY_TO_ACQUIRE\n"); next_state = STATE_READY_TO_ACQUIRE; wait_change_timer_set = 0; + /* We want to run dirsync to catch values generated by AD after + * it process operations that we send to it (such as GUID values). */ + run_dirsync = PR_TRUE; } else if ((e1 = event_occurred(prp, EVENT_WINDOW_OPENED)) || event_occurred(prp, EVENT_BACKOFF_EXPIRED)) diff --git a/ldap/servers/plugins/replication/windows_tot_protocol.c b/ldap/servers/plugins/replication/windows_tot_protocol.c index 24d1675..6c54004 100644 --- a/ldap/servers/plugins/replication/windows_tot_protocol.c +++ b/ldap/servers/plugins/replication/windows_tot_protocol.c @@ -241,6 +241,14 @@ windows_tot_run(Private_Repl_Protocol *prp) agmt_set_consumer_ruv(prp->agmt, starting_ruv ); } + /* Do another dirsync to ensure we get GUIDs for newly added entries. */ + if ((one_way == ONE_WAY_SYNC_DISABLED) || (one_way == ONE_WAY_SYNC_FROM_AD)) { + windows_dirsync_inc_run(prp); + } + + /* Save the dirsync cookie. */ + windows_private_save_dirsync_cookie(prp->agmt); + /* call end total update callback */ winsync_plugin_call_end_update_cb(prp->agmt, windows_private_get_directory_subtree(prp->agmt),