summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gorrod <alexander.gorrod@mongodb.com>2015-10-07 16:36:51 +1100
committerAlex Gorrod <alexander.gorrod@mongodb.com>2015-10-07 16:36:51 +1100
commitb1fb715a0c3b6f697bdcad8d9e3fe5acc59c71a6 (patch)
treef6ccc6c380da7ebba59874da084dbee4d3107dc4
parentbf1d359892b6ea0717e6b0465bfb59e0ecb5c4aa (diff)
parenta792371e4584c49f3c94b9e5843e0d57b2341fd8 (diff)
downloadmongo-b1fb715a0c3b6f697bdcad8d9e3fe5acc59c71a6.tar.gz
Merge pull request #2244 from wiredtiger/WT-2149
WT-2149 Track if the lookaside table is open when starting eviction workers
-rw-r--r--dist/flags.py1
-rw-r--r--src/cache/cache_las.c24
-rw-r--r--src/conn/conn_open.c15
-rw-r--r--src/evict/evict_lru.c16
-rw-r--r--src/include/extern.h2
-rw-r--r--src/include/flags.h23
-rw-r--r--src/txn/txn_recover.c5
7 files changed, 53 insertions, 33 deletions
diff --git a/dist/flags.py b/dist/flags.py
index d98f249335e..65b68cf4277 100644
--- a/dist/flags.py
+++ b/dist/flags.py
@@ -92,6 +92,7 @@ flags = {
'CONN_CKPT_SYNC',
'CONN_CLOSING',
'CONN_EVICTION_RUN',
+ 'CONN_LAS_OPEN',
'CONN_LEAK_MEMORY',
'CONN_LOG_SERVER_RUN',
'CONN_LSM_MERGE',
diff --git a/src/cache/cache_las.c b/src/cache/cache_las.c
index 30de8ce2301..2eb406c2af8 100644
--- a/src/cache/cache_las.c
+++ b/src/cache/cache_las.c
@@ -25,11 +25,8 @@ __wt_las_stats_update(WT_SESSION_IMPL *session)
* Lookaside table statistics are copied from the underlying lookaside
* table data-source statistics. If there's no lookaside table, values
* remain 0.
- *
- * The statistics log is started before we create the lookaside table,
- * check the session and the cursor for validity.
*/
- if (conn->las_session == NULL || conn->las_session->las_cursor == NULL)
+ if (!F_ISSET(conn, WT_CONN_LAS_OPEN))
return;
/*
@@ -62,25 +59,28 @@ __wt_las_create(WT_SESSION_IMPL *session)
/*
* Done at startup: we cannot do it on demand because we require the
- * schema lock to create and drop the file, and it may not always be
+ * schema lock to create and drop the table, and it may not always be
* available.
*
- * Discard any previous incarnation of the file.
+ * Discard any previous incarnation of the table.
*/
WT_RET(__wt_session_drop(session, WT_LAS_URI, drop_cfg));
- /* Re-create the file. */
+ /* Re-create the table. */
WT_RET(__wt_session_create(session, WT_LAS_URI, WT_LAS_FORMAT));
/*
- * Open an internal session, used for the shared lookaside cursor.
- *
- * Sessions associated with a lookaside cursor should never be tapped
- * for eviction.
+ * Open a shared internal session used to access the lookaside table.
+ * This session should never be tapped for eviction.
*/
session_flags = WT_SESSION_LOOKASIDE_CURSOR | WT_SESSION_NO_EVICTION;
- return (__wt_open_internal_session(
+ WT_RET(__wt_open_internal_session(
conn, "lookaside table", true, session_flags, &conn->las_session));
+
+ /* Flag that the lookaside table has been created. */
+ F_SET(conn, WT_CONN_LAS_OPEN);
+
+ return (0);
}
/*
diff --git a/src/conn/conn_open.c b/src/conn/conn_open.c
index 6db0c4bb10c..04815c8e152 100644
--- a/src/conn/conn_open.c
+++ b/src/conn/conn_open.c
@@ -234,7 +234,13 @@ __wt_connection_workers(WT_SESSION_IMPL *session, const char *cfg[])
WT_RET(__wt_statlog_create(session, cfg));
WT_RET(__wt_logmgr_create(session, cfg));
- /* Run recovery. */
+ /*
+ * Run recovery.
+ * NOTE: This call will start (and stop) eviction if recovery is
+ * required. Recovery must run before the lookaside table is created
+ * (because recovery will update the metadata), and before eviction is
+ * started for real.
+ */
WT_RET(__wt_txn_recover(session));
/*
@@ -249,8 +255,11 @@ __wt_connection_workers(WT_SESSION_IMPL *session, const char *cfg[])
/* Create the lookaside table. */
WT_RET(__wt_las_create(session));
- /* Start eviction threads. */
- WT_RET(__wt_evict_create(session, true));
+ /*
+ * Start eviction threads.
+ * NOTE: Eviction must be started after the lookaside table is created.
+ */
+ WT_RET(__wt_evict_create(session));
/* Start the handle sweep thread. */
WT_RET(__wt_sweep_create(session));
diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c
index dd1c86b5ad8..f9171900ca4 100644
--- a/src/evict/evict_lru.c
+++ b/src/evict/evict_lru.c
@@ -251,12 +251,17 @@ __evict_workers_resize(WT_SESSION_IMPL *session)
for (i = conn->evict_workers_alloc; i < conn->evict_workers_max; i++) {
/*
* Eviction worker threads get their own session.
- * Eviction worker threads get their own lookaside table cursor.
* Eviction worker threads may be called upon to perform slow
* operations for the block manager.
+ *
+ * Eviction worker threads get their own lookaside table cursor
+ * if the lookaside table is open. Note that eviction is also
+ * started during recovery, before the lookaside table is
+ * created.
*/
- session_flags =
- WT_SESSION_CAN_WAIT | WT_SESSION_LOOKASIDE_CURSOR;
+ session_flags = WT_SESSION_CAN_WAIT;
+ if (F_ISSET(conn, WT_CONN_LAS_OPEN))
+ FLD_SET(session_flags, WT_SESSION_LOOKASIDE_CURSOR);
WT_ERR(__wt_open_internal_session(conn, "eviction-worker",
false, session_flags, &workers[i].session));
workers[i].id = i;
@@ -278,7 +283,7 @@ err: conn->evict_workers_alloc = conn->evict_workers_max;
* Start the eviction server thread.
*/
int
-__wt_evict_create(WT_SESSION_IMPL *session, bool with_las)
+__wt_evict_create(WT_SESSION_IMPL *session)
{
WT_CONNECTION_IMPL *conn;
uint32_t session_flags;
@@ -297,7 +302,8 @@ __wt_evict_create(WT_SESSION_IMPL *session, bool with_las)
* perform slow operations for the block manager. (The flag is not
* reset if reconfigured later, but I doubt that's a problem.)
*/
- session_flags = with_las ? WT_SESSION_LOOKASIDE_CURSOR : 0;
+ session_flags = F_ISSET(conn, WT_CONN_LAS_OPEN) ?
+ WT_SESSION_LOOKASIDE_CURSOR : 0;
if (conn->evict_workers_max == 0)
FLD_SET(session_flags, WT_SESSION_CAN_WAIT);
WT_RET(__wt_open_internal_session(conn,
diff --git a/src/include/extern.h b/src/include/extern.h
index 171f6b02768..1f63f07646e 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -319,7 +319,7 @@ extern int __wt_curtable_open(WT_SESSION_IMPL *session, const char *uri, const c
extern int __wt_evict_file(WT_SESSION_IMPL *session, int syncop);
extern void __wt_evict_list_clear_page(WT_SESSION_IMPL *session, WT_REF *ref);
extern int __wt_evict_server_wake(WT_SESSION_IMPL *session);
-extern int __wt_evict_create(WT_SESSION_IMPL *session, bool with_las);
+extern int __wt_evict_create(WT_SESSION_IMPL *session);
extern int __wt_evict_destroy(WT_SESSION_IMPL *session);
extern int __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session, bool *evict_resetp);
extern void __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session);
diff --git a/src/include/flags.h b/src/include/flags.h
index ca3c3c38245..24dccd30913 100644
--- a/src/include/flags.h
+++ b/src/include/flags.h
@@ -6,17 +6,18 @@
#define WT_CONN_CKPT_SYNC 0x00000002
#define WT_CONN_CLOSING 0x00000004
#define WT_CONN_EVICTION_RUN 0x00000008
-#define WT_CONN_LEAK_MEMORY 0x00000010
-#define WT_CONN_LOG_SERVER_RUN 0x00000020
-#define WT_CONN_LSM_MERGE 0x00000040
-#define WT_CONN_PANIC 0x00000080
-#define WT_CONN_SERVER_ASYNC 0x00000100
-#define WT_CONN_SERVER_CHECKPOINT 0x00000200
-#define WT_CONN_SERVER_LSM 0x00000400
-#define WT_CONN_SERVER_RUN 0x00000800
-#define WT_CONN_SERVER_STATISTICS 0x00001000
-#define WT_CONN_SERVER_SWEEP 0x00002000
-#define WT_CONN_WAS_BACKUP 0x00004000
+#define WT_CONN_LAS_OPEN 0x00000010
+#define WT_CONN_LEAK_MEMORY 0x00000020
+#define WT_CONN_LOG_SERVER_RUN 0x00000040
+#define WT_CONN_LSM_MERGE 0x00000080
+#define WT_CONN_PANIC 0x00000100
+#define WT_CONN_SERVER_ASYNC 0x00000200
+#define WT_CONN_SERVER_CHECKPOINT 0x00000400
+#define WT_CONN_SERVER_LSM 0x00000800
+#define WT_CONN_SERVER_RUN 0x00001000
+#define WT_CONN_SERVER_STATISTICS 0x00002000
+#define WT_CONN_SERVER_SWEEP 0x00004000
+#define WT_CONN_WAS_BACKUP 0x00008000
#define WT_EVICTING 0x00000001
#define WT_EVICT_LOOKASIDE 0x00000002
#define WT_EVICT_UPDATE_RESTORE 0x00000004
diff --git a/src/txn/txn_recover.c b/src/txn/txn_recover.c
index 9d8a19cbff3..63d86969311 100644
--- a/src/txn/txn_recover.c
+++ b/src/txn/txn_recover.c
@@ -501,7 +501,7 @@ __wt_txn_recover(WT_SESSION_IMPL *session)
* regular eviction to manage paging. Start eviction threads for
* recovery without LAS cursors.
*/
- WT_ERR(__wt_evict_create(session, false));
+ WT_ERR(__wt_evict_create(session));
eviction_started = true;
/*
@@ -533,6 +533,9 @@ done: FLD_SET(conn->log_flags, WT_CONN_LOG_RECOVER_DONE);
err: WT_TRET(__recovery_free(&r));
__wt_free(session, config);
+ if (ret != 0)
+ __wt_err(session, ret, "Recovery failed");
+
/*
* Destroy the eviction threads that were started in support of
* recovery. They will be restarted once the lookaside table is