]> git.sur5r.net Git - openldap/commitdiff
Delete CDB (no transactions) support
authorKurt Zeilenga <kurt@openldap.org>
Mon, 28 Jan 2002 22:57:50 +0000 (22:57 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 28 Jan 2002 22:57:50 +0000 (22:57 +0000)
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/config.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-bdb/passwd.c
servers/slapd/back-bdb/tools.c

index bb621f845b0a1ca6347204ca1e52904bbea5dbd9..6d03e22db0f85e6cfd000bd62aeb9fc8ff231adc 100644 (file)
@@ -77,22 +77,20 @@ retry:      /* transaction retry */
        }
 
        /* begin transaction */
-       if( bdb->bi_txn ) {
-               rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 
-                       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;
-               }
+       rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 
+               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 );
+       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;
 
index 4b26842f127499b68b34504dfc8589e7c3d84a91..08ad730aa2abca31d99e8d215915696767b961e1 100644 (file)
@@ -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;
index 6de743254e60ca3ac8267d97aaaf55358069c699..b1a6d6d5dd19fe5209b8dad57766b86997345bb6 100644 (file)
@@ -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;
index 0c1f352e1d1ab495fad178a6e8c99c79435a7adc..b79cf104df12cc06dd415859fae876fa3f539299 100644 (file)
@@ -58,23 +58,21 @@ retry:      /* transaction retry */
                ldap_pvt_thread_yield();
        }
 
-       if( bdb->bi_txn ) {
-               /* begin transaction */
-               rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 
-                       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, &ltid, 
+               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 );
+       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;
 
index 447eaa5f44df92b95094950a1c050bfe2a814bdf..c61a1618d93f7b03ba1bd60f5e46f9642ec8ab93 100644 (file)
@@ -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);
index 2f48cb40ebf5988463a87e0facc07c9c01704542..44002bf3257574669873477a1b7e93214ac5b8c0 100644 (file)
@@ -215,19 +215,17 @@ retry:    /* transaction retry */
                ldap_pvt_thread_yield();
        }
 
-       if( bdb->bi_txn ) {
-               /* begin transaction */
-               rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 
-                       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, &ltid, 
+               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;
 
index f83fd79e9a69ef67ad2345d05bc396a2b7cc0c56..5e9e4776a486b414166a9d587131c4daae1e60d6 100644 (file)
@@ -92,19 +92,17 @@ retry:      /* transaction retry */
                ldap_pvt_thread_yield();
        }
 
-       if( bdb->bi_txn ) {
-               /* begin transaction */
-               rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 
-                       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, &ltid, 
+               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;
 
index cb9b51aa6225fdb317191575022a38590d39d245..cbad790f1c3833bbf3ac7b33f5a9526c68bc577e 100644 (file)
@@ -102,19 +102,17 @@ retry:    /* transaction retry */
                ldap_pvt_thread_yield();
        }
 
-       if( bdb->bi_txn ) {
-               /* begin transaction */
-               rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 
-                       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, &ltid, 
+               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;
                }
index a1323405e13c51c135eba755cd4781351aa840e5..737a0c8180e5790efcc56e1ea0c69f47dba1738c 100644 (file)
@@ -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;