本文整理汇总了C++中WT_SESSION::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ WT_SESSION::reset方法的具体用法?C++ WT_SESSION::reset怎么用?C++ WT_SESSION::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_SESSION
的用法示例。
在下文中一共展示了WT_SESSION::reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mmrand
static void *
ops(void *arg)
{
TINFO *tinfo;
WT_CONNECTION *conn;
WT_CURSOR *cursor, *cursor_insert;
WT_SESSION *session;
WT_ITEM key, value;
uint64_t keyno, ckpt_op, reset_op, session_op;
uint32_t op;
uint8_t *keybuf, *valbuf;
u_int np;
int ckpt_available, dir, insert, intxn, notfound, readonly;
char *ckpt_config, ckpt_name[64];
tinfo = arg;
conn = g.wts_conn;
keybuf = valbuf = NULL;
readonly = 0; /* -Wconditional-uninitialized */
/* Initialize the per-thread random number generator. */
__wt_random_init(&tinfo->rnd);
/* Set up the default key and value buffers. */
key_gen_setup(&keybuf);
val_gen_setup(&tinfo->rnd, &valbuf);
/* Set the first operation where we'll create sessions and cursors. */
session_op = 0;
session = NULL;
cursor = cursor_insert = NULL;
/* Set the first operation where we'll perform checkpoint operations. */
ckpt_op = g.c_checkpoints ? mmrand(&tinfo->rnd, 100, 10000) : 0;
ckpt_available = 0;
/* Set the first operation where we'll reset the session. */
reset_op = mmrand(&tinfo->rnd, 100, 10000);
for (intxn = 0; !tinfo->quit; ++tinfo->ops) {
/*
* We can't checkpoint or swap sessions/cursors while in a
* transaction, resolve any running transaction.
*/
if (intxn &&
(tinfo->ops == ckpt_op || tinfo->ops == session_op)) {
testutil_check(
session->commit_transaction(session, NULL));
++tinfo->commit;
intxn = 0;
}
/* Open up a new session and cursors. */
if (tinfo->ops == session_op ||
session == NULL || cursor == NULL) {
if (session != NULL)
testutil_check(session->close(session, NULL));
testutil_check(conn->open_session(conn, NULL,
ops_session_config(&tinfo->rnd), &session));
/*
* 10% of the time, perform some read-only operations
* from a checkpoint.
*
* Skip that if we single-threaded and doing checks
* against a Berkeley DB database, because that won't
* work because the Berkeley DB database records won't
* match the checkpoint. Also skip if we are using
* LSM, because it doesn't support reads from
* checkpoints.
*/
if (!SINGLETHREADED && !DATASOURCE("lsm") &&
ckpt_available && mmrand(&tinfo->rnd, 1, 10) == 1) {
testutil_check(session->open_cursor(session,
g.uri, NULL, ckpt_name, &cursor));
/* Pick the next session/cursor close/open. */
session_op += 250;
/* Checkpoints are read-only. */
readonly = 1;
} else {
/*
* Open two cursors: one for overwriting and one
* for append (if it's a column-store).
*
* The reason is when testing with existing
* records, we don't track if a record was
* deleted or not, which means we must use
* cursor->insert with overwriting configured.
* But, in column-store files where we're
* testing with new, appended records, we don't
* want to have to specify the record number,
* which requires an append configuration.
*/
testutil_check(session->open_cursor(session,
g.uri, NULL, "overwrite", &cursor));
if (g.type == FIX || g.type == VAR)
//.........这里部分代码省略.........
示例2: releaseSession
void WiredTigerSessionCache::releaseSession(WiredTigerSession* session) {
invariant(session);
invariant(session->cursorsOut() == 0);
const int shuttingDown = _shuttingDown.fetchAndAdd(1);
ON_BLOCK_EXIT([this] { _shuttingDown.fetchAndSubtract(1); });
if (shuttingDown & kShuttingDownMask) {
// There is a race condition with clean shutdown, where the storage engine is ripped from
// underneath OperationContexts, which are not "active" (i.e., do not have any locks), but
// are just about to delete the recovery unit. See SERVER-16031 for more information. Since
// shutting down the WT_CONNECTION will close all WT_SESSIONS, we shouldn't also try to
// directly close this session.
session->_session = nullptr; // Prevents calling _session->close() in destructor.
delete session;
return;
}
{
WT_SESSION* ss = session->getSession();
uint64_t range;
// This checks that we are only caching idle sessions and not something which might hold
// locks or otherwise prevent truncation.
invariantWTOK(ss->transaction_pinned_range(ss, &range));
invariant(range == 0);
// Release resources in the session we're about to cache.
// If we are using hybrid caching, then close cursors now and let them
// be cached at the WiredTiger level.
if (kWiredTigerCursorCacheSize.load() < 0) {
session->closeAllCursors("");
}
invariantWTOK(ss->reset(ss));
}
// If the cursor epoch has moved on, close all cursors in the session.
uint64_t cursorEpoch = _cursorEpoch.load();
if (session->_getCursorEpoch() != cursorEpoch)
session->closeCursorsForQueuedDrops(_engine);
bool returnedToCache = false;
uint64_t currentEpoch = _epoch.load();
bool dropQueuedIdentsAtSessionEnd = session->isDropQueuedIdentsAtSessionEndAllowed();
// Reset this session's flag for dropping queued idents to default, before returning it to
// session cache.
session->dropQueuedIdentsAtSessionEndAllowed(true);
if (session->_getEpoch() == currentEpoch) { // check outside of lock to reduce contention
stdx::lock_guard<stdx::mutex> lock(_cacheLock);
if (session->_getEpoch() == _epoch.load()) { // recheck inside the lock for correctness
returnedToCache = true;
_sessions.push_back(session);
}
} else
invariant(session->_getEpoch() < currentEpoch);
if (!returnedToCache)
delete session;
if (dropQueuedIdentsAtSessionEnd && _engine && _engine->haveDropsQueued())
_engine->dropSomeQueuedIdents();
}