Use BDB transaction log for debug messages

This commit is contained in:
Howard Chu 2007-12-05 22:27:12 +00:00
parent 460e94c001
commit cff654bd60
2 changed files with 39 additions and 1 deletions

View File

@ -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 ) {

View File

@ -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",