Commit 6a1288d3 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #2120 refs[t:2120] Internally created child transactions now copy...

Addresses #2120 refs[t:2120] Internally created child transactions now copy parent's isolation level

git-svn-id: file:///svn/toku/tokudb.2037b@15675 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3c49f749
...@@ -357,7 +357,7 @@ static int toku_db_set_dup_compare(DB *db, int (*dup_compare)(DB *, const DBT *, ...@@ -357,7 +357,7 @@ static int toku_db_set_dup_compare(DB *db, int (*dup_compare)(DB *, const DBT *,
static int toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, DBTYPE dbtype, u_int32_t flags, int mode); static int toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, DBTYPE dbtype, u_int32_t flags, int mode);
static int toku_env_txn_checkpoint(DB_ENV * env, u_int32_t kbyte, u_int32_t min, u_int32_t flags); static int toku_env_txn_checkpoint(DB_ENV * env, u_int32_t kbyte, u_int32_t min, u_int32_t flags);
static int toku_db_close(DB * db, u_int32_t flags); static int toku_db_close(DB * db, u_int32_t flags);
static int toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags); static int toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags, int internal);
static int toku_txn_commit(DB_TXN * txn, u_int32_t flags); static int toku_txn_commit(DB_TXN * txn, u_int32_t flags);
static int db_open_iname(DB * db, DB_TXN * txn, const char *iname, u_int32_t flags, int mode); static int db_open_iname(DB * db, DB_TXN * txn, const char *iname, u_int32_t flags, int mode);
...@@ -539,7 +539,7 @@ static int toku_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mo ...@@ -539,7 +539,7 @@ static int toku_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mo
DB_TXN *txn=NULL; DB_TXN *txn=NULL;
if (using_txns) { if (using_txns) {
r = toku_txn_begin(env, 0, &txn, 0); r = toku_txn_begin(env, 0, &txn, 0, 1);
assert(r==0);//For Now assert(r==0);//For Now
} }
//TODO: put environment, directory in environment home instead of in data dir //TODO: put environment, directory in environment home instead of in data dir
...@@ -1520,7 +1520,7 @@ static int toku_txn_abort(DB_TXN * txn) { ...@@ -1520,7 +1520,7 @@ static int toku_txn_abort(DB_TXN * txn) {
} }
static int locked_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags) { static int locked_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags) {
toku_ydb_lock(); int r = toku_txn_begin(env, stxn, txn, flags); toku_ydb_unlock(); return r; toku_ydb_lock(); int r = toku_txn_begin(env, stxn, txn, flags, 0); toku_ydb_unlock(); return r;
} }
static u_int32_t locked_txn_id(DB_TXN *txn) { static u_int32_t locked_txn_id(DB_TXN *txn) {
...@@ -1550,13 +1550,17 @@ static int locked_txn_abort(DB_TXN *txn) { ...@@ -1550,13 +1550,17 @@ static int locked_txn_abort(DB_TXN *txn) {
return r; return r;
} }
static int toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags) { static int toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags, int internal) {
HANDLE_PANICKED_ENV(env); HANDLE_PANICKED_ENV(env);
HANDLE_ILLEGAL_WORKING_PARENT_TXN(env, stxn); //Cannot create child while child already exists. HANDLE_ILLEGAL_WORKING_PARENT_TXN(env, stxn); //Cannot create child while child already exists.
if (!toku_logger_is_open(env->i->logger)) return toku_ydb_do_error(env, EINVAL, "Environment does not have logging enabled\n"); if (!toku_logger_is_open(env->i->logger)) return toku_ydb_do_error(env, EINVAL, "Environment does not have logging enabled\n");
if (!(env->i->open_flags & DB_INIT_TXN)) return toku_ydb_do_error(env, EINVAL, "Environment does not have transactions enabled\n"); if (!(env->i->open_flags & DB_INIT_TXN)) return toku_ydb_do_error(env, EINVAL, "Environment does not have transactions enabled\n");
u_int32_t txn_flags = 0; u_int32_t txn_flags = 0;
txn_flags |= DB_TXN_NOWAIT; //We do not support blocking locks. txn_flags |= DB_TXN_NOWAIT; //We do not support blocking locks.
if (internal && stxn) {
uint32_t parent_isolation_flags = db_txn_struct_i(stxn)->flags & (DB_READ_UNCOMMITTED); //TODO: #2126 DB_READ_COMMITTED should be added here once supported.
flags |= parent_isolation_flags;
}
if (flags&DB_READ_UNCOMMITTED) { if (flags&DB_READ_UNCOMMITTED) {
txn_flags |= DB_READ_UNCOMMITTED; txn_flags |= DB_READ_UNCOMMITTED;
flags &= ~DB_READ_UNCOMMITTED; flags &= ~DB_READ_UNCOMMITTED;
...@@ -3647,7 +3651,7 @@ toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, DBTYP ...@@ -3647,7 +3651,7 @@ toku_db_open(DB * db, DB_TXN * txn, const char *fname, const char *dbname, DBTYP
DB_TXN *child = NULL; DB_TXN *child = NULL;
// begin child (unless transactionless) // begin child (unless transactionless)
if (using_txns) { if (using_txns) {
r = toku_txn_begin(db->dbenv, txn, &child, DB_TXN_NOSYNC); r = toku_txn_begin(db->dbenv, txn, &child, DB_TXN_NOSYNC, 1);
assert(r==0); assert(r==0);
} }
...@@ -3968,7 +3972,7 @@ toku_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbna ...@@ -3968,7 +3972,7 @@ toku_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbna
DB_TXN *child = NULL; DB_TXN *child = NULL;
// begin child (unless transactionless) // begin child (unless transactionless)
if (using_txns) { if (using_txns) {
r = toku_txn_begin(env, txn, &child, DB_TXN_NOSYNC); r = toku_txn_begin(env, txn, &child, DB_TXN_NOSYNC, 1);
assert(r==0); assert(r==0);
} }
...@@ -4081,7 +4085,7 @@ toku_env_dbrename(DB_ENV *env, DB_TXN *txn, const char *fname, const char *dbnam ...@@ -4081,7 +4085,7 @@ toku_env_dbrename(DB_ENV *env, DB_TXN *txn, const char *fname, const char *dbnam
DB_TXN *child = NULL; DB_TXN *child = NULL;
// begin child (unless transactionless) // begin child (unless transactionless)
if (using_txns) { if (using_txns) {
r = toku_txn_begin(env, txn, &child, DB_TXN_NOSYNC); r = toku_txn_begin(env, txn, &child, DB_TXN_NOSYNC, 1);
assert(r==0); assert(r==0);
} }
...@@ -4315,7 +4319,7 @@ static inline int toku_db_construct_autotxn(DB* db, DB_TXN **txn, BOOL* changed, ...@@ -4315,7 +4319,7 @@ static inline int toku_db_construct_autotxn(DB* db, DB_TXN **txn, BOOL* changed,
} }
BOOL nosync = (BOOL)(!force_auto_commit && !(env->i->open_flags & DB_AUTO_COMMIT)); 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); u_int32_t txn_flags = DB_TXN_NOWAIT | (nosync ? DB_TXN_NOSYNC : 0);
int r = toku_txn_begin(env, NULL, txn, txn_flags); int r = toku_txn_begin(env, NULL, txn, txn_flags, 1);
if (r!=0) return r; if (r!=0) return r;
*changed = TRUE; *changed = TRUE;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment