mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-14 08:13:10 -05:00
Delete CDB (no transactions) support
This commit is contained in:
parent
a8710d2105
commit
98a2c60c3a
9 changed files with 113 additions and 156 deletions
|
|
@ -77,22 +77,20 @@ retry: /* transaction retry */
|
|||
}
|
||||
|
||||
/* begin transaction */
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_add: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
#if 0
|
||||
lockid = TXN_ID( ltid );
|
||||
#endif
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_add: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
#if 0
|
||||
lockid = TXN_ID( ltid );
|
||||
#endif
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
opinfo.boi_txn = ltid;
|
||||
|
|
@ -341,9 +339,7 @@ retry: /* transaction retry */
|
|||
goto return_results;
|
||||
}
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
}
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,6 @@ struct bdb_info {
|
|||
int bi_nrdns;
|
||||
#endif
|
||||
|
||||
int bi_txn;
|
||||
int bi_txn_cp;
|
||||
u_int32_t bi_txn_cp_min;
|
||||
u_int32_t bi_txn_cp_kbyte;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include "back-bdb.h"
|
||||
|
||||
#define SLAP_BDB_ALLOW_DBNOTXN
|
||||
#ifdef DB_DIRTY_READ
|
||||
# define SLAP_BDB_ALLOW_DIRTY_READ
|
||||
#endif
|
||||
|
|
@ -47,11 +46,6 @@ bdb_db_config(
|
|||
}
|
||||
bdb->bi_dbenv_home = ch_strdup( argv[1] );
|
||||
|
||||
#ifdef SLAP_BDB_ALLOW_DBNOTXN
|
||||
/* turn off transactions, use CDB mode instead */
|
||||
} else if ( strcasecmp( argv[0], "dbnotxn" ) == 0 ) {
|
||||
bdb->bi_txn = 0;
|
||||
#endif
|
||||
#ifdef SLAP_BDB_ALLOW_DIRTY_READ
|
||||
} else if ( strcasecmp( argv[0], "dirtyread" ) == 0 ) {
|
||||
bdb->bi_db_opflags |= DB_DIRTY_READ;
|
||||
|
|
|
|||
|
|
@ -58,23 +58,21 @@ retry: /* transaction retry */
|
|||
ldap_pvt_thread_yield();
|
||||
}
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_delete: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
#if 0
|
||||
lockid = TXN_ID( ltid );
|
||||
#endif
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_delete: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
#if 0
|
||||
lockid = TXN_ID( ltid );
|
||||
#endif
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
opinfo.boi_txn = ltid;
|
||||
|
|
@ -334,9 +332,7 @@ retry: /* transaction retry */
|
|||
ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex );
|
||||
#endif
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
}
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ bdb_db_init( BackendDB *be )
|
|||
bdb->bi_dbenv_home = ch_strdup( BDB_DBENV_HOME );
|
||||
bdb->bi_dbenv_xflags = 0;
|
||||
bdb->bi_dbenv_mode = DEFAULT_MODE;
|
||||
bdb->bi_txn = 1; /* default to using transactions */
|
||||
|
||||
bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
|
||||
|
||||
|
|
@ -171,15 +170,8 @@ bdb_db_open( BackendDB *be )
|
|||
return rc;
|
||||
}
|
||||
|
||||
flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_RECOVER;
|
||||
|
||||
} else {
|
||||
flags |= DB_INIT_CDB;
|
||||
bdb->bi_txn_cp = 0;
|
||||
}
|
||||
flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE
|
||||
| DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_RECOVER;
|
||||
|
||||
bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0]->bv_val );
|
||||
bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
|
||||
|
|
@ -366,13 +358,11 @@ bdb_db_destroy( BackendDB *be )
|
|||
/* close db environment */
|
||||
if( bdb->bi_dbenv ) {
|
||||
/* force a checkpoint */
|
||||
if( bdb->bi_txn ) {
|
||||
rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
}
|
||||
rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
}
|
||||
|
||||
bdb_cache_release_all (&bdb->bi_cache);
|
||||
|
|
|
|||
|
|
@ -215,19 +215,17 @@ retry: /* transaction retry */
|
|||
ldap_pvt_thread_yield();
|
||||
}
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_modify: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_modify: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
|
|
@ -330,9 +328,7 @@ retry: /* transaction retry */
|
|||
goto return_results;
|
||||
}
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
}
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -92,19 +92,17 @@ retry: /* transaction retry */
|
|||
ldap_pvt_thread_yield();
|
||||
}
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_delete: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_delete: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
text = "internal error";
|
||||
goto return_results;
|
||||
}
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
|
|
@ -622,9 +620,7 @@ retry: /* transaction retry */
|
|||
goto return_results;
|
||||
}
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
}
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -102,19 +102,17 @@ retry: /* transaction retry */
|
|||
ldap_pvt_thread_yield();
|
||||
}
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
*text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_exop_passwd: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
*text = "internal error";
|
||||
goto done;
|
||||
}
|
||||
/* begin transaction */
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, <id,
|
||||
bdb->bi_db_opflags );
|
||||
*text = NULL;
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_TRACE,
|
||||
"bdb_exop_passwd: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
rc = LDAP_OTHER;
|
||||
*text = "internal error";
|
||||
goto done;
|
||||
}
|
||||
|
||||
opinfo.boi_bdb = be;
|
||||
|
|
@ -199,7 +197,7 @@ retry: /* transaction retry */
|
|||
rc = LDAP_OTHER;
|
||||
}
|
||||
|
||||
if( bdb->bi_txn && rc == 0 ) {
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,18 +130,16 @@ ID bdb_tool_entry_put(
|
|||
Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
|
||||
(long) e->e_id, e->e_dn, 0 );
|
||||
|
||||
if( bdb->bi_txn ) {
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, &tid,
|
||||
bdb->bi_db_opflags );
|
||||
if( rc != 0 ) {
|
||||
snprintf( text->bv_val, text->bv_len,
|
||||
"txn_begin failed: %s (%d)",
|
||||
db_strerror(rc), rc );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: %s\n",
|
||||
text->bv_val, 0, 0 );
|
||||
return NOID;
|
||||
}
|
||||
rc = txn_begin( bdb->bi_dbenv, NULL, &tid,
|
||||
bdb->bi_db_opflags );
|
||||
if( rc != 0 ) {
|
||||
snprintf( text->bv_val, text->bv_len,
|
||||
"txn_begin failed: %s (%d)",
|
||||
db_strerror(rc), rc );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: %s\n",
|
||||
text->bv_val, 0, 0 );
|
||||
return NOID;
|
||||
}
|
||||
|
||||
rc = bdb_next_id( be, tid, &e->e_id );
|
||||
|
|
@ -192,29 +190,27 @@ ID bdb_tool_entry_put(
|
|||
}
|
||||
|
||||
done:
|
||||
if( bdb->bi_txn ) {
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
snprintf( text->bv_val, text->bv_len,
|
||||
"txn_commit failed: %s (%d)",
|
||||
db_strerror(rc), rc );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: %s\n",
|
||||
text->bv_val, 0, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
} else {
|
||||
txn_abort( tid );
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
snprintf( text->bv_val, text->bv_len,
|
||||
"txn_aborted! %s (%d)",
|
||||
"txn_commit failed: %s (%d)",
|
||||
db_strerror(rc), rc );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: %s\n",
|
||||
text->bv_val, 0, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
} else {
|
||||
txn_abort( tid );
|
||||
snprintf( text->bv_val, text->bv_len,
|
||||
"txn_aborted! %s (%d)",
|
||||
db_strerror(rc), rc );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_put: %s\n",
|
||||
text->bv_val, 0, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
return e->e_id;
|
||||
|
|
@ -242,14 +238,12 @@ int bdb_tool_entry_reindex(
|
|||
return -1;
|
||||
}
|
||||
|
||||
if( bi->bi_txn ) {
|
||||
rc = txn_begin( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
goto done;
|
||||
}
|
||||
rc = txn_begin( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -279,23 +273,21 @@ int bdb_tool_entry_reindex(
|
|||
rc = bdb_index_entry_add( be, tid, e, e->e_attrs );
|
||||
|
||||
done:
|
||||
if( bi->bi_txn ) {
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
} else {
|
||||
txn_abort( tid );
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n",
|
||||
"=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
} else {
|
||||
txn_abort( tid );
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n",
|
||||
db_strerror(rc), rc, 0 );
|
||||
e->e_id = NOID;
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
|
|
|||
Loading…
Reference in a new issue