summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <mjc@wiredtiger.com>2014-08-01 14:54:23 +1000
committerMichael Cahill <mjc@wiredtiger.com>2014-08-01 14:54:23 +1000
commite9bba7b3fc4cf5376cc6f84006fc612701c00352 (patch)
tree773774c8488191813774a50121afabd2cbd95a38
parente74d149335e13d1ccdff42258da6ea8c0f85899e (diff)
parentfdf1dfa55f0273c1df2361b480cdca9886046f52 (diff)
downloadmongo-e9bba7b3fc4cf5376cc6f84006fc612701c00352.tar.gz
Merge pull request #1141 from wiredtiger/acquire-metadata-at-session-create
Cache metadata reference when creating internal sessions.
-rw-r--r--dist/flags.py1
-rw-r--r--src/async/async_api.c14
-rw-r--r--src/btree/bt_evict.c7
-rw-r--r--src/conn/conn_api.c5
-rw-r--r--src/conn/conn_cache_pool.c3
-rw-r--r--src/conn/conn_ckpt.c4
-rw-r--r--src/conn/conn_dhandle.c13
-rw-r--r--src/conn/conn_log.c5
-rw-r--r--src/conn/conn_open.c6
-rw-r--r--src/conn/conn_stat.c4
-rw-r--r--src/conn/conn_sweep.c4
-rw-r--r--src/include/connection.h4
-rw-r--r--src/include/extern.h9
-rw-r--r--src/include/flags.h9
-rw-r--r--src/lsm/lsm_tree.c25
-rw-r--r--src/session/session_api.c73
-rw-r--r--src/session/session_dhandle.c63
-rw-r--r--src/txn/txn_recover.c2
18 files changed, 148 insertions, 103 deletions
diff --git a/dist/flags.py b/dist/flags.py
index 3a99022a571..0242173a851 100644
--- a/dist/flags.py
+++ b/dist/flags.py
@@ -101,6 +101,7 @@ flags = {
'SESSION_LOGGING_INMEM',
'SESSION_NO_CACHE',
'SESSION_NO_CACHE_CHECK',
+ 'SESSION_NO_DATA_HANDLES',
'SESSION_NO_LOGGING',
'SESSION_NO_SCHEMA_LOCK',
'SESSION_SALVAGE_CORRUPT_OK',
diff --git a/src/async/async_api.c b/src/async/async_api.c
index b6d6f121bf5..6e425515bf2 100644
--- a/src/async/async_api.c
+++ b/src/async/async_api.c
@@ -51,8 +51,8 @@ __async_get_format(WT_CONNECTION_IMPL *conn, const char *uri,
* Insert it at the head expecting LRU usage. We need a real session
* for the cursor.
*/
- session = NULL;
- WT_RET(__wt_open_session(conn, 1, NULL, NULL, &session));
+ WT_RET(
+ __wt_open_internal_session(conn, "async-cursor", 1, 1, &session));
__wt_spin_lock(session, &async->ops_lock);
WT_ERR(__wt_calloc_def(session, 1, &af));
WT_ERR(__wt_strdup(session, uri, &af->uri));
@@ -268,9 +268,8 @@ __wt_async_create(WT_CONNECTION_IMPL *conn, const char *cfg[])
* workers and we may want to selectively stop some workers
* while leaving the rest running.
*/
- WT_RET(__wt_open_session(
- conn, 1, NULL, NULL, &async->worker_sessions[i]));
- async->worker_sessions[i]->name = "async-worker";
+ WT_RET(__wt_open_internal_session(
+ conn, "async-worker", 1, 1, &async->worker_sessions[i]));
F_SET(async->worker_sessions[i], WT_SESSION_SERVER_ASYNC);
}
for (i = 0; i < conn->async_workers; i++) {
@@ -363,9 +362,8 @@ __wt_async_reconfig(WT_CONNECTION_IMPL *conn, const char *cfg[])
/*
* Each worker has its own session.
*/
- WT_RET(__wt_open_session(
- conn, 1, NULL, NULL, &async->worker_sessions[i]));
- async->worker_sessions[i]->name = "async-worker";
+ WT_RET(__wt_open_internal_session(conn,
+ "async-worker", 1, 1, &async->worker_sessions[i]));
F_SET(async->worker_sessions[i],
WT_SESSION_SERVER_ASYNC);
}
diff --git a/src/btree/bt_evict.c b/src/btree/bt_evict.c
index 7f51d586c45..1637b447c9a 100644
--- a/src/btree/bt_evict.c
+++ b/src/btree/bt_evict.c
@@ -238,9 +238,9 @@ __wt_evict_create(WT_CONNECTION_IMPL *conn)
/* Set first, the thread might run before we finish up. */
F_SET(conn, WT_CONN_EVICTION_RUN);
- WT_RET(__wt_open_session(conn, 1, NULL, NULL, &session));
+ WT_RET(__wt_open_internal_session(
+ conn, "eviction-server", 0, 0, &session));
conn->evict_session = session;
- conn->evict_session->name = "eviction-server";
WT_RET(__wt_thread_create(
session, &conn->evict_tid, __evict_server, conn->evict_session));
@@ -301,7 +301,8 @@ __evict_worker(void *arg)
* Start with the default session to keep error handling simple.
*/
session = conn->default_session;
- WT_ERR(__wt_open_session(conn, 1, NULL, NULL, &session));
+ WT_ERR(__wt_open_internal_session(
+ conn, "eviction-worker", 0, 0, &session));
while (F_ISSET(conn, WT_CONN_EVICTION_RUN)) {
/* Don't spin in a busy loop if there is no work to do */
diff --git a/src/conn/conn_api.c b/src/conn/conn_api.c
index 7a5cc01153f..e9d641ecf3f 100644
--- a/src/conn/conn_api.c
+++ b/src/conn/conn_api.c
@@ -665,7 +665,7 @@ __conn_open_session(WT_CONNECTION *wt_conn,
CONNECTION_API_CALL(conn, session, open_session, config, cfg);
WT_UNUSED(cfg);
- WT_ERR(__wt_open_session(conn, 0, event_handler, config, &session_ret));
+ WT_ERR(__wt_open_session(conn, event_handler, config, &session_ret));
*wt_sessionp = &session_ret->iface;
@@ -1354,7 +1354,8 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
/*
* Check on the turtle and metadata files, creating them if necessary
* (which avoids application threads racing to create the metadata file
- * later).
+ * later). Once the metadata file exists, get a reference to it in
+ * the connection's session.
*/
WT_ERR(__wt_turtle_init(session));
WT_ERR(__wt_metadata_open(session));
diff --git a/src/conn/conn_cache_pool.c b/src/conn/conn_cache_pool.c
index 598c75cdcd8..1c0f8225ef7 100644
--- a/src/conn/conn_cache_pool.c
+++ b/src/conn/conn_cache_pool.c
@@ -351,7 +351,8 @@ __cache_pool_balance(void)
* has closed. If it's NULL create a new one.
*/
if (cp->session == NULL &&
- (ret = __wt_open_session(entry, 1, NULL, NULL, &cp->session)) != 0)
+ (ret = __wt_open_internal_session(
+ entry, "cache-pool", 0, 0, &cp->session)) != 0)
WT_ERR_MSG(NULL, ret,
"Failed to create session for cache pool");
diff --git a/src/conn/conn_ckpt.c b/src/conn/conn_ckpt.c
index a466afc5a71..88b606bf991 100644
--- a/src/conn/conn_ckpt.c
+++ b/src/conn/conn_ckpt.c
@@ -99,8 +99,8 @@ __ckpt_server_start(WT_CONNECTION_IMPL *conn)
F_SET(conn, WT_CONN_SERVER_CHECKPOINT);
/* The checkpoint server gets its own session. */
- WT_RET(__wt_open_session(conn, 1, NULL, NULL, &conn->ckpt_session));
- conn->ckpt_session->name = "checkpoint-server";
+ WT_RET(__wt_open_internal_session(
+ conn, "checkpoint-server", 1, 1, &conn->ckpt_session));
WT_RET(
__wt_cond_alloc(session, "checkpoint server", 0, &conn->ckpt_cond));
diff --git a/src/conn/conn_dhandle.c b/src/conn/conn_dhandle.c
index 3cee7482733..6906e002abb 100644
--- a/src/conn/conn_dhandle.c
+++ b/src/conn/conn_dhandle.c
@@ -643,7 +643,6 @@ int
__wt_conn_dhandle_discard(WT_CONNECTION_IMPL *conn)
{
WT_DATA_HANDLE *dhandle;
- WT_DATA_HANDLE_CACHE *dhandle_cache;
WT_DECL_RET;
WT_SESSION_IMPL *session;
@@ -666,13 +665,13 @@ restart:
}
/*
- * Closing the files may have resulted in entries on our session's list
- * of open data handles, specifically, we added the metadata file if
- * any of the files were dirty. Clean up that list before we shut down
- * the metadata entry, for good.
+ * Closing the files may have resulted in entries on our default
+ * session's list of open data handles, specifically, we added the
+ * metadata file if any of the files were dirty. Clean up that list
+ * before we shut down the metadata entry, for good.
*/
- while ((dhandle_cache = SLIST_FIRST(&session->dhandles)) != NULL)
- __wt_session_discard_btree(session, dhandle_cache);
+ __wt_session_close_cache(session);
+ F_SET(session, WT_SESSION_NO_DATA_HANDLES);
/* Close the metadata file handle. */
while ((dhandle = SLIST_FIRST(&conn->dhlh)) != NULL)
diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c
index a9085f15029..bac2ed93512 100644
--- a/src/conn/conn_log.c
+++ b/src/conn/conn_log.c
@@ -216,9 +216,8 @@ __wt_logmgr_create(WT_CONNECTION_IMPL *conn, const char *cfg[])
WT_RET(__wt_cond_signal(session, conn->arch_cond));
} else {
/* The log archive server gets its own session. */
- WT_RET(__wt_open_session(
- conn, 1, NULL, NULL, &conn->arch_session));
- conn->arch_session->name = "archive-server";
+ WT_RET(__wt_open_internal_session(
+ conn, "archive-server", 0, 0, &conn->arch_session));
WT_RET(__wt_cond_alloc(
session, "log archiving server", 0, &conn->arch_cond));
diff --git a/src/conn/conn_open.c b/src/conn/conn_open.c
index 78a4dcdfdb3..4bc642acfce 100644
--- a/src/conn/conn_open.c
+++ b/src/conn/conn_open.c
@@ -41,7 +41,7 @@ __wt_connection_open(WT_CONNECTION_IMPL *conn, const char *cfg[])
* threads because those may allocate and use session resources that
* need to get cleaned up on close.
*/
- WT_RET(__wt_open_session(conn, 1, NULL, NULL, &session));
+ WT_RET(__wt_open_internal_session(conn, "connection", 1, 0, &session));
conn->default_session = session;
return (0);
@@ -115,8 +115,8 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn)
WT_TRET(__wt_conn_remove_data_source(conn, ndsrc));
/*
- * Complain if files weren't closed, ignoring the lock and logging
- * files, we'll close them in a minute.
+ * Complain if files weren't closed, ignoring the lock file, we'll
+ * close it in a minute.
*/
TAILQ_FOREACH(fh, &conn->fhqh, q) {
if (fh == conn->lock_fh)
diff --git a/src/conn/conn_stat.c b/src/conn/conn_stat.c
index ae6a2f1dd20..21e251c8cd3 100644
--- a/src/conn/conn_stat.c
+++ b/src/conn/conn_stat.c
@@ -407,8 +407,8 @@ __statlog_start(WT_CONNECTION_IMPL *conn)
F_SET(conn, WT_CONN_SERVER_STATISTICS);
/* The statistics log server gets its own session. */
- WT_RET(__wt_open_session(conn, 1, NULL, NULL, &conn->stat_session));
- conn->stat_session->name = "statlog-server";
+ WT_RET(__wt_open_internal_session(
+ conn, "statlog-server", 1, 1, &conn->stat_session));
session = conn->stat_session;
diff --git a/src/conn/conn_sweep.c b/src/conn/conn_sweep.c
index a4621e38d03..ee6a932401e 100644
--- a/src/conn/conn_sweep.c
+++ b/src/conn/conn_sweep.c
@@ -134,9 +134,9 @@ __wt_sweep_create(WT_CONNECTION_IMPL *conn)
/* Set first, the thread might run before we finish up. */
F_SET(conn, WT_CONN_SERVER_SWEEP);
- WT_RET(__wt_open_session(conn, 1, NULL, NULL, &session));
+ WT_RET(
+ __wt_open_internal_session(conn, "sweep-server", 1, 1, &session));
conn->sweep_session = session;
- conn->sweep_session->name = "sweep-server";
WT_RET(__wt_cond_alloc(
session, "handle sweep server", 0, &conn->sweep_cond));
diff --git a/src/include/connection.h b/src/include/connection.h
index 76b13ccccd7..18a825111c8 100644
--- a/src/include/connection.h
+++ b/src/include/connection.h
@@ -55,9 +55,9 @@ struct __wt_named_data_source {
/*
* Allocate some additional slots for internal sessions. There is a default
- * session for each connection, plus a session for the eviction thread.
+ * session for each connection, plus a session for each server thread.
*/
-#define WT_NUM_INTERNAL_SESSIONS 2
+#define WT_NUM_INTERNAL_SESSIONS 10
/*
* WT_CONNECTION_IMPL --
diff --git a/src/include/extern.h b/src/include/extern.h
index d9dd3050ffe..309e7bcdbb0 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -1363,8 +1363,12 @@ extern int __wt_session_create_strip(WT_SESSION *wt_session,
const char *v1,
const char *v2,
const char **value_ret);
+extern int __wt_open_internal_session(WT_CONNECTION_IMPL *conn,
+ const char *name,
+ int uses_dhandles,
+ int open_metadata,
+ WT_SESSION_IMPL **sessionp);
extern int __wt_open_session(WT_CONNECTION_IMPL *conn,
- int internal,
WT_EVENT_HANDLER *event_handler,
const char *config,
WT_SESSION_IMPL **sessionp);
@@ -1382,6 +1386,7 @@ extern int __wt_session_get_btree_ckpt(WT_SESSION_IMPL *session,
const char *uri,
const char *cfg[],
uint32_t flags);
+extern void __wt_session_close_cache(WT_SESSION_IMPL *session);
extern int __wt_session_get_btree(WT_SESSION_IMPL *session,
const char *uri,
const char *checkpoint,
@@ -1389,8 +1394,6 @@ extern int __wt_session_get_btree(WT_SESSION_IMPL *session,
uint32_t flags);
extern int __wt_session_lock_checkpoint(WT_SESSION_IMPL *session,
const char *checkpoint);
-extern void __wt_session_discard_btree( WT_SESSION_IMPL *session,
- WT_DATA_HANDLE_CACHE *dhandle_cache);
extern int __wt_salvage(WT_SESSION_IMPL *session, const char *cfg[]);
extern uint32_t __wt_cksum(const void *chunk, size_t len);
extern void __wt_cksum_init(void);
diff --git a/src/include/flags.h b/src/include/flags.h
index 80f2a1079e9..52a9d262f29 100644
--- a/src/include/flags.h
+++ b/src/include/flags.h
@@ -35,10 +35,11 @@
#define WT_READ_SKIP_LEAF 0x00000004
#define WT_READ_TRUNCATE 0x00000002
#define WT_READ_WONT_NEED 0x00000001
-#define WT_SESSION_INTERNAL 0x00000100
-#define WT_SESSION_LOGGING_INMEM 0x00000080
-#define WT_SESSION_NO_CACHE 0x00000040
-#define WT_SESSION_NO_CACHE_CHECK 0x00000020
+#define WT_SESSION_INTERNAL 0x00000200
+#define WT_SESSION_LOGGING_INMEM 0x00000100
+#define WT_SESSION_NO_CACHE 0x00000080
+#define WT_SESSION_NO_CACHE_CHECK 0x00000040
+#define WT_SESSION_NO_DATA_HANDLES 0x00000020
#define WT_SESSION_NO_LOGGING 0x00000010
#define WT_SESSION_NO_SCHEMA_LOCK 0x00000008
#define WT_SESSION_SALVAGE_CORRUPT_OK 0x00000004
diff --git a/src/lsm/lsm_tree.c b/src/lsm/lsm_tree.c
index 3d5de2185ae..72398d21183 100644
--- a/src/lsm/lsm_tree.c
+++ b/src/lsm/lsm_tree.c
@@ -264,34 +264,35 @@ __wt_lsm_tree_setup_chunk(
static int
__lsm_tree_start_worker(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
{
- WT_CONNECTION *wt_conn;
+ WT_CONNECTION_IMPL *conn;
WT_LSM_WORKER_ARGS *wargs;
- WT_SESSION *wt_session;
WT_SESSION_IMPL *s;
uint32_t i;
- wt_conn = &S2C(session)->iface;
+ conn = S2C(session);
/*
+ * Open internal sessions for LSM worker threads: they will be managed
+ * along with the LSM tree structure, not with application sessions.
+ * We can't open the metadata here: our session may hold the schema
+ * lock, which would block the new session from open the handle.
+ *
* All the LSM worker threads do their operations on read-only files.
* Use read-uncommitted isolation to avoid keeping updates in cache
* unnecessarily.
*/
- WT_RET(wt_conn->open_session(
- wt_conn, NULL, "isolation=read-uncommitted", &wt_session));
- lsm_tree->ckpt_session = (WT_SESSION_IMPL *)wt_session;
- F_SET(lsm_tree->ckpt_session, WT_SESSION_INTERNAL);
+ WT_RET(__wt_open_internal_session(
+ conn, "lsm-worker", 1, 0, &lsm_tree->ckpt_session));
+ lsm_tree->ckpt_session->isolation = TXN_ISO_READ_UNCOMMITTED;
F_SET(lsm_tree, WT_LSM_TREE_WORKING);
/* The new thread will rely on the WORKING value being visible. */
WT_FULL_BARRIER();
if (F_ISSET(S2C(session), WT_CONN_LSM_MERGE))
for (i = 0; i < lsm_tree->merge_threads; i++) {
- WT_RET(wt_conn->open_session(
- wt_conn, NULL, "isolation=read-uncommitted",
- &wt_session));
- s = (WT_SESSION_IMPL *)wt_session;
- F_SET(s, WT_SESSION_INTERNAL);
+ WT_RET(__wt_open_internal_session(
+ conn, "lsm-merge", 1, 0, &s));
+ s->isolation = TXN_ISO_READ_UNCOMMITTED;
lsm_tree->worker_sessions[i] = s;
WT_RET(__wt_calloc_def(session, 1, &wargs));
diff --git a/src/session/session_api.c b/src/session/session_api.c
index 1a24d6b3b76..b7e66dd54df 100644
--- a/src/session/session_api.c
+++ b/src/session/session_api.c
@@ -26,19 +26,6 @@ __wt_session_reset_cursors(WT_SESSION_IMPL *session)
}
/*
- * __session_close_cache --
- * Close any cached handles in a session. Called holding the schema lock.
- */
-static void
-__session_close_cache(WT_SESSION_IMPL *session)
-{
- WT_DATA_HANDLE_CACHE *dhandle_cache;
-
- while ((dhandle_cache = SLIST_FIRST(&session->dhandles)) != NULL)
- __wt_session_discard_btree(session, dhandle_cache);
-}
-
-/*
* __session_clear --
* Clear a session structure.
*/
@@ -99,7 +86,7 @@ __session_close(WT_SESSION *wt_session, const char *config)
WT_ASSERT(session, session->ncursors == 0);
/* Discard cached handles. */
- __session_close_cache(session);
+ __wt_session_close_cache(session);
/* Close all tables. */
__wt_schema_close_tables(session);
@@ -748,12 +735,59 @@ err: F_CLR(session, WT_SESSION_NO_CACHE_CHECK);
}
/*
+ * __wt_open_internal_session --
+ * Allocate a session for WiredTiger's use.
+ */
+int
+__wt_open_internal_session(WT_CONNECTION_IMPL *conn, const char *name,
+ int uses_dhandles, int open_metadata, WT_SESSION_IMPL **sessionp)
+{
+ WT_SESSION_IMPL *session;
+
+ *sessionp = NULL;
+
+ WT_RET(__wt_open_session(conn, NULL, NULL, &session));
+ session->name = name;
+
+ /*
+ * Public sessions are automatically closed during WT_CONNECTION->close.
+ * If the session handles for internal threads were to go on the public
+ * list, there would be complex ordering issues during close. Set a
+ * flag to avoid this: internal sessions are not closed automatically.
+ */
+ F_SET(session, WT_SESSION_INTERNAL);
+
+ /*
+ * Some internal threads must keep running after we close all data
+ * handles. Make sure these threads don't open their own handles.
+ */
+ if (!uses_dhandles)
+ F_SET(session, WT_SESSION_NO_DATA_HANDLES);
+
+ /*
+ * Acquiring the metadata handle requires the schema lock; we've seen
+ * problems in the past where a worker thread has acquired the schema
+ * lock unexpectedly, relatively late in the run, and deadlocked. Be
+ * defensive, get it now. The metadata file may not exist when the
+ * connection first creates its default session or the shared cache
+ * pool creates its sessions, let our caller decline this work.
+ */
+ if (open_metadata) {
+ WT_ASSERT(session, !F_ISSET(session, WT_SESSION_SCHEMA_LOCKED));
+ WT_RET(__wt_metadata_open(session));
+ }
+
+ *sessionp = session;
+ return (0);
+}
+
+/*
* __wt_open_session --
* Allocate a session handle. The internal parameter is used for sessions
* opened by WiredTiger for its own use.
*/
int
-__wt_open_session(WT_CONNECTION_IMPL *conn, int internal,
+__wt_open_session(WT_CONNECTION_IMPL *conn,
WT_EVENT_HANDLER *event_handler, const char *config,
WT_SESSION_IMPL **sessionp)
{
@@ -839,15 +873,6 @@ __wt_open_session(WT_CONNECTION_IMPL *conn, int internal,
session_ret->hazard_size = WT_HAZARD_INCR;
/*
- * Public sessions are automatically closed during WT_CONNECTION->close.
- * If the session handles for internal threads were to go on the public
- * list, there would be complex ordering issues during close. Set a
- * flag to avoid this: internal sessions are not closed automatically.
- */
- if (internal)
- F_SET(session_ret, WT_SESSION_INTERNAL);
-
- /*
* Configuration: currently, the configuration for open_session is the
* same as session.reconfigure, so use that function.
*/
diff --git a/src/session/session_dhandle.c b/src/session/session_dhandle.c
index 8c207b57874..96de77054d7 100644
--- a/src/session/session_dhandle.c
+++ b/src/session/session_dhandle.c
@@ -250,6 +250,42 @@ retry: WT_RET(__wt_meta_checkpoint_last_name(
}
/*
+ * __session_discard_btree --
+ * Discard our reference to the btree.
+ */
+static void
+__session_discard_btree(
+ WT_SESSION_IMPL *session, WT_DATA_HANDLE_CACHE *dhandle_cache)
+{
+ WT_DATA_HANDLE *saved_dhandle;
+
+ SLIST_REMOVE(
+ &session->dhandles, dhandle_cache, __wt_data_handle_cache, l);
+
+ saved_dhandle = session->dhandle;
+ session->dhandle = dhandle_cache->dhandle;
+
+ __wt_overwrite_and_free(session, dhandle_cache);
+ __wt_conn_btree_close(session);
+
+ /* Restore the original handle in the session. */
+ session->dhandle = saved_dhandle;
+}
+
+/*
+ * __wt_session_close_cache --
+ * Close any cached handles in a session.
+ */
+void
+__wt_session_close_cache(WT_SESSION_IMPL *session)
+{
+ WT_DATA_HANDLE_CACHE *dhandle_cache;
+
+ while ((dhandle_cache = SLIST_FIRST(&session->dhandles)) != NULL)
+ __session_discard_btree(session, dhandle_cache);
+}
+
+/*
* __session_dhandle_sweep --
* Discard any session dhandles that are not open.
*/
@@ -286,7 +322,7 @@ __session_dhandle_sweep(WT_SESSION_IMPL *session, uint32_t flags)
dhandle->session_inuse == 0 &&
now - dhandle->timeofdeath > WT_DHANDLE_SWEEP_WAIT) {
WT_STAT_FAST_CONN_INCR(session, dh_session_handles);
- __wt_session_discard_btree(session, dhandle_cache);
+ __session_discard_btree(session, dhandle_cache);
}
dhandle_cache = dhandle_cache_next;
}
@@ -307,6 +343,8 @@ __wt_session_get_btree(WT_SESSION_IMPL *session,
uint64_t hash;
int candidate;
+ WT_ASSERT(session, !F_ISSET(session, WT_SESSION_NO_DATA_HANDLES));
+
dhandle = NULL;
candidate = 0;
@@ -411,26 +449,3 @@ err: session->dhandle = saved_dhandle;
return (ret);
}
-
-/*
- * __wt_session_discard_btree --
- * Discard our reference to the btree.
- */
-void
-__wt_session_discard_btree(
- WT_SESSION_IMPL *session, WT_DATA_HANDLE_CACHE *dhandle_cache)
-{
- WT_DATA_HANDLE *saved_dhandle;
-
- SLIST_REMOVE(
- &session->dhandles, dhandle_cache, __wt_data_handle_cache, l);
-
- saved_dhandle = session->dhandle;
- session->dhandle = dhandle_cache->dhandle;
-
- __wt_overwrite_and_free(session, dhandle_cache);
- __wt_conn_btree_close(session);
-
- /* Restore the original handle in the session. */
- session->dhandle = saved_dhandle;
-}
diff --git a/src/txn/txn_recover.c b/src/txn/txn_recover.c
index 0fcb6604882..b4767d6e0d6 100644
--- a/src/txn/txn_recover.c
+++ b/src/txn/txn_recover.c
@@ -415,7 +415,7 @@ __wt_txn_recover(WT_SESSION_IMPL *default_session)
was_backup = F_ISSET(conn, WT_CONN_WAS_BACKUP) ? 1 : 0;
/* We need a real session for recovery. */
- WT_RET(__wt_open_session(conn, 0, NULL, NULL, &session));
+ WT_RET(__wt_open_session(conn, NULL, NULL, &session));
F_SET(session, WT_SESSION_NO_LOGGING);
r.session = session;