From 579c27e416c46cbc1c826c4c8b2e4cd1919862a3 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Thu, 19 Jan 2012 11:19:53 -0800 Subject: [PATCH] Trac Ticket #18 - Data inconsitency during replication https://fedorahosted.org/389/ticket/18 Bug description: If promote a hub server to a new master and assign the same replica ID as the original master server had, some new adds/modifies to the new server may dropped and not be replicated to the consumers. Fix description: If a hub is promoted to a master, consumer's RUV is updated. It only updated the master's URL, but not the CSN and min CSN. This patch resets the CSNs if the URL needs to be updated. --- ldap/servers/plugins/replication/repl5_ruv.c | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c index e5ddb39..e0b10ae 100644 --- a/ldap/servers/plugins/replication/repl5_ruv.c +++ b/ldap/servers/plugins/replication/repl5_ruv.c @@ -479,21 +479,26 @@ int ruv_replace_replica_purl (RUV *ruv, ReplicaId rid, const char *replica_purl) { RUVElement* replica; - int rc = RUV_NOTFOUND; - + int rc = RUV_NOTFOUND; + PR_ASSERT (ruv && replica_purl); slapi_rwlock_wrlock (ruv->lock); replica = ruvGetReplica (ruv, rid); if (replica != NULL) { - slapi_ch_free((void **)&(replica->replica_purl)); - replica->replica_purl = slapi_ch_strdup(replica_purl); + if (strcmp(replica->replica_purl, replica_purl)) { /* purl updated */ + /* Replace replica_purl in RUV since supplier has been updated. */ + slapi_ch_free((void **)&(replica->replica_purl)); + replica->replica_purl = slapi_ch_strdup(replica_purl); + /* Also, reset csn and min_csn. */ + replica->csn = replica->min_csn = NULL; + } rc = RUV_SUCCESS; - } + } - slapi_rwlock_unlock (ruv->lock); - return rc; + slapi_rwlock_unlock (ruv->lock); + return rc; } int -- 1.7.6.4