summaryrefslogtreecommitdiff
path: root/src/session/session_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/session/session_api.c')
-rw-r--r--src/session/session_api.c104
1 files changed, 48 insertions, 56 deletions
diff --git a/src/session/session_api.c b/src/session/session_api.c
index 00c2852649f..377bc0bdc2d 100644
--- a/src/session/session_api.c
+++ b/src/session/session_api.c
@@ -483,8 +483,8 @@ __wt_session_create(
{
WT_DECL_RET;
- WT_WITH_SCHEMA_LOCK(session, ret,
- WT_WITH_TABLE_LOCK(session, ret,
+ WT_WITH_SCHEMA_LOCK(session,
+ WT_WITH_TABLE_LOCK(session,
ret = __wt_schema_create(session, uri, config)));
return (ret);
}
@@ -677,8 +677,8 @@ __session_rebalance(WT_SESSION *wt_session, const char *uri, const char *config)
SESSION_API_CALL(session, rebalance, config, cfg);
/* Block out checkpoints to avoid spurious EBUSY errors. */
- WT_WITH_CHECKPOINT_LOCK(session, ret,
- WT_WITH_SCHEMA_LOCK(session, ret,
+ WT_WITH_CHECKPOINT_LOCK(session,
+ WT_WITH_SCHEMA_LOCK(session,
ret = __wt_schema_worker(session, uri, __wt_bt_rebalance,
NULL, cfg, WT_DHANDLE_EXCLUSIVE | WT_BTREE_REBALANCE)));
@@ -730,9 +730,9 @@ __session_rename(WT_SESSION *wt_session,
WT_ERR(__wt_str_name_check(session, uri));
WT_ERR(__wt_str_name_check(session, newuri));
- WT_WITH_CHECKPOINT_LOCK(session, ret,
- WT_WITH_SCHEMA_LOCK(session, ret,
- WT_WITH_TABLE_LOCK(session, ret,
+ WT_WITH_CHECKPOINT_LOCK(session,
+ WT_WITH_SCHEMA_LOCK(session,
+ WT_WITH_TABLE_LOCK(session,
ret = __wt_schema_rename(session, uri, newuri, cfg))));
err: if (ret != 0)
@@ -791,53 +791,16 @@ err: API_END_RET_NOTFOUND_MAP(session, ret);
}
/*
- * __wt_session_drop --
- * Internal version of WT_SESSION::drop.
- */
-int
-__wt_session_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[])
-{
- WT_DECL_RET;
- WT_CONFIG_ITEM cval;
- bool checkpoint_wait, lock_wait;
-
- WT_RET(__wt_config_gets_def(session, cfg, "checkpoint_wait", 1, &cval));
- checkpoint_wait = cval.val != 0;
- WT_RET(__wt_config_gets_def(session, cfg, "lock_wait", 1, &cval));
- lock_wait = cval.val != 0 || F_ISSET(session, WT_SESSION_LOCK_NO_WAIT);
-
- if (!lock_wait)
- F_SET(session, WT_SESSION_LOCK_NO_WAIT);
-
- /*
- * Take the checkpoint lock if there is a need to prevent the drop
- * operation from failing with EBUSY due to an ongoing checkpoint.
- */
- if (checkpoint_wait)
- WT_WITH_CHECKPOINT_LOCK(session, ret,
- WT_WITH_SCHEMA_LOCK(session, ret,
- WT_WITH_TABLE_LOCK(session, ret,
- ret = __wt_schema_drop(session, uri, cfg))));
- else
- WT_WITH_SCHEMA_LOCK(session, ret,
- WT_WITH_TABLE_LOCK(session, ret,
- ret = __wt_schema_drop(session, uri, cfg)));
-
- if (!lock_wait)
- F_CLR(session, WT_SESSION_LOCK_NO_WAIT);
-
- return (ret);
-}
-
-/*
* __session_drop --
* WT_SESSION->drop method.
*/
static int
__session_drop(WT_SESSION *wt_session, const char *uri, const char *config)
{
+ WT_CONFIG_ITEM cval;
WT_DECL_RET;
WT_SESSION_IMPL *session;
+ bool checkpoint_wait, lock_wait;
session = (WT_SESSION_IMPL *)wt_session;
SESSION_API_CALL(session, drop, config, cfg);
@@ -845,7 +808,36 @@ __session_drop(WT_SESSION *wt_session, const char *uri, const char *config)
/* Disallow objects in the WiredTiger name space. */
WT_ERR(__wt_str_name_check(session, uri));
- ret = __wt_session_drop(session, uri, cfg);
+ WT_ERR(__wt_config_gets_def(session, cfg, "checkpoint_wait", 1, &cval));
+ checkpoint_wait = cval.val != 0;
+ WT_ERR(__wt_config_gets_def(session, cfg, "lock_wait", 1, &cval));
+ lock_wait = cval.val != 0;
+
+ /*
+ * Take the checkpoint lock if there is a need to prevent the drop
+ * operation from failing with EBUSY due to an ongoing checkpoint.
+ */
+ if (checkpoint_wait) {
+ if (lock_wait)
+ WT_WITH_CHECKPOINT_LOCK(session,
+ WT_WITH_SCHEMA_LOCK(session,
+ WT_WITH_TABLE_LOCK(session, ret =
+ __wt_schema_drop(session, uri, cfg))));
+ else
+ WT_WITH_CHECKPOINT_LOCK_NOWAIT(session, ret,
+ WT_WITH_SCHEMA_LOCK_NOWAIT(session, ret,
+ WT_WITH_TABLE_LOCK_NOWAIT(session, ret, ret =
+ __wt_schema_drop(session, uri, cfg))));
+ } else {
+ if (lock_wait)
+ WT_WITH_SCHEMA_LOCK(session,
+ WT_WITH_TABLE_LOCK(session,
+ ret = __wt_schema_drop(session, uri, cfg)));
+ else
+ WT_WITH_SCHEMA_LOCK_NOWAIT(session, ret,
+ WT_WITH_TABLE_LOCK_NOWAIT(session, ret,
+ ret = __wt_schema_drop(session, uri, cfg)));
+ }
err: if (ret != 0)
WT_STAT_CONN_INCR(session, session_table_drop_fail);
@@ -1036,8 +1028,8 @@ __session_salvage(WT_SESSION *wt_session, const char *uri, const char *config)
"configurations");
/* Block out checkpoints to avoid spurious EBUSY errors. */
- WT_WITH_CHECKPOINT_LOCK(session, ret,
- WT_WITH_SCHEMA_LOCK(session, ret,
+ WT_WITH_CHECKPOINT_LOCK(session,
+ WT_WITH_SCHEMA_LOCK(session,
ret = __wt_schema_worker(session, uri, __wt_salvage,
NULL, cfg, WT_DHANDLE_EXCLUSIVE | WT_BTREE_SALVAGE)));
@@ -1237,8 +1229,8 @@ __session_truncate(WT_SESSION *wt_session,
session, uri, start, stop));
else
/* Wait for checkpoints to avoid EBUSY errors. */
- WT_WITH_CHECKPOINT_LOCK(session, ret,
- WT_WITH_SCHEMA_LOCK(session, ret,
+ WT_WITH_CHECKPOINT_LOCK(session,
+ WT_WITH_SCHEMA_LOCK(session,
ret = __wt_schema_truncate(session, uri, cfg)));
} else
WT_ERR(__wt_session_range_truncate(session, uri, start, stop));
@@ -1293,8 +1285,8 @@ __session_upgrade(WT_SESSION *wt_session, const char *uri, const char *config)
SESSION_API_CALL(session, upgrade, config, cfg);
/* Block out checkpoints to avoid spurious EBUSY errors. */
- WT_WITH_CHECKPOINT_LOCK(session, ret,
- WT_WITH_SCHEMA_LOCK(session, ret,
+ WT_WITH_CHECKPOINT_LOCK(session,
+ WT_WITH_SCHEMA_LOCK(session,
ret = __wt_schema_worker(session, uri, __wt_upgrade,
NULL, cfg, WT_DHANDLE_EXCLUSIVE | WT_BTREE_UPGRADE)));
@@ -1342,8 +1334,8 @@ __session_verify(WT_SESSION *wt_session, const char *uri, const char *config)
"configurations");
/* Block out checkpoints to avoid spurious EBUSY errors. */
- WT_WITH_CHECKPOINT_LOCK(session, ret,
- WT_WITH_SCHEMA_LOCK(session, ret,
+ WT_WITH_CHECKPOINT_LOCK(session,
+ WT_WITH_SCHEMA_LOCK(session,
ret = __wt_schema_worker(session, uri, __wt_verify,
NULL, cfg, WT_DHANDLE_EXCLUSIVE | WT_BTREE_VERIFY)));
@@ -1606,7 +1598,7 @@ __session_checkpoint(WT_SESSION *wt_session, const char *config)
WT_ERR_MSG(session, EINVAL,
"Checkpoint not permitted in a transaction");
- ret = __wt_txn_checkpoint(session, cfg);
+ ret = __wt_txn_checkpoint(session, cfg, true);
/*
* Release common session resources (for example, checkpoint may acquire