]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9342 delta-sync: ignore add if entryCSN is too old
authorHoward Chu <hyc@openldap.org>
Wed, 30 Sep 2020 09:15:36 +0000 (10:15 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Wed, 30 Sep 2020 21:54:27 +0000 (21:54 +0000)
This check is only needed for ops received without a CSN in their cookie.
This only occurs when the ops completed out of order on the provider.

servers/slapd/syncrepl.c

index 6022b8cfda904ffbbc15e173e7c7f7d1025da4c6..88af1011aa7e2283dd2535eeee1ccd52b8db242a 100644 (file)
@@ -2598,11 +2598,30 @@ syncrepl_message_to_op(
                                "mods2entry (%s)\n",
                                        si->si_ridtxt, text, 0 );
                        } else {
-                               rc = op->o_bd->be_add( op, &rs );
-                               Debug( LDAP_DEBUG_SYNC,
-                                       "syncrepl_message_to_op: %s be_add %s (%d)\n", 
-                                       si->si_ridtxt, op->o_req_dn.bv_val, rc );
-                               do_graduate = 0;
+                               rc = CV_CSN_OK;
+                               if ( do_lock ) {
+                                       /* do_lock is only true because we didn't get a cookieCSN and
+                                        * therefore didn't already lock the pending list. See if the
+                                        * entryCSN is fresh enough. Ignore this op if too old.
+                                        */
+                                       Attribute *a = attr_find( e->e_attrs, slap_schema.si_ad_entryCSN );
+                                       if ( a ) {
+                                               int sid = slap_parse_csn_sid( &a->a_nvals[0] );
+                                               ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
+                                               rc = check_csn_age( si, &op->o_req_dn, &a->a_nvals[0],
+                                                       sid, (cookie_vals *)&si->si_cookieState->cs_vals, NULL );
+                                               ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
+                                       }
+                               }
+                               if ( rc == CV_CSN_OLD ) {
+                                       rc = LDAP_SUCCESS;
+                               } else {
+                                       rc = op->o_bd->be_add( op, &rs );
+                                       Debug( LDAP_DEBUG_SYNC,
+                                               "syncrepl_message_to_op: %s be_add %s (%d)\n",
+                                               si->si_ridtxt, op->o_req_dn.bv_val, rc );
+                                       do_graduate = 0;
+                               }
                        }
                        if ( e == op->ora_e )
                                be_entry_release_w( op, op->ora_e );