andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 13fbc1d8fe9c87ce88f0d88b79819101b04c2aa9 Mon Sep 17 00:00:00 2001
dc8c34
From: Mark Reynolds <mreynolds@redhat.com>
dc8c34
Date: Wed, 11 Dec 2013 11:25:44 -0500
dc8c34
Subject: [PATCH 152/225] Ticket 47627 - changelog iteration should ignore
dc8c34
 cleaned rids when getting the minCSN
dc8c34
dc8c34
Description:  If a change is not found in the change log the server will look for a min csn
dc8c34
              to start the replay. This minCSN should not come from a cleaned RUV element.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/47627
dc8c34
dc8c34
Reviewed by: rmeggins & lkrispenz(Thanks!!)
dc8c34
(cherry picked from commit 9c6e9bb12327a2d50e651221614d34984b605427)
dc8c34
(cherry picked from commit e746f7e02826bce27819c1a4ca514ef3d23085c5)
dc8c34
---
dc8c34
 ldap/servers/plugins/replication/cl5_api.c   |  2 +-
dc8c34
 ldap/servers/plugins/replication/repl5_ruv.c | 42 ++++++++++++++++++++++------
dc8c34
 ldap/servers/plugins/replication/repl5_ruv.h |  3 ++
dc8c34
 3 files changed, 37 insertions(+), 10 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
dc8c34
index f2e038e..55bda39 100644
dc8c34
--- a/ldap/servers/plugins/replication/cl5_api.c
dc8c34
+++ b/ldap/servers/plugins/replication/cl5_api.c
dc8c34
@@ -5132,7 +5132,7 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum
dc8c34
         {
dc8c34
             /* use the supplier min csn for the buffer start csn - we know
dc8c34
                this csn is in our changelog */
dc8c34
-            if ((RUV_SUCCESS == ruv_get_min_csn(supplierRuv, &startCSN)) &&
dc8c34
+            if ((RUV_SUCCESS == ruv_get_min_csn_ext(supplierRuv, &startCSN, 1 /* ignore cleaned rids */)) &&
dc8c34
                 startCSN)
dc8c34
             { /* must now free startCSN */
dc8c34
                 if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
dc8c34
diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c
dc8c34
index 2808c58..d9a3b26 100644
dc8c34
--- a/ldap/servers/plugins/replication/repl5_ruv.c
dc8c34
+++ b/ldap/servers/plugins/replication/repl5_ruv.c
dc8c34
@@ -986,9 +986,9 @@ ruv_covers_csn_cleanallruv(const RUV *ruv, const CSN *csn)
dc8c34
  * or max{maxcsns of all ruv elements} if get_the_max != 0.
dc8c34
  */
dc8c34
 static int
dc8c34
-ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid)
dc8c34
+ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid, int ignore_cleaned_rid)
dc8c34
 {
dc8c34
-	int return_value;
dc8c34
+	int return_value = RUV_SUCCESS;
dc8c34
 
dc8c34
 	if (ruv == NULL || csn == NULL) 
dc8c34
 	{
dc8c34
@@ -1000,6 +1000,7 @@ ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid
dc8c34
 		CSN *found = NULL;
dc8c34
 		RUVElement *replica;
dc8c34
 		int cookie;
dc8c34
+
dc8c34
 		slapi_rwlock_rdlock (ruv->lock);
dc8c34
 		for (replica = dl_get_first (ruv->elements, &cookie); replica;
dc8c34
 			 replica = dl_get_next (ruv->elements, &cookie))
dc8c34
@@ -1016,6 +1017,10 @@ ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid
dc8c34
 			{
dc8c34
 				continue;
dc8c34
 			}
dc8c34
+			if(ignore_cleaned_rid && is_cleaned_rid(replica->rid)){
dc8c34
+				continue;
dc8c34
+			}
dc8c34
+
dc8c34
 			if(rid){ /* we are only interested in this rid's maxcsn */
dc8c34
 				if(replica->rid == rid){
dc8c34
 					found = replica->csn;
dc8c34
@@ -1029,36 +1034,55 @@ ruv_get_min_or_max_csn(const RUV *ruv, CSN **csn, int get_the_max, ReplicaId rid
dc8c34
 					found = replica->csn;
dc8c34
 				}
dc8c34
 			}
dc8c34
-		} 
dc8c34
+		}
dc8c34
+
dc8c34
 		if (found == NULL)
dc8c34
 		{
dc8c34
-			*csn = NULL;	
dc8c34
+			*csn = NULL;
dc8c34
 		}
dc8c34
 		else
dc8c34
 		{
dc8c34
 			*csn = csn_dup (found);
dc8c34
 		}
dc8c34
 		slapi_rwlock_unlock (ruv->lock);
dc8c34
-		return_value = RUV_SUCCESS;	
dc8c34
 	}
dc8c34
 	return return_value;
dc8c34
 }
dc8c34
 
dc8c34
 int
dc8c34
-ruv_get_rid_max_csn(const RUV *ruv, CSN **csn, ReplicaId rid){
dc8c34
-	return ruv_get_min_or_max_csn(ruv, csn, 1 /* get the max */, rid);
dc8c34
+ruv_get_rid_max_csn(const RUV *ruv, CSN **csn, ReplicaId rid)
dc8c34
+{
dc8c34
+	return ruv_get_rid_max_csn_ext(ruv, csn, rid, 0);
dc8c34
+}
dc8c34
+
dc8c34
+int
dc8c34
+ruv_get_rid_max_csn_ext(const RUV *ruv, CSN **csn, ReplicaId rid, int ignore_cleaned_rid)
dc8c34
+{
dc8c34
+	return ruv_get_min_or_max_csn(ruv, csn, 1 /* get the max */, rid, ignore_cleaned_rid);
dc8c34
 }
dc8c34
 
dc8c34
 int
dc8c34
 ruv_get_max_csn(const RUV *ruv, CSN **csn)
dc8c34
 {
dc8c34
-	return ruv_get_min_or_max_csn(ruv, csn, 1 /* get the max */, 0 /* rid */);
dc8c34
+	return ruv_get_max_csn_ext(ruv, csn, 0);
dc8c34
+}
dc8c34
+
dc8c34
+int
dc8c34
+ruv_get_max_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid)
dc8c34
+{
dc8c34
+	return ruv_get_min_or_max_csn(ruv, csn, 1 /* get the max */, 0 /* rid */, ignore_cleaned_rid);
dc8c34
 }
dc8c34
 
dc8c34
 int
dc8c34
 ruv_get_min_csn(const RUV *ruv, CSN **csn)
dc8c34
 {
dc8c34
-	return ruv_get_min_or_max_csn(ruv, csn, 0 /* get the min */, 0 /* rid */);
dc8c34
+	return ruv_get_min_csn_ext(ruv, csn, 0);
dc8c34
+}
dc8c34
+
dc8c34
+int
dc8c34
+ruv_get_min_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid)
dc8c34
+{
dc8c34
+	return ruv_get_min_or_max_csn(ruv, csn, 0 /* get the min */, 0 /* rid */, ignore_cleaned_rid);
dc8c34
 }
dc8c34
 
dc8c34
 int 
dc8c34
diff --git a/ldap/servers/plugins/replication/repl5_ruv.h b/ldap/servers/plugins/replication/repl5_ruv.h
dc8c34
index fdc8af2..5264395 100644
dc8c34
--- a/ldap/servers/plugins/replication/repl5_ruv.h
dc8c34
+++ b/ldap/servers/plugins/replication/repl5_ruv.h
dc8c34
@@ -118,8 +118,11 @@ PRBool ruv_covers_csn(const RUV *ruv, const CSN *csn);
dc8c34
 PRBool ruv_covers_csn_strict(const RUV *ruv, const CSN *csn);
dc8c34
 PRBool ruv_covers_csn_cleanallruv(const RUV *ruv, const CSN *csn);
dc8c34
 int ruv_get_min_csn(const RUV *ruv, CSN **csn);
dc8c34
+int ruv_get_min_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid);
dc8c34
 int ruv_get_max_csn(const RUV *ruv, CSN **csn);
dc8c34
+int ruv_get_max_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid);
dc8c34
 int ruv_get_rid_max_csn(const RUV *ruv, CSN **csn, ReplicaId rid);
dc8c34
+int ruv_get_rid_max_csn_ext(const RUV *ruv, CSN **csn, ReplicaId rid, int ignore_cleaned_rid);
dc8c34
 int ruv_enumerate_elements (const RUV *ruv, FNEnumRUV fn, void *arg);
dc8c34
 int ruv_to_smod(const RUV *ruv, Slapi_Mod *smod);
dc8c34
 int ruv_last_modified_to_smod(const RUV *ruv, Slapi_Mod *smod);
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34