andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 4 months ago
Clone

Blame 0395-Ticket-48944-backport-1.2.11-on-a-read-only-replica-.patch

dc8c34
From c088ea0049412cfb216ddadb8f2ee7566fc9075c Mon Sep 17 00:00:00 2001
dc8c34
From: Ludwig Krispenz <lkrispen@redhat.com>
dc8c34
Date: Wed, 14 Sep 2016 11:39:33 +0200
dc8c34
Subject: [PATCH] Ticket 48944 - backport 1.2.11 - on a read only replica
dc8c34
 invalid state info can accumulate
dc8c34
dc8c34
Bug Description: if internal mods are generated on a consumer (eg by Account Policy)
dc8c34
		 and changes for these attributes are als received via replication
dc8c34
		 the state information on the consumer can accumulate
dc8c34
dc8c34
Fix Description: Make sure replace operations are only applied if they
dc8c34
		 are newer than an existing attribute deletion csn.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/48944
dc8c34
dc8c34
Reviewed by: Noriko, thanks
dc8c34
dc8c34
(cherry picked from commit 2e98b9ecd575d4cf531a92df3bbbe3e4f021b0ca)
dc8c34
(cherry picked from commit 6751a36e8eb1936e3abd0a300fe68341f20bd8a6)
dc8c34
---
dc8c34
 ldap/servers/slapd/entrywsi.c | 21 +++++++++++++++++++++
dc8c34
 1 file changed, 21 insertions(+)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/entrywsi.c b/ldap/servers/slapd/entrywsi.c
dc8c34
index 663d115..76286a1 100644
dc8c34
--- a/ldap/servers/slapd/entrywsi.c
dc8c34
+++ b/ldap/servers/slapd/entrywsi.c
dc8c34
@@ -430,6 +430,8 @@ entry_add_present_values_wsi(Slapi_Entry *e, const char *type, struct berval **b
dc8c34
 		Slapi_Attr *a= NULL;
dc8c34
 		long a_flags_orig;
dc8c34
 		int attr_state= entry_attr_find_wsi(e, type, &a);
dc8c34
+		const CSN *adcsn = NULL;
dc8c34
+
dc8c34
 		if (ATTRIBUTE_NOTFOUND == attr_state)
dc8c34
 		{
dc8c34
 			/* Create a new attribute */
dc8c34
@@ -437,6 +439,17 @@ entry_add_present_values_wsi(Slapi_Entry *e, const char *type, struct berval **b
dc8c34
 			slapi_attr_init(a, type);
dc8c34
 			attrlist_add(&e->e_attrs, a);
dc8c34
 		}
dc8c34
+
dc8c34
+		adcsn = attr_get_deletion_csn(a);
dc8c34
+		if (csn_compare(csn, adcsn) < 0) {
dc8c34
+			/* the attribute was deleted with an adcsn
dc8c34
+			 * newer than the current csn.
dc8c34
+			 * Nothing to do.
dc8c34
+			 */
dc8c34
+			valuearray_free(&valuestoadd);
dc8c34
+			return retVal;
dc8c34
+		}
dc8c34
+
dc8c34
 		a_flags_orig = a->a_flags;
dc8c34
 		a->a_flags |= flags;
dc8c34
 		/* Check if the type of the to-be-added values has DN syntax or not. */
dc8c34
@@ -544,6 +557,14 @@ entry_delete_present_values_wsi(Slapi_Entry *e, const char *type, struct berval
dc8c34
 		{
dc8c34
 			/* delete the entire attribute */
dc8c34
 			LDAPDebug( LDAP_DEBUG_ARGS, "removing entire attribute %s\n", type, 0, 0 );
dc8c34
+			const CSN *adcsn = attr_get_deletion_csn(a);
dc8c34
+			if (csn_compare(csn, adcsn) < 0) {
dc8c34
+				/* the attribute was deleted with an adcsn
dc8c34
+				 * newer than the current csn.
dc8c34
+				 * Nothing to do.
dc8c34
+				 */
dc8c34
+				return retVal;
dc8c34
+			}
dc8c34
 			attr_set_deletion_csn(a,csn);
dc8c34
 			if(urp)
dc8c34
 			{
dc8c34
-- 
dc8c34
2.4.11
dc8c34