Blame SOURCES/0076-Ticket-47627-changelog-iteration-should-ignore-clean.patch

cc3dff
From ea86342f0497a2d4c45c337ada9ec9e8329fc7cd Mon Sep 17 00:00:00 2001
cc3dff
From: Mark Reynolds <mreynolds@redhat.com>
cc3dff
Date: Wed, 11 Dec 2013 11:25:44 -0500
cc3dff
Subject: [PATCH 76/78] Ticket 47627 - changelog iteration should ignore
cc3dff
 cleaned rids when getting the minCSN
cc3dff
cc3dff
Description:  If a change is not found in the change log the server will look for a min csn
cc3dff
              to start the replay. This minCSN should not come from a cleaned RUV element.
cc3dff
cc3dff
https://fedorahosted.org/389/ticket/47627
cc3dff
cc3dff
Reviewed by: rmeggins & lkrispenz(Thanks!!)
cc3dff
(cherry picked from commit 9c6e9bb12327a2d50e651221614d34984b605427)
cc3dff
(cherry picked from commit 8004449ae206d0d417497324ffedf79ca9e25572)
cc3dff
---
cc3dff
 ldap/servers/plugins/replication/cl5_api.c   |  2 +-
cc3dff
 ldap/servers/plugins/replication/repl5_ruv.c | 42 ++++++++++++++++++++++------
cc3dff
 ldap/servers/plugins/replication/repl5_ruv.h |  3 ++
cc3dff
 3 files changed, 37 insertions(+), 10 deletions(-)
cc3dff
cc3dff
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
cc3dff
index 7bedc2c..064a628 100644
cc3dff
--- a/ldap/servers/plugins/replication/cl5_api.c
cc3dff
+++ b/ldap/servers/plugins/replication/cl5_api.c
cc3dff
@@ -5172,7 +5172,7 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum
cc3dff
         {
cc3dff
             /* use the supplier min csn for the buffer start csn - we know
cc3dff
                this csn is in our changelog */
cc3dff
-            if ((RUV_SUCCESS == ruv_get_min_csn(supplierRuv, &startCSN)) &&
cc3dff
+            if ((RUV_SUCCESS == ruv_get_min_csn_ext(supplierRuv, &startCSN, 1 /* ignore cleaned rids */)) &&
cc3dff
                 startCSN)
cc3dff
             { /* must now free startCSN */
cc3dff
                 if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
cc3dff
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
cc3dff
index 7395195..dc83555 100644
cc3dff
--- a/ldap/servers/plugins/replication/repl5_ruv.c
cc3dff
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
cc3dff
@@ -998,9 +998,9 @@ ruv_covers_csn_cleanallruv(const RUV *ruv, const CSN *csn)
cc3dff
  * or max{maxcsns of all ruv elements} if get_the_max != 0.
cc3dff
  */
cc3dff
 static int
cc3dff
-ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid)
cc3dff
+ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid, int ignore_cleaned_rid)
cc3dff
 {
cc3dff
-	int return_value;
cc3dff
+	int return_value = RUV_SUCCESS;
cc3dff
 
cc3dff
 	if (ruv == NULL || csn == NULL) 
cc3dff
 	{
cc3dff
@@ -1012,6 +1012,7 @@ ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid
cc3dff
 		CSN *found = NULL;
cc3dff
 		RUVElement *replica;
cc3dff
 		int cookie;
cc3dff
+
cc3dff
 		slapi_rwlock_rdlock (ruv->lock);
cc3dff
 		for (replica = dl_get_first (ruv->elements, &cookie); replica;
cc3dff
 			 replica = dl_get_next (ruv->elements, &cookie))
cc3dff
@@ -1028,6 +1029,10 @@ ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid
cc3dff
 			{
cc3dff
 				continue;
cc3dff
 			}
cc3dff
+			if(ignore_cleaned_rid && is_cleaned_rid(replica->rid)){
cc3dff
+				continue;
cc3dff
+			}
cc3dff
+
cc3dff
 			if(rid){ /* we are only interested in this rid's maxcsn */
cc3dff
 				if(replica->rid == rid){
cc3dff
 					found = replica->csn;
cc3dff
@@ -1041,36 +1046,55 @@ ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid
cc3dff
 					found = replica->csn;
cc3dff
 				}
cc3dff
 			}
cc3dff
-		} 
cc3dff
+		}
cc3dff
+
cc3dff
 		if (found == NULL)
cc3dff
 		{
cc3dff
-			*csn = NULL;	
cc3dff
+			*csn = NULL;
cc3dff
 		}
cc3dff
 		else
cc3dff
 		{
cc3dff
 			*csn = csn_dup (found);
cc3dff
 		}
cc3dff
 		slapi_rwlock_unlock (ruv->lock);
cc3dff
-		return_value = RUV_SUCCESS;	
cc3dff
 	}
cc3dff
 	return return_value;
cc3dff
 }
cc3dff
 
cc3dff
 int
cc3dff
-ruv_get_rid_max_csn(const RUV *ruv, CSN **csn, ReplicaId rid){
cc3dff
-	return ruv_get_min_or_max_csn(ruv, csn, 1 /* get the max */, rid);
cc3dff
+ruv_get_rid_max_csn(const RUV *ruv, CSN **csn, ReplicaId rid)
cc3dff
+{
cc3dff
+	return ruv_get_rid_max_csn_ext(ruv, csn, rid, 0);
cc3dff
+}
cc3dff
+
cc3dff
+int
cc3dff
+ruv_get_rid_max_csn_ext(const RUV *ruv, CSN **csn, ReplicaId rid, int ignore_cleaned_rid)
cc3dff
+{
cc3dff
+	return ruv_get_min_or_max_csn(ruv, csn, 1 /* get the max */, rid, ignore_cleaned_rid);
cc3dff
 }
cc3dff
 
cc3dff
 int
cc3dff
 ruv_get_max_csn(const RUV *ruv, CSN **csn)
cc3dff
 {
cc3dff
-	return ruv_get_min_or_max_csn(ruv, csn, 1 /* get the max */, 0 /* rid */);
cc3dff
+	return ruv_get_max_csn_ext(ruv, csn, 0);
cc3dff
+}
cc3dff
+
cc3dff
+int
cc3dff
+ruv_get_max_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid)
cc3dff
+{
cc3dff
+	return ruv_get_min_or_max_csn(ruv, csn, 1 /* get the max */, 0 /* rid */, ignore_cleaned_rid);
cc3dff
 }
cc3dff
 
cc3dff
 int
cc3dff
 ruv_get_min_csn(const RUV *ruv, CSN **csn)
cc3dff
 {
cc3dff
-	return ruv_get_min_or_max_csn(ruv, csn, 0 /* get the min */, 0 /* rid */);
cc3dff
+	return ruv_get_min_csn_ext(ruv, csn, 0);
cc3dff
+}
cc3dff
+
cc3dff
+int
cc3dff
+ruv_get_min_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid)
cc3dff
+{
cc3dff
+	return ruv_get_min_or_max_csn(ruv, csn, 0 /* get the min */, 0 /* rid */, ignore_cleaned_rid);
cc3dff
 }
cc3dff
 
cc3dff
 int 
cc3dff
diff --git a/ldap/servers/plugins/replication/repl5_ruv.h b/ldap/servers/plugins/replication/repl5_ruv.h
cc3dff
index 799dc7f..4593b84 100644
cc3dff
--- a/ldap/servers/plugins/replication/repl5_ruv.h
cc3dff
+++ b/ldap/servers/plugins/replication/repl5_ruv.h
cc3dff
@@ -123,8 +123,11 @@ PRBool ruv_covers_csn(const RUV *ruv, const CSN *csn);
cc3dff
 PRBool ruv_covers_csn_strict(const RUV *ruv, const CSN *csn);
cc3dff
 PRBool ruv_covers_csn_cleanallruv(const RUV *ruv, const CSN *csn);
cc3dff
 int ruv_get_min_csn(const RUV *ruv, CSN **csn);
cc3dff
+int ruv_get_min_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid);
cc3dff
 int ruv_get_max_csn(const RUV *ruv, CSN **csn);
cc3dff
+int ruv_get_max_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid);
cc3dff
 int ruv_get_rid_max_csn(const RUV *ruv, CSN **csn, ReplicaId rid);
cc3dff
+int ruv_get_rid_max_csn_ext(const RUV *ruv, CSN **csn, ReplicaId rid, int ignore_cleaned_rid);
cc3dff
 int ruv_enumerate_elements (const RUV *ruv, FNEnumRUV fn, void *arg);
cc3dff
 int ruv_to_smod(const RUV *ruv, Slapi_Mod *smod);
cc3dff
 int ruv_last_modified_to_smod(const RUV *ruv, Slapi_Mod *smod);
cc3dff
-- 
cc3dff
1.8.1.4
cc3dff