summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/session/session_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/session/session_api.c')
-rw-r--r--src/third_party/wiredtiger/src/session/session_api.c169
1 files changed, 98 insertions, 71 deletions
diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c
index 00c2852649f..fe1bf821d3b 100644
--- a/src/third_party/wiredtiger/src/session/session_api.c
+++ b/src/third_party/wiredtiger/src/session/session_api.c
@@ -58,7 +58,6 @@ int
__wt_session_copy_values(WT_SESSION_IMPL *session)
{
WT_CURSOR *cursor;
- WT_DECL_RET;
TAILQ_FOREACH(cursor, &session->cursors, q)
if (F_ISSET(cursor, WT_CURSTD_VALUE_INT)) {
@@ -80,7 +79,7 @@ __wt_session_copy_values(WT_SESSION_IMPL *session)
F_SET(cursor, WT_CURSTD_VALUE_EXT);
}
- return (ret);
+ return (0);
}
/*
@@ -130,9 +129,47 @@ __session_clear(WT_SESSION_IMPL *session)
* For these reasons, be careful when clearing the session structure.
*/
memset(session, 0, WT_SESSION_CLEAR_SIZE(session));
- session->hazard_size = 0;
- session->nhazard = 0;
+
WT_INIT_LSN(&session->bg_sync_lsn);
+
+ session->hazard_inuse = 0;
+ session->nhazard = 0;
+}
+
+/*
+ * __session_alter --
+ * Alter a table setting.
+ */
+static int
+__session_alter(WT_SESSION *wt_session, const char *uri, const char *config)
+{
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ session = (WT_SESSION_IMPL *)wt_session;
+
+ SESSION_API_CALL(session, alter, config, cfg);
+
+ /* Disallow objects in the WiredTiger name space. */
+ WT_ERR(__wt_str_name_check(session, uri));
+
+ /*
+ * We replace the default configuration listing with the current
+ * configuration. Otherwise the defaults for values that can be
+ * altered would override settings used by the user in create.
+ */
+ cfg[0] = cfg[1];
+ cfg[1] = NULL;
+ WT_WITH_CHECKPOINT_LOCK(session,
+ WT_WITH_SCHEMA_LOCK(session,
+ WT_WITH_TABLE_LOCK(session,
+ ret = __wt_schema_alter(session, uri, cfg))));
+
+err: if (ret != 0)
+ WT_STAT_CONN_INCR(session, session_table_alter_fail);
+ else
+ WT_STAT_CONN_INCR(session, session_table_alter_success);
+ API_END_RET_NOTFOUND_MAP(session, ret);
}
/*
@@ -483,8 +520,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 +714,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 +767,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 +828,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 +845,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 +1065,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 +1266,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 +1322,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 +1371,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 +1635,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
@@ -1698,6 +1727,7 @@ __open_session(WT_CONNECTION_IMPL *conn,
static const WT_SESSION stds = {
NULL,
NULL,
+ __session_alter,
__session_close,
__session_reconfigure,
__wt_session_strerror,
@@ -1725,6 +1755,7 @@ __open_session(WT_CONNECTION_IMPL *conn,
}, stds_readonly = {
NULL,
NULL,
+ __session_alter,
__session_close,
__session_reconfigure,
__wt_session_strerror,
@@ -1828,17 +1859,13 @@ __open_session(WT_CONNECTION_IMPL *conn,
* session close because access to it isn't serialized. Allocate the
* first time we open this session.
*/
- if (WT_SESSION_FIRST_USE(session_ret))
- WT_ERR(__wt_calloc_def(
- session, conn->hazard_max, &session_ret->hazard));
-
- /*
- * Set an initial size for the hazard array. It will be grown as
- * required up to hazard_max. The hazard_size is reset on close, since
- * __wt_hazard_close ensures the array is cleared - so it is safe to
- * reset the starting size on each open.
- */
- session_ret->hazard_size = 0;
+ if (WT_SESSION_FIRST_USE(session_ret)) {
+ WT_ERR(__wt_calloc_def(session,
+ WT_SESSION_INITIAL_HAZARD_SLOTS, &session_ret->hazard));
+ session_ret->hazard_size = WT_SESSION_INITIAL_HAZARD_SLOTS;
+ session_ret->hazard_inuse = 0;
+ session_ret->nhazard = 0;
+ }
/* Cache the offset of this session's statistics bucket. */
session_ret->stat_bucket = WT_STATS_SLOT_ID(session);