mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 16:49:39 -05:00
Added "dbnotxn" config keyword. If present, back-bdb uses DB_INIT_CDB
(Concurrent Data Store mode) instead of DB_INIT_TXN. Faster, but tends to impede writers.
This commit is contained in:
parent
78066c08c0
commit
323689da57
10 changed files with 93 additions and 57 deletions
|
|
@ -69,15 +69,17 @@ retry: rc = txn_abort( ltid );
|
|||
}
|
||||
|
||||
/* 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;
|
||||
|
|
@ -273,7 +275,8 @@ retry: rc = txn_abort( ltid );
|
|||
goto return_results;
|
||||
}
|
||||
|
||||
rc = txn_commit( ltid, 0 );
|
||||
if( bdb->bi_txn )
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ struct bdb_info {
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ bdb_db_config(
|
|||
}
|
||||
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 ) {
|
||||
|
|
|
|||
|
|
@ -48,16 +48,18 @@ retry: /* transaction retry */
|
|||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
|
@ -281,7 +283,8 @@ retry: /* transaction retry */
|
|||
goto return_results;
|
||||
}
|
||||
|
||||
rc = txn_commit( ltid, 0 );
|
||||
if (bdb->bi_txn)
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ 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 */
|
||||
|
||||
#ifndef NO_THREADS
|
||||
bdb->bi_lock_detect = DB_LOCK_NORUN;
|
||||
|
|
@ -119,8 +120,14 @@ bdb_db_open( BackendDB *be )
|
|||
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 );
|
||||
|
|
@ -257,6 +264,7 @@ bdb_db_close( BackendDB *be )
|
|||
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,
|
||||
|
|
@ -264,6 +272,7 @@ bdb_db_close( BackendDB *be )
|
|||
db_strerror(rc), rc, 0 );
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
while( bdb->bi_ndatabases-- ) {
|
||||
rc = bdb->bi_databases[bdb->bi_ndatabases]->bdi_db->close(
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ bdb_modify(
|
|||
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 );
|
||||
|
|
@ -187,16 +187,18 @@ retry: /* transaction retry */
|
|||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
|
@ -300,7 +302,8 @@ retry: /* transaction retry */
|
|||
goto return_results;
|
||||
}
|
||||
|
||||
rc = txn_commit( ltid, 0 );
|
||||
if (bdb->bi_txn)
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -82,16 +82,18 @@ retry: /* transaction retry */
|
|||
}
|
||||
|
||||
|
||||
/* 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;
|
||||
|
|
@ -606,7 +608,8 @@ retry: /* transaction retry */
|
|||
goto return_results;
|
||||
}
|
||||
|
||||
rc = txn_commit( ltid, 0 );
|
||||
if (bdb->bi_txn)
|
||||
rc = txn_commit( ltid, 0 );
|
||||
ltid = NULL;
|
||||
op->o_private = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *out )
|
|||
ID kid = NOID;
|
||||
ID id;
|
||||
DBT key, data;
|
||||
DB_TXN *ltid;
|
||||
DB_TXN *ltid = NULL;
|
||||
|
||||
DBTzero( &key );
|
||||
key.data = (char *) &kid;
|
||||
|
|
@ -48,12 +48,14 @@ retry: if( tid != NULL ) {
|
|||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
|
|
@ -105,7 +107,11 @@ retry: if( tid != NULL ) {
|
|||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -97,16 +97,18 @@ retry: /* transaction retry */
|
|||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
|
@ -195,14 +197,12 @@ retry: /* transaction retry */
|
|||
}
|
||||
*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 ) {
|
||||
|
|
|
|||
|
|
@ -18,18 +18,6 @@ static DBT key, data;
|
|||
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 );
|
||||
|
|
@ -68,10 +56,19 @@ ID bdb_tool_entry_next(
|
|||
{
|
||||
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 );
|
||||
|
||||
|
|
@ -114,7 +111,7 @@ ID bdb_tool_entry_put(
|
|||
{
|
||||
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 );
|
||||
|
|
@ -122,12 +119,14 @@ ID bdb_tool_entry_put(
|
|||
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 );
|
||||
|
|
@ -165,7 +164,8 @@ ID bdb_tool_entry_put(
|
|||
}
|
||||
|
||||
done:
|
||||
if( rc == 0 ) {
|
||||
if( bdb->bi_txn ) {
|
||||
if( rc == 0 ) {
|
||||
rc = txn_commit( tid, 0 );
|
||||
if( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
|
|
@ -174,12 +174,13 @@ done:
|
|||
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;
|
||||
|
|
@ -206,12 +207,14 @@ int bdb_tool_entry_reindex(
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -226,7 +229,8 @@ int bdb_tool_entry_reindex(
|
|||
|
||||
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,
|
||||
|
|
@ -235,12 +239,13 @@ int bdb_tool_entry_reindex(
|
|||
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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue