}
/* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
- text = NULL;
- if( rc != 0 ) {
+ if (bdb->bi_txn) {
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
+ 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;
+ }
}
opinfo.boi_bdb = be;
goto return_results;
}
- rc = txn_commit( ltid, 0 );
+ if( bdb->bi_txn )
+ rc = txn_commit( ltid, 0 );
ltid = NULL;
op->o_private = NULL;
slap_mask_t bi_defaultmask;
Avlnode *bi_attrs;
+ int bi_txn;
int bi_txn_cp;
u_int32_t bi_txn_cp_min;
u_int32_t bi_txn_cp_kbyte;
}
bdb->bi_dbenv_home = ch_strdup( argv[1] );
+ /* turn off transactions, use CDB mode instead */
+ } else if ( strcasecmp( argv[0], "dbnotxn" ) == 0 ) {
+ bdb->bi_txn = 0;
/* transaction checkpoint configuration */
} else if ( strcasecmp( argv[0], "dbnosync" ) == 0 ) {
}
}
- /* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
- text = NULL;
- if( rc != 0 ) {
+ if (bdb->bi_txn) {
+ /* begin transaction */
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
+ 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;
goto return_results;
}
- rc = txn_commit( ltid, 0 );
+ if (bdb->bi_txn)
+ rc = txn_commit( ltid, 0 );
ltid = NULL;
op->o_private = NULL;
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 */
#ifndef NO_THREADS
bdb->bi_lock_detect = DB_LOCK_NORUN;
return rc;
}
- flags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN |
- DB_THREAD | DB_CREATE | DB_RECOVER;
+ 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;
+ bdb->bi_dbenv->set_lk_detect(bdb->bi_dbenv, DB_LOCK_DEFAULT);
+ }
bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0] );
bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
/* force a checkpoint */
+ if (bdb->bi_txn) {
rc = txn_checkpoint( bdb->bi_dbenv, 0, 0, DB_FORCE );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
db_strerror(rc), rc, 0 );
return rc;
}
+ }
while( bdb->bi_ndatabases-- ) {
rc = bdb->bi_databases[bdb->bi_ndatabases]->bdi_db->close(
const char *text = NULL;
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
- DB_TXN *ltid;
+ DB_TXN *ltid = NULL;
struct bdb_op_info opinfo;
Debug( LDAP_DEBUG_ARGS, "bdb_modify: %s\n", dn, 0, 0 );
}
}
- /* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
- text = NULL;
- if( rc != 0 ) {
+ if (bdb->bi_txn) {
+ /* begin transaction */
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
+ 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;
goto return_results;
}
- rc = txn_commit( ltid, 0 );
+ if (bdb->bi_txn)
+ rc = txn_commit( ltid, 0 );
ltid = NULL;
op->o_private = NULL;
}
- /* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
- text = NULL;
- if( rc != 0 ) {
+ if (bdb->bi_txn) {
+ /* begin transaction */
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
+ 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;
goto return_results;
}
- rc = txn_commit( ltid, 0 );
+ if (bdb->bi_txn)
+ rc = txn_commit( ltid, 0 );
ltid = NULL;
op->o_private = NULL;
ID kid = NOID;
ID id;
DBT key, data;
- DB_TXN *ltid;
+ DB_TXN *ltid = NULL;
DBTzero( &key );
key.data = (char *) &kid;
}
}
- rc = txn_begin( bdb->bi_dbenv, tid, <id, 0 );
- if( rc != 0 ) {
+ if (bdb->bi_txn) {
+ rc = txn_begin( bdb->bi_dbenv, tid, <id, 0 );
+ if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
"=> bdb_next_id: txn_begin failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
return rc;
+ }
}
/* get existing value for read/modify/write */
bdb->bi_lastid = id;
- rc = txn_commit( ltid, 0 );
+ if (bdb->bi_txn)
+ {
+ rc = txn_commit( ltid, 0 );
+ ltid = NULL;
+ }
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
}
}
- /* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
- *text = NULL;
- if( rc != 0 ) {
+ if (bdb->bi_txn) {
+ /* begin transaction */
+ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 );
+ *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;
}
*text = "entry update failed";
rc = LDAP_OTHER;
- } else
- {
+ }
+ if (bdb->bi_txn && rc == 0) {
rc = txn_commit( ltid, 0 );
ltid = NULL;
- op->o_private = NULL;
- if (rc)
- *text = "commit failed";
}
+ op->o_private = NULL;
done:
if( e != NULL ) {
int bdb_tool_entry_open(
BackendDB *be, int mode )
{
- int rc;
- struct bdb_info *bdb = (struct bdb_info *) be->be_private;
-
- assert( be != NULL );
- assert( bdb != NULL );
-
- rc = bdb->bi_id2entry->bdi_db->cursor(
- bdb->bi_id2entry->bdi_db, NULL, &cursor, 0 );
- if( rc != 0 ) {
- return NOID;
- }
-
/* initialize key and data thangs */
DBTzero( &key );
DBTzero( &data );
{
int rc;
ID id;
+ struct bdb_info *bdb = (struct bdb_info *) be->be_private;
assert( be != NULL );
assert( slapMode & SLAP_TOOL_MODE );
- assert( cursor != NULL );
+ assert( bdb != NULL );
+
+ if (cursor == NULL) {
+ rc = bdb->bi_id2entry->bdi_db->cursor(
+ bdb->bi_id2entry->bdi_db, NULL, &cursor, 0 );
+ if( rc != 0 ) {
+ return NOID;
+ }
+ }
rc = cursor->c_get( cursor, &key, &data, DB_NEXT );
{
int rc;
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
- DB_TXN *tid;
+ DB_TXN *tid = NULL;
assert( be != NULL );
assert( slapMode & SLAP_TOOL_MODE );
Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
(long) e->e_id, e->e_dn, 0 );
- rc = txn_begin( bdb->bi_dbenv, NULL, &tid, 0 );
- if( rc != 0 ) {
+ if (bdb->bi_txn) {
+ rc = txn_begin( bdb->bi_dbenv, NULL, &tid, 0 );
+ if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
"=> bdb_tool_entry_put: txn_begin failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
return NOID;
+ }
}
rc = bdb_next_id( be, tid, &e->e_id );
}
done:
- if( rc == 0 ) {
+ if( bdb->bi_txn ) {
+ if( rc == 0 ) {
rc = txn_commit( tid, 0 );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
e->e_id = NOID;
}
- } else {
+ } else {
txn_abort( tid );
Debug( LDAP_DEBUG_ANY,
"=> bdb_tool_entry_put: txn_aborted! %s (%d)\n",
db_strerror(rc), rc, 0 );
e->e_id = NOID;
+ }
}
return e->e_id;
return -1;
}
- rc = txn_begin( bi->bi_dbenv, NULL, &tid, 0 );
- if( rc != 0 ) {
+ if( bi->bi_txn ) {
+ rc = txn_begin( bi->bi_dbenv, NULL, &tid, 0 );
+ 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 = bdb_index_entry_add( be, tid, e, e->e_attrs );
- if( rc == 0 ) {
+ if (bi->bi_txn) {
+ if( rc == 0 ) {
rc = txn_commit( tid, 0 );
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
e->e_id = NOID;
}
- } else {
+ } 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;
+ }
}
done: