From 79b04b12a2276a21e1395458188430722c1478ac Mon Sep 17 00:00:00 2001 From: Jong Hyuk Choi Date: Tue, 26 Aug 2003 00:35:27 +0000 Subject: [PATCH] Context CSN Patch (5) - persistent search patch - cascading search patch --- servers/slapd/back-bdb/add.c | 30 ++++++++---- servers/slapd/back-bdb/delete.c | 30 ++++++++---- servers/slapd/back-bdb/modify.c | 30 ++++++++---- servers/slapd/back-bdb/modrdn.c | 30 ++++++++---- servers/slapd/back-bdb/search.c | 48 +++++++++++++++++-- tests/scripts/test018-syncreplication-persist | 3 -- .../scripts/test020-syncreplication-cascading | 3 -- 7 files changed, 123 insertions(+), 51 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 2bdc1a8b73..9877210970 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -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 diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index a1c191388a..db013e6a85 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -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 diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 938e60ca1e..a7ed134aef 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -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 diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 8f20bd0c42..b158ed7f42 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -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 diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index fa84086001..007e0ba699 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -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; diff --git a/tests/scripts/test018-syncreplication-persist b/tests/scripts/test018-syncreplication-persist index cc6022f570..3a71e5959c 100755 --- a/tests/scripts/test018-syncreplication-persist +++ b/tests/scripts/test018-syncreplication-persist @@ -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 diff --git a/tests/scripts/test020-syncreplication-cascading b/tests/scripts/test020-syncreplication-cascading index 2920cf617d..e84d595281 100755 --- a/tests/scripts/test020-syncreplication-cascading +++ b/tests/scripts/test020-syncreplication-cascading @@ -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 -- 2.39.5