Commit 0fca2e35 authored by Yoni Fogel's avatar Yoni Fogel

refs #4964 Cleanups during review

Trying to disable syncs during child txns does nothing, also for parents when doing a dbremove
Removed pointers
Cleanup with regards to indentation/style

git-svn-id: file:///svn/toku/tokudb@44988 c7de825b-a66e-492c-adef-691d508d4ae1
parent e58a55df
...@@ -86,7 +86,7 @@ struct __toku_db_env_internal { ...@@ -86,7 +86,7 @@ struct __toku_db_env_internal {
int enospc_redzone_ctr; // number of operations rejected by enospc prevention (red zone) int enospc_redzone_ctr; // number of operations rejected by enospc prevention (red zone)
int fs_poll_time; // Time in seconds between statfs calls int fs_poll_time; // Time in seconds between statfs calls
struct minicron fs_poller; // Poll the file systems struct minicron fs_poller; // Poll the file systems
BOOL fs_poller_is_init; BOOL fs_poller_is_init;
int envdir_lockfd; int envdir_lockfd;
int datadir_lockfd; int datadir_lockfd;
int logdir_lockfd; int logdir_lockfd;
......
...@@ -1173,8 +1173,8 @@ locked_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *db ...@@ -1173,8 +1173,8 @@ locked_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *db
DB_TXN *child_txn = NULL; DB_TXN *child_txn = NULL;
int using_txns = env->i->open_flags & DB_INIT_TXN; int using_txns = env->i->open_flags & DB_INIT_TXN;
if (using_txns) { if (using_txns) {
ret = toku_txn_begin(env, txn, &child_txn, DB_TXN_NOSYNC); ret = toku_txn_begin(env, txn, &child_txn, 0);
invariant_zero(ret); lazy_assert_zero(ret);
} }
// cannot begin a checkpoint // cannot begin a checkpoint
...@@ -1184,11 +1184,11 @@ locked_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *db ...@@ -1184,11 +1184,11 @@ locked_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *db
if (using_txns) { if (using_txns) {
if (r == 0) { // commit if (r == 0) { // commit
ret = locked_txn_commit(child_txn, DB_TXN_NOSYNC); ret = locked_txn_commit(child_txn, 0);
invariant_zero(ret); lazy_assert_zero(ret);
} else { } else {
ret = locked_txn_abort(child_txn); ret = locked_txn_abort(child_txn);
invariant_zero(ret); lazy_assert_zero(ret);
} }
} }
return r; return r;
...@@ -1202,8 +1202,8 @@ locked_env_dbrename(DB_ENV *env, DB_TXN *txn, const char *fname, const char *dbn ...@@ -1202,8 +1202,8 @@ locked_env_dbrename(DB_ENV *env, DB_TXN *txn, const char *fname, const char *dbn
DB_TXN *child_txn = NULL; DB_TXN *child_txn = NULL;
int using_txns = env->i->open_flags & DB_INIT_TXN; int using_txns = env->i->open_flags & DB_INIT_TXN;
if (using_txns) { if (using_txns) {
ret = toku_txn_begin(env, txn, &child_txn, DB_TXN_NOSYNC); ret = toku_txn_begin(env, txn, &child_txn, 0);
invariant_zero(ret); lazy_assert_zero(ret);
} }
// cannot begin a checkpoint // cannot begin a checkpoint
...@@ -1213,11 +1213,11 @@ locked_env_dbrename(DB_ENV *env, DB_TXN *txn, const char *fname, const char *dbn ...@@ -1213,11 +1213,11 @@ locked_env_dbrename(DB_ENV *env, DB_TXN *txn, const char *fname, const char *dbn
if (using_txns) { if (using_txns) {
if (r == 0) { if (r == 0) {
ret = locked_txn_commit(child_txn, DB_TXN_NOSYNC); ret = locked_txn_commit(child_txn, 0);
invariant_zero(ret); lazy_assert_zero(ret);
} else { } else {
ret = locked_txn_abort(child_txn); ret = locked_txn_abort(child_txn);
invariant_zero(ret); lazy_assert_zero(ret);
} }
} }
return r; return r;
...@@ -2438,46 +2438,49 @@ toku_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbna ...@@ -2438,46 +2438,49 @@ toku_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbna
r = toku_db_get(env->i->directory, txn, &dname_dbt, &iname_dbt, DB_SERIALIZABLE); // allocates memory for iname r = toku_db_get(env->i->directory, txn, &dname_dbt, &iname_dbt, DB_SERIALIZABLE); // allocates memory for iname
char *iname = iname_dbt.data; char *iname = iname_dbt.data;
DB *db = NULL; DB *db = NULL;
if (r == DB_NOTFOUND) { if (r != 0) {
r = ENOENT; if (r == DB_NOTFOUND) {
} else if (r == 0) { r = ENOENT;
// remove (dname,iname) from directory
r = toku_db_del(env->i->directory, txn, &dname_dbt, DB_DELETE_ANY, TRUE);
if (r != 0) {
goto exit;
} }
r = toku_db_create(&db, env, 0); goto exit;
assert_zero(r); }
r = db_open_iname(db, txn, iname, 0, 0); // remove (dname,iname) from directory
assert_zero(r); r = toku_db_del(env->i->directory, txn, &dname_dbt, DB_DELETE_ANY, TRUE);
if (txn) { if (r != 0) {
// Now that we have a writelock on dname, verify that there are still no handles open. (to prevent race conditions) goto exit;
if (env_is_db_with_dname_open(env, dname)) { }
r = toku_ydb_do_error(env, EINVAL, "Cannot remove dictionary with an open handle.\n"); r = toku_db_create(&db, env, 0);
goto exit; lazy_assert_zero(r);
} r = db_open_iname(db, txn, iname, 0, 0);
// we know a live db handle does not exist. lazy_assert_zero(r);
// if (txn) {
// use the internally opened db to try and get a table lock // Now that we have a writelock on dname, verify that there are still no handles open. (to prevent race conditions)
// if (env_is_db_with_dname_open(env, dname)) {
// if we can't get it, then some txn needs the ft and we r = toku_ydb_do_error(env, EINVAL, "Cannot remove dictionary with an open handle.\n");
// should return lock not granted. goto exit;
//
// otherwise, we're okay in marking this ft as remove on
// commit. no new handles can open for this dictionary
// because the txn has directory write locks on the dname
if (toku_db_pre_acquire_table_lock(db, txn) != 0) {
r = DB_LOCK_NOTGRANTED;
} else {
// The ft will be unlinked when the txn commits
r = toku_ft_unlink_on_commit(db->i->ft_handle, db_txn_struct_i(txn)->tokutxn);
assert_zero(r);
}
} }
else { // we know a live db handle does not exist.
// unlink the ft without a txn //
toku_ft_unlink(db->i->ft_handle); // use the internally opened db to try and get a table lock
//
// if we can't get it, then some txn needs the ft and we
// should return lock not granted.
//
// otherwise, we're okay in marking this ft as remove on
// commit. no new handles can open for this dictionary
// because the txn has directory write locks on the dname
r = toku_db_pre_acquire_table_lock(db, txn);
if (r != 0) {
r = DB_LOCK_NOTGRANTED;
goto exit;
} }
// The ft will be unlinked when the txn commits
r = toku_ft_unlink_on_commit(db->i->ft_handle, db_txn_struct_i(txn)->tokutxn);
lazy_assert_zero(r);
}
else {
// unlink the ft without a txn
toku_ft_unlink(db->i->ft_handle);
} }
exit: exit:
......
...@@ -74,7 +74,9 @@ ydb_getf_do_nothing(DBT const* UU(key), DBT const* UU(val), void* UU(extra)) { ...@@ -74,7 +74,9 @@ ydb_getf_do_nothing(DBT const* UU(key), DBT const* UU(val), void* UU(extra)) {
static inline int static inline int
env_check_avail_fs_space(DB_ENV *env) { env_check_avail_fs_space(DB_ENV *env) {
int r = env->i->fs_state == FS_RED ? ENOSPC : 0; int r = env->i->fs_state == FS_RED ? ENOSPC : 0;
if (r) env->i->enospc_redzone_ctr++; if (r) {
env->i->enospc_redzone_ctr++;
}
return r; return r;
} }
......
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