Pārlūkot izejas kodu

Ticket #369 - restore of replica ldif file on second master after deleting two records shows only 1 deletion

Bug Description:  If you take a "db2ldif -r" on a consumer and later restore it "ldif2db"
                  any changes made on that consumer after the backup(db2ldif), will not be
                  replayed back to the consumer after it has been restored(ldif2db).

Fix Description:  When we check if we can skip updates from the change log, check if the
                  consumer csn is "newer" than its current max csn.  If it is, then it
                  needs to be replayed back to itself.

https://fedorahosted.org/389/ticket/369

Reviewed by: Nathan & Rich (Thanks!)
Mark Reynolds 13 gadi atpakaļ
vecāks
revīzija
a640ac2197
1 mainītis faili ar 13 papildinājumiem un 2 dzēšanām
  1. 13 2
      ldap/servers/plugins/replication/cl5_clcache.c

+ 13 - 2
ldap/servers/plugins/replication/cl5_clcache.c

@@ -664,13 +664,24 @@ clcache_skip_change ( CLC_Buffer *buf )
 		rid = csn_get_replicaid ( buf->buf_current_csn );
 
 		/*
-		 * Skip CSN that is originated from the consumer.
+		 * Skip CSN that is originated from the consumer,
+		 * unless the CSN is newer than the maxcsn.
 		 * If RID==65535, the CSN is originated from a
 		 * legacy consumer. In this case the supplier
 		 * and the consumer may have the same RID.
 		 */
-		if (rid == buf->buf_consumer_rid && rid != MAX_REPLICA_ID)
+		if (rid == buf->buf_consumer_rid && rid != MAX_REPLICA_ID){
+			CSN *cons_maxcsn = NULL;
+
+			ruv_get_max_csn(buf->buf_consumer_ruv, &cons_maxcsn);
+			if ( csn_compare ( buf->buf_current_csn, cons_maxcsn) > 0 ) {
+				/*
+				 *  The consumer must have been "restored" and needs this newer update.
+				 */
+				skip = 0;
+			}
 			break;
+		}
 
 		/* Skip helper entry (ENTRY_COUNT, PURGE_RUV and so on) */
 		if ( cl5HelperEntry ( NULL, buf->buf_current_csn ) == PR_TRUE ) {