From cff654bd6003360f5a01fb055bcc2a75535b1e67 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 5 Dec 2007 22:27:12 +0000 Subject: [PATCH] Use BDB transaction log for debug messages --- servers/slapd/back-bdb/cache.c | 19 ++++++++++++++++++- servers/slapd/back-bdb/delete.c | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index bf0c02b0a4..8d6d0c293f 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -364,7 +364,12 @@ bdb_entryinfo_add_internal( bdb->bi_cache.c_leaves++; rc = avl_insert( &ei->bei_parent->bei_kids, ei2, bdb_rdn_cmp, avl_dup_error ); - assert( !rc ); +#if defined(LDAP_DEBUG) && defined(LDAP_DEVEL) + if ( rc ) { + bdb->bi_dbenv->log_flush( bdb->bi_dbenv, NULL ); + assert( !rc ); + } +#endif #ifdef BDB_HIER ei->bei_parent->bei_ckids++; #endif @@ -432,6 +437,11 @@ bdb_cache_find_ndn( (ei.bei_nrdn.bv_val - ndn->bv_val); bdb_cache_entryinfo_unlock( eip ); +#if defined(LDAP_DEBUG) && defined(LDAP_DEVEL) + bdb->bi_dbenv->log_printf( bdb->bi_dbenv, NULL, "Reading %s", + ei.bei_nrdn.bv_val ); +#endif + rc = bdb_dn2id( op, locker, &ei.bei_nrdn, &ei ); if (rc) { bdb_cache_entryinfo_lock( eip ); @@ -439,9 +449,16 @@ bdb_cache_find_ndn( return rc; } +#if defined(LDAP_DEBUG) && defined(LDAP_DEVEL) + bdb->bi_dbenv->log_printf( bdb->bi_dbenv, NULL, "Read got %s(%d)", + ei.bei_nrdn.bv_val, ei.bei_id ); +#endif + /* DN exists but needs to be added to cache */ ei.bei_nrdn.bv_len = len; rc = bdb_entryinfo_add_internal( bdb, &ei, &ei2 ); + Debug( LDAP_DEBUG_TRACE, "add_internal: \"%s\" %d\n", + ei.bei_nrdn.bv_val, ei.bei_id, 0 ); /* add_internal left eip and c_rwlock locked */ ldap_pvt_thread_rdwr_wunlock( &bdb->bi_cache.c_rwlock ); if ( rc ) { diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index c9fdba93d6..765a8acc63 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -372,6 +372,11 @@ retry: /* transaction retry */ goto return_results; } +#if defined(LDAP_DEBUG) && defined(LDAP_DEVEL) + bdb->bi_dbenv->log_printf( bdb->bi_dbenv, lt2, "Starting delete %s(%d)", + e->e_nname.bv_val, e->e_id ); +#endif + /* Can't do it if we have kids */ rs->sr_err = bdb_cache_children( op, lt2, e ); if( rs->sr_err != DB_NOTFOUND ) { @@ -492,6 +497,11 @@ retry: /* transaction retry */ p = NULL; } +#if defined(LDAP_DEBUG) && defined(LDAP_DEVEL) + bdb->bi_dbenv->log_printf( bdb->bi_dbenv, lt2, "Commit1 delete %s(%d)", + e->e_nname.bv_val, e->e_id ); +#endif + if ( TXN_COMMIT( lt2, 0 ) != 0 ) { rs->sr_err = LDAP_OTHER; rs->sr_text = "txn_commit(2) failed"; @@ -517,6 +527,12 @@ retry: /* transaction retry */ goto return_results; } } else { + +#if defined(LDAP_DEBUG) && defined(LDAP_DEVEL) + bdb->bi_dbenv->log_printf( bdb->bi_dbenv, ltid, "Cache delete %s(%d)", + e->e_nname.bv_val, e->e_id ); +#endif + rc = bdb_cache_delete( bdb, e, locker, &lock ); switch( rc ) { case DB_LOCK_DEADLOCK: @@ -529,6 +545,11 @@ retry: /* transaction retry */ ltid = NULL; op->o_private = NULL; +#if defined(LDAP_DEBUG) && defined(LDAP_DEVEL) + bdb->bi_dbenv->log_printf( bdb->bi_dbenv, NULL, "Committed delete %s(%d)", + e->e_nname.bv_val, e->e_id ); +#endif + if( rs->sr_err != 0 ) { Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_delete) ": txn_%s failed: %s (%d)\n", -- 2.39.5