diff --git a/src/ydb_db.c b/src/ydb_db.c index 7f3801f1d5b..4c3d9da6104 100644 --- a/src/ydb_db.c +++ b/src/ydb_db.c @@ -649,20 +649,20 @@ int autotxn_db_get(DB* db, DB_TXN* txn, DBT* key, DBT* data, u_int32_t flags) { BOOL changed; int r; // ydb lock is NOT held here - r = toku_db_construct_autotxn(db, &txn, &changed, FALSE, FALSE); + r = toku_db_construct_autotxn(db, &txn, &changed, FALSE); if (r!=0) return r; r = toku_db_get(db, txn, key, data, flags); - return toku_db_destruct_autotxn(txn, r, changed, FALSE); + return toku_db_destruct_autotxn(txn, r, changed); } static inline int autotxn_db_getf_set (DB *db, DB_TXN *txn, u_int32_t flags, DBT *key, YDB_CALLBACK_FUNCTION f, void *extra) { BOOL changed; int r; // ydb lock is NOT held here - r = toku_db_construct_autotxn(db, &txn, &changed, FALSE, FALSE); + r = toku_db_construct_autotxn(db, &txn, &changed, FALSE); if (r!=0) return r; r = db_getf_set(db, txn, flags, key, f, extra); - return toku_db_destruct_autotxn(txn, r, changed, FALSE); + return toku_db_destruct_autotxn(txn, r, changed); } static int diff --git a/src/ydb_db.h b/src/ydb_db.h index 5f8f65c64c8..1a3b62b5187 100644 --- a/src/ydb_db.h +++ b/src/ydb_db.h @@ -51,7 +51,7 @@ int autotxn_db_get(DB* db, DB_TXN* txn, DBT* key, DBT* data, u_int32_t flags); //TODO: Nowait only conditionally? //TODO: NOSYNC change to SYNC if DB_ENV has something in set_flags static inline int -toku_db_construct_autotxn(DB* db, DB_TXN **txn, BOOL* changed, BOOL force_auto_commit, BOOL holds_ydb_lock) { +toku_db_construct_autotxn(DB* db, DB_TXN **txn, BOOL* changed, BOOL force_auto_commit) { assert(db && txn && changed); DB_ENV* env = db->dbenv; if (*txn || !(env->i->open_flags & DB_INIT_TXN)) { @@ -60,23 +60,23 @@ toku_db_construct_autotxn(DB* db, DB_TXN **txn, BOOL* changed, BOOL force_auto_c } BOOL nosync = (BOOL)(!force_auto_commit && !(env->i->open_flags & DB_AUTO_COMMIT)); u_int32_t txn_flags = DB_TXN_NOWAIT | (nosync ? DB_TXN_NOSYNC : 0); - int r = toku_txn_begin(env, NULL, txn, txn_flags, 1, holds_ydb_lock); + int r = toku_txn_begin(env, NULL, txn, txn_flags, 1, FALSE); if (r!=0) return r; *changed = TRUE; return 0; } static inline int -toku_db_destruct_autotxn(DB_TXN *txn, int r, BOOL changed, BOOL holds_ydb_lock) { +toku_db_destruct_autotxn(DB_TXN *txn, int r, BOOL changed) { if (!changed) return r; - if (!holds_ydb_lock) toku_ydb_lock(); + toku_ydb_lock(); if (r==0) { r = toku_txn_commit(txn, 0, NULL, NULL, false); } else { toku_txn_abort(txn, NULL, NULL, false); } - if (!holds_ydb_lock) toku_ydb_unlock(); + toku_ydb_unlock(); return r; } diff --git a/src/ydb_write.c b/src/ydb_write.c index f277c8b9058..7c38cc6ded7 100644 --- a/src/ydb_write.c +++ b/src/ydb_write.c @@ -764,10 +764,10 @@ cleanup: int autotxn_db_del(DB* db, DB_TXN* txn, DBT* key, u_int32_t flags) { BOOL changed; int r; - r = toku_db_construct_autotxn(db, &txn, &changed, FALSE, FALSE); + r = toku_db_construct_autotxn(db, &txn, &changed, FALSE); if (r!=0) return r; r = toku_db_del(db, txn, key, flags, FALSE); - return toku_db_destruct_autotxn(txn, r, changed, FALSE); + return toku_db_destruct_autotxn(txn, r, changed); } int @@ -776,12 +776,12 @@ autotxn_db_put(DB* db, DB_TXN* txn, DBT* key, DBT* data, u_int32_t flags) { BOOL changed; int r; r = env_check_avail_fs_space(db->dbenv); if (r != 0) { goto cleanup; } - r = toku_db_construct_autotxn(db, &txn, &changed, FALSE, FALSE); + r = toku_db_construct_autotxn(db, &txn, &changed, FALSE); if (r!=0) { goto cleanup; } r = toku_db_put(db, txn, key, data, flags, FALSE); - r = toku_db_destruct_autotxn(txn, r, changed, FALSE); + r = toku_db_destruct_autotxn(txn, r, changed); cleanup: return r; } @@ -794,10 +794,10 @@ autotxn_db_update(DB *db, DB_TXN *txn, BOOL changed; int r; r = env_check_avail_fs_space(db->dbenv); if (r != 0) { goto cleanup; } - r = toku_db_construct_autotxn(db, &txn, &changed, FALSE, FALSE); + r = toku_db_construct_autotxn(db, &txn, &changed, FALSE); if (r != 0) { return r; } r = toku_db_update(db, txn, key, update_function_extra, flags); - r = toku_db_destruct_autotxn(txn, r, changed, FALSE); + r = toku_db_destruct_autotxn(txn, r, changed); cleanup: return r; } @@ -809,10 +809,10 @@ autotxn_db_update_broadcast(DB *db, DB_TXN *txn, BOOL changed; int r; r = env_check_avail_fs_space(db->dbenv); if (r != 0) { goto cleanup; } - r = toku_db_construct_autotxn(db, &txn, &changed, FALSE, FALSE); + r = toku_db_construct_autotxn(db, &txn, &changed, FALSE); if (r != 0) { return r; } r = toku_db_update_broadcast(db, txn, update_function_extra, flags); - r = toku_db_destruct_autotxn(txn, r, changed, FALSE); + r = toku_db_destruct_autotxn(txn, r, changed); cleanup: return r; }