]> git.sur5r.net Git - openldap/commitdiff
ITS#8789 revert previous patch
authorHoward Chu <hyc@openldap.org>
Thu, 22 Feb 2018 14:59:41 +0000 (14:59 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 28 Feb 2018 22:19:57 +0000 (22:19 +0000)
And try another approach. Always write contextCSN updates, but
don't set dont_replicate for updates we want propagated.

servers/slapd/overlays/accesslog.c
servers/slapd/overlays/syncprov.c
servers/slapd/syncrepl.c

index 77d2c9fddc7c76d4af0e20f3eece7c5bc9cb8b2a..61f9da9781288862c848fdde571fe5b50274ba65 100644 (file)
@@ -1491,17 +1491,9 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
        if ( lo->mask & LOG_OP_WRITES ) {
                slap_callback *cb;
 
-               /* Most internal ops are not logged */
-               if ( op->o_dont_replicate) {
-                       /* Let contextCSN updates from syncrepl thru; the underlying
-                        * syncprov needs to see them. Skip others.
-                        */
-                       if (( op->o_tag != LDAP_REQ_MODIFY ||
-                               op->orm_modlist->sml_op != LDAP_MOD_REPLACE ||
-                               op->orm_modlist->sml_desc != slap_schema.si_ad_contextCSN ) &&
-                               op->orm_no_opattrs )
+               /* These internal ops are not logged */
+               if ( op->o_dont_replicate )
                        return SLAP_CB_CONTINUE;
-               }
 
                ldap_pvt_thread_mutex_lock( &li->li_log_mutex );
                old = li->li_old;
@@ -1963,22 +1955,8 @@ accesslog_op_mod( Operation *op, SlapReply *rs )
        int doit = 0;
 
        /* These internal ops are not logged */
-       if ( op->o_dont_replicate ) {
-               /* Let contextCSN updates from syncrepl thru; the underlying
-                * syncprov needs to see them. Skip others.
-                */
-               if (( op->o_tag != LDAP_REQ_MODIFY ||
-                       op->orm_modlist->sml_op != LDAP_MOD_REPLACE ||
-                       op->orm_modlist->sml_desc != slap_schema.si_ad_contextCSN ) &&
-                       op->orm_no_opattrs )
+       if ( op->o_dont_replicate )
                return SLAP_CB_CONTINUE;
-               /* give this a unique timestamp */
-               op->o_tincr++;
-               if ( op->o_tincr >= 1000000 ) {
-                       op->o_tincr -= 1000000;
-                       op->o_time++;
-               }
-       }
 
        logop = accesslog_op2logop( op );
        lo = logops+logop+EN_OFFSET;
index fbb06050ff0877962d979cf2430d3773a6467064..402182e249a174758d62a98f22fac84f9d4fe016 100644 (file)
@@ -1934,21 +1934,24 @@ syncprov_op_response( Operation *op, SlapReply *rs )
                }
 
                /* Don't do any processing for consumer contextCSN updates */
-               if ( op->o_dont_replicate ) {
-                       if ( op->o_tag == LDAP_REQ_MODIFY &&
-                               op->orm_modlist->sml_op == LDAP_MOD_REPLACE &&
-                               op->orm_modlist->sml_desc == slap_schema.si_ad_contextCSN ) {
+               if ( SLAPD_SYNC_IS_SYNCCONN( op->o_connid ) &&
+                       op->o_tag == LDAP_REQ_MODIFY &&
+                       op->orm_modlist->sml_op == LDAP_MOD_REPLACE &&
+                       op->orm_modlist->sml_desc == slap_schema.si_ad_contextCSN ) {
                        /* Catch contextCSN updates from syncrepl. We have to look at
                         * all the attribute values, as there may be more than one csn
                         * that changed, and only one can be passed in the csn queue.
                         */
-                               csn_changed = syncprov_new_ctxcsn( opc, si, csn_changed,
-                                       op->orm_modlist->sml_numvals, op->orm_modlist->sml_values );
-                       } else {
-                               ldap_pvt_thread_rdwr_wunlock( &si->si_csn_rwlock );
-                       }
+                       csn_changed = syncprov_new_ctxcsn( opc, si, csn_changed,
+                               op->orm_modlist->sml_numvals, op->orm_modlist->sml_values );
+                       if ( csn_changed )
+                               si->si_numops++;
+                       goto leave;
+               }
+               if ( op->o_dont_replicate ) {
                        if ( csn_changed )
                                si->si_numops++;
+                       ldap_pvt_thread_rdwr_wunlock( &si->si_csn_rwlock );
                        goto leave;
                }
 
index a0b87a9ec47be30a45b198d6b6ca3e487dd8044c..36d01d85bf7d69d759ed39abef7ac73497ae4324 100644 (file)
@@ -123,7 +123,6 @@ typedef struct syncinfo_s {
        int                     si_got;
        int                     si_strict_refresh;      /* stop listening during fallback refresh */
        int                     si_too_old;
-       int                     si_has_syncprov;
        ber_int_t       si_msgid;
        Avlnode                 *si_presentlist;
        LDAP                    *si_ld;
@@ -564,7 +563,6 @@ check_syncprov(
                        ber_bvarray_free( a.a_nvals );
                }
                ber_bvarray_free( a.a_vals );
-               si->si_has_syncprov = 1;
        }
        /* See if the cookieState has changed due to anything outside
         * this particular consumer. That includes other consumers in
@@ -729,8 +727,6 @@ do_syncrep1(
                                        si->si_syncCookie.sids[i] = si->si_cookieState->cs_sids[i];
                        }
                        ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
-                       /* Also look in syncprov overlay, if it was already active */
-                       check_syncprov( op, si );
                }
 
                ch_free( si->si_syncCookie.octet_str.bv_val );
@@ -4028,47 +4024,46 @@ syncrepl_updateCookie(
        si->si_cookieState->cs_updating = 1;
        ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
 
-       if ( save || !si->si_has_syncprov ) {
-               op->o_bd = si->si_wbe;
-               slap_queue_csn( op, &first );
-
-               op->o_tag = LDAP_REQ_MODIFY;
-
-               cb.sc_response = syncrepl_null_callback;
-               cb.sc_private = si;
-
-               op->o_callback = &cb;
-               op->o_req_dn = si->si_contextdn;
-               op->o_req_ndn = si->si_contextdn;
-
-               /* update contextCSN */
-               op->o_dont_replicate = 1;
+       op->o_bd = si->si_wbe;
+       slap_queue_csn( op, &first );
 
-               mod.sml_numvals = sc.numcsns;
-               mod.sml_values = sc.ctxcsn;
+       op->o_tag = LDAP_REQ_MODIFY;
 
-               op->orm_modlist = &mod;
-               op->orm_no_opattrs = 1;
-               rc = op->o_bd->be_modify( op, &rs_modify );
-
-               if ( rs_modify.sr_err == LDAP_NO_SUCH_OBJECT &&
-                       SLAP_SYNC_SUBENTRY( op->o_bd )) {
-                       const char      *text;
-                       char txtbuf[SLAP_TEXT_BUFLEN];
-                       size_t textlen = sizeof txtbuf;
-                       Entry *e = slap_create_context_csn_entry( op->o_bd, NULL );
-                       rs_reinit( &rs_modify, REP_RESULT );
-                       rc = slap_mods2entry( &mod, &e, 0, 1, &text, txtbuf, textlen);
-                       op->ora_e = e;
-                       rc = op->o_bd->be_add( op, &rs_modify );
-                       if ( e == op->ora_e )
-                               be_entry_release_w( op, op->ora_e );
-               }
+       cb.sc_response = syncrepl_null_callback;
+       cb.sc_private = si;
 
-               op->orm_no_opattrs = 0;
-               op->o_dont_replicate = 0;
-       } else {
-               rc = 0;
+       op->o_callback = &cb;
+       op->o_req_dn = si->si_contextdn;
+       op->o_req_ndn = si->si_contextdn;
+
+       /* update contextCSN */
+       op->o_dont_replicate = !save;
+
+       /* avoid timestamp collisions */
+       if ( save )
+               slap_op_time( &op->o_time, &op->o_tincr );
+
+       mod.sml_numvals = sc.numcsns;
+       mod.sml_values = sc.ctxcsn;
+
+       op->orm_modlist = &mod;
+       op->orm_no_opattrs = 1;
+       rc = op->o_bd->be_modify( op, &rs_modify );
+
+       if ( rs_modify.sr_err == LDAP_NO_SUCH_OBJECT &&
+               SLAP_SYNC_SUBENTRY( op->o_bd )) {
+               const char      *text;
+               char txtbuf[SLAP_TEXT_BUFLEN];
+               size_t textlen = sizeof txtbuf;
+               Entry *e = slap_create_context_csn_entry( op->o_bd, NULL );
+               rs_reinit( &rs_modify, REP_RESULT );
+               rc = slap_mods2entry( &mod, &e, 0, 1, &text, txtbuf, textlen);
+               slap_queue_csn( op, &first );
+               op->o_tag = LDAP_REQ_ADD;
+               op->ora_e = e;
+               rc = op->o_bd->be_add( op, &rs_modify );
+               if ( e == op->ora_e )
+                       be_entry_release_w( op, op->ora_e );
        }
 
        op->orm_no_opattrs = 0;
@@ -4111,8 +4106,7 @@ syncrepl_updateCookie(
        ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
 
        op->o_bd = be;
-       if ( op->o_csn.bv_val )
-               op->o_tmpfree( op->o_csn.bv_val, op->o_tmpmemctx );
+       op->o_tmpfree( op->o_csn.bv_val, op->o_tmpmemctx );
        BER_BVZERO( &op->o_csn );
        if ( mod.sml_next ) slap_mods_free( mod.sml_next, 1 );