]> git.sur5r.net Git - openldap/commitdiff
Context CSN Patch (5)
authorJong Hyuk Choi <jongchoi@openldap.org>
Tue, 26 Aug 2003 00:35:27 +0000 (00:35 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Tue, 26 Aug 2003 00:35:27 +0000 (00:35 +0000)
- persistent search patch
- cascading search patch

servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/search.c
tests/scripts/test018-syncreplication-persist
tests/scripts/test020-syncreplication-cascading

index 2bdc1a8b73a4b3f50825a24f80ba8866e2ab3f31..9877210970915591fa09ae9df0a02766b0bc2538 100644 (file)
@@ -470,13 +470,18 @@ retry:    /* transaction retry */
                goto return_results;
        }
 
+#ifdef LDAP_SYNCREPL
+       if ( !op->o_bd->syncinfo )
+#endif
 #ifdef LDAP_SYNC
-       rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker );
-       switch ( rc ) {
-       case BDB_CSN_ABORT :
-               goto return_results;
-       case BDB_CSN_RETRY :
-               goto retry;
+       {
+               rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker );
+               switch ( rc ) {
+               case BDB_CSN_ABORT :
+                       goto return_results;
+               case BDB_CSN_RETRY :
+                       goto retry;
+               }
        }
 #endif
 
@@ -512,11 +517,16 @@ retry:    /* transaction retry */
 
                        bdb_cache_add( bdb, ei, op->oq_add.rs_e, &nrdn, locker );
 
+#ifdef LDAP_SYNCREPL
+                       if ( !op->o_bd->syncinfo )
+#endif
 #ifdef LDAP_SYNC
-                       if ( ctxcsn_added ) {
-                               ctx_nrdn.bv_val = "cn=ldapsync";
-                               ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val );
-                               bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+                       {
+                               if ( ctxcsn_added ) {
+                                       ctx_nrdn.bv_val = "cn=ldapsync";
+                                       ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val );
+                                       bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+                               }
                        }
 #endif
 
index a1c191388aa4d48c83127b13051c17b1ce68bc22..db013e6a85fa86fa55e33272b35913b93347356d 100644 (file)
@@ -460,13 +460,18 @@ retry:    /* transaction retry */
        ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex );
 #endif
 
+#ifdef LDAP_SYNCREPL
+       if ( !op->o_bd->syncinfo )
+#endif
 #ifdef LDAP_SYNC
-       rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker );
-       switch ( rc ) {
-       case BDB_CSN_ABORT :
-               goto return_results;
-       case BDB_CSN_RETRY :
-               goto retry;
+       {
+               rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker );
+               switch ( rc ) {
+               case BDB_CSN_ABORT :
+                       goto return_results;
+               case BDB_CSN_RETRY :
+                       goto retry;
+               }
        }
 #endif
 
@@ -485,11 +490,16 @@ retry:    /* transaction retry */
                bdb_cache_delete( &bdb->bi_cache, e, bdb->bi_dbenv,
                        locker, &lock );
 
+#ifdef LDAP_SYNCREPL
+               if ( !op->o_bd->syncinfo )
+#endif
 #ifdef LDAP_SYNC
-               if ( ctxcsn_added ) {
-                       ctx_nrdn.bv_val = "cn=ldapsync";
-                       ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val );
-                       bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+               {
+                       if ( ctxcsn_added ) {
+                               ctx_nrdn.bv_val = "cn=ldapsync";
+                               ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val );
+                               bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+                       }
                }
 #endif
 
index 938e60ca1e4fcdf0e0097e536e515d079e748c06..a7ed134aefc6e81b3da408479a4304c5780fda6c 100644 (file)
@@ -575,13 +575,18 @@ retry:    /* transaction retry */
                goto return_results;
        }
 
+#ifdef LDAP_SYNCREPL
+       if ( !op->o_bd->syncinfo )
+#endif
 #ifdef LDAP_SYNC
-       rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker );
-       switch ( rc ) {
-       case BDB_CSN_ABORT :
-               goto return_results;
-       case BDB_CSN_RETRY :
-               goto retry;
+       {
+               rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker );
+               switch ( rc ) {
+               case BDB_CSN_ABORT :
+                       goto return_results;
+               case BDB_CSN_RETRY :
+                       goto retry;
+               }
        }
 #endif
 
@@ -599,11 +604,16 @@ retry:    /* transaction retry */
 #endif
                bdb_cache_modify( e, dummy.e_attrs, bdb->bi_dbenv, locker, &lock );
 
+#ifdef LDAP_SYNCREPL
+               if ( !op->o_bd->syncinfo )
+#endif
 #ifdef LDAP_SYNC
-               if ( ctxcsn_added ) {
-                       ctx_nrdn.bv_val = "cn=ldapsync";
-                       ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val );
-                       bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+               {
+                       if ( ctxcsn_added ) {
+                               ctx_nrdn.bv_val = "cn=ldapsync";
+                               ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val );
+                               bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+                       }
                }
 #endif
 
index 8f20bd0c4294c4d9d0e3d055b6b53a865ef8f536..b158ed7f425518e1bd08469c9c8fb42bae306592 100644 (file)
@@ -915,13 +915,18 @@ retry:    /* transaction retry */
                goto return_results;
        }
 
+#ifdef LDAP_SYNCREPL
+       if ( !op->o_bd->syncinfo )
+#endif
 #ifdef LDAP_SYNC
-       rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker );
-       switch ( rc ) {
-       case BDB_CSN_ABORT :
-               goto return_results;
-       case BDB_CSN_RETRY :
-               goto retry;
+       {
+               rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker );
+               switch ( rc ) {
+               case BDB_CSN_ABORT :
+                       goto return_results;
+               case BDB_CSN_RETRY :
+                       goto retry;
+               }
        }
 #endif
 
@@ -949,11 +954,16 @@ retry:    /* transaction retry */
                        bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip,
                                bdb->bi_dbenv, locker, &lock );
 
+#ifdef LDAP_SYNCREPL
+                       if ( !op->o_bd->syncinfo )
+#endif
 #ifdef LDAP_SYNC
-                       if ( ctxcsn_added ) {
-                               ctx_nrdn.bv_val = "cn=ldapsync";
-                               ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val );
-                               bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+                       {
+                               if ( ctxcsn_added ) {
+                                       ctx_nrdn.bv_val = "cn=ldapsync";
+                                       ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val );
+                                       bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker );
+                               }
                        }
 #endif
 
index fa84086001d32c3fc37279eab72629f632582bda..007e0ba699b571cbe97ce4ab8d56b593ced5ce31 100644 (file)
@@ -688,17 +688,55 @@ dn2entry_retry:
 
 #ifdef LDAP_SYNC
        if ( sop->o_sync_mode != SLAP_SYNC_NONE ) {
-               ber_str2bv( "cn=ldapsync", strlen("cn=ldapsync"), 0, &ctxcsn_rdn );
-               build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &ctxcsn_rdn );
+#ifdef LDAP_SYNCREPL
+               if ( sop->o_bd->syncinfo ) {
+                       char substr[67];
+                       sprintf( substr, "cn=syncrepl%d", sop->o_bd->syncinfo->id );
+                       ber_str2bv( substr, strlen( substr ), 0, &ctxcsn_rdn );
+                       build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &ctxcsn_rdn );
+               } else
+#endif
+               {
+                       ber_str2bv( "cn=ldapsync", strlen("cn=ldapsync"), 0, &ctxcsn_rdn );
+                       build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0], &ctxcsn_rdn );
+               }
 
-               bdb_dn2entry( op, NULL, &ctxcsn_ndn, &ctxcsn_ei, 0, locker, &ctxcsn_lock );
+ctxcsn_retry :
+               rs->sr_err = bdb_dn2entry( op, NULL, &ctxcsn_ndn, &ctxcsn_ei, 0, locker, &ctxcsn_lock );
+
+               switch(rs->sr_err) {
+               case 0:
+                       e = ei->bei_e; break;
+               case LDAP_BUSY:
+                       send_ldap_error( sop, rs, LDAP_BUSY, "ldap server busy" );
+                       LOCK_ID_FREE (bdb->bi_dbenv, locker );
+                       return LDAP_BUSY;
+               case DB_LOCK_DEADLOCK:
+               case DB_LOCK_NOTGRANTED:
+                       goto ctxcsn_retry;
+               case DB_NOTFOUND:
+                       send_ldap_error( sop, rs, LDAP_OTHER, "context csn entry not present" );
+                       LOCK_ID_FREE( bdb->bi_dbenv, locker );
+                       return rs->sr_err;
+               default:
+                       send_ldap_error( sop, rs, LDAP_OTHER, "internal error" );
+                       LOCK_ID_FREE (bdb->bi_dbenv, locker );
+                       return rs->sr_err;
+               }
 
                if ( ctxcsn_ei ) {
                        ctxcsn_e = ctxcsn_ei->bei_e;
                }
 
                if ( ctxcsn_e ) {
-                       csn_a = attr_find( ctxcsn_e->e_attrs, slap_schema.si_ad_contextCSN );
+#ifdef LDAP_SYNCREPL
+                       if ( sop->o_bd->syncinfo ) {
+                               csn_a = attr_find( ctxcsn_e->e_attrs, slap_schema.si_ad_syncreplCookie );
+                       } else
+#endif
+                       {
+                               csn_a = attr_find( ctxcsn_e->e_attrs, slap_schema.si_ad_contextCSN );
+                       }
                        if ( csn_a ) {
                                search_context_csn = ber_dupbv( NULL, &csn_a->a_vals[0] );
                        } else {
@@ -838,7 +876,7 @@ dn2entry_retry:
                csnfge.f_av_desc = slap_schema.si_ad_entryCSN;
                csnfge.f_av_value = sop->o_sync_state;
 
-               if ( search_context_csn ) {
+               if ( search_context_csn && !IS_PSEARCH ) {
                        csnfge.f_next = &contextcsnand;
 
                        contextcsnand.f_choice = LDAP_FILTER_AND;
index cc6022f570c5a5732cdf18a31126409b107d1d48..3a71e5959c5ab1d329ebfc47e16035611ea537b5 100755 (executable)
@@ -8,9 +8,6 @@ fi
 
 . $SRCDIR/scripts/args.sh $*
 
-echo "test018-syncreplication-persist is temporarily disabled"
-exit 0
-
 echo "running defines.sh"
 . $SRCDIR/scripts/defines.sh
 
index 2920cf617ded2263f45dffc8363775474b8dbe3b..e84d59528146f800b8cf4e9beb06abd48720a51e 100755 (executable)
@@ -11,9 +11,6 @@ fi
 echo "running defines.sh"
 . $SRCDIR/scripts/defines.sh
 
-echo "test020-syncreplication-cascading is temporarily disabled"
-exit 0
-
 #
 # Test replication:
 # - start master