summaryrefslogtreecommitdiff
path: root/src/conn
diff options
context:
space:
mode:
Diffstat (limited to 'src/conn')
-rw-r--r--src/conn/conn_api.c204
-rw-r--r--src/conn/conn_cache.c20
-rw-r--r--src/conn/conn_cache_pool.c1
-rw-r--r--src/conn/conn_handle.c8
-rw-r--r--src/conn/conn_log.c42
-rw-r--r--src/conn/conn_open.c2
-rw-r--r--src/conn/conn_stat.c32
7 files changed, 201 insertions, 108 deletions
diff --git a/src/conn/conn_api.c b/src/conn/conn_api.c
index 9e2f03da21f..18ad383ec74 100644
--- a/src/conn/conn_api.c
+++ b/src/conn/conn_api.c
@@ -806,6 +806,7 @@ static int
__conn_load_default_extensions(WT_CONNECTION_IMPL *conn)
{
WT_UNUSED(conn);
+
#ifdef HAVE_BUILTIN_EXTENSION_SNAPPY
WT_RET(snappy_extension_init(&conn->iface, NULL));
#endif
@@ -819,18 +820,16 @@ __conn_load_default_extensions(WT_CONNECTION_IMPL *conn)
}
/*
- * __conn_load_extension --
- * WT_CONNECTION->load_extension method.
+ * __conn_load_extension_int --
+ * Internal extension load interface
*/
static int
-__conn_load_extension(
- WT_CONNECTION *wt_conn, const char *path, const char *config)
+__conn_load_extension_int(WT_SESSION_IMPL *session,
+ const char *path, const char *cfg[], bool early_load)
{
WT_CONFIG_ITEM cval;
- WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
WT_DLH *dlh;
- WT_SESSION_IMPL *session;
int (*load)(WT_CONNECTION *, WT_CONFIG_ARG *);
bool is_local;
const char *init_name, *terminate_name;
@@ -839,8 +838,10 @@ __conn_load_extension(
init_name = terminate_name = NULL;
is_local = strcmp(path, "local") == 0;
- conn = (WT_CONNECTION_IMPL *)wt_conn;
- CONNECTION_API_CALL(conn, session, load_extension, config, cfg);
+ /* Ensure that the load matches the phase of startup we are in. */
+ WT_ERR(__wt_config_gets(session, cfg, "early_load", &cval));
+ if ((cval.val == 0 && early_load) || (cval.val != 0 && !early_load))
+ return (0);
/*
* This assumes the underlying shared libraries are reference counted,
@@ -865,20 +866,39 @@ __conn_load_extension(
__wt_dlsym(session, dlh, terminate_name, false, &dlh->terminate));
/* Call the load function last, it simplifies error handling. */
- WT_ERR(load(wt_conn, (WT_CONFIG_ARG *)cfg));
+ WT_ERR(load(&S2C(session)->iface, (WT_CONFIG_ARG *)cfg));
/* Link onto the environment's list of open libraries. */
- __wt_spin_lock(session, &conn->api_lock);
- TAILQ_INSERT_TAIL(&conn->dlhqh, dlh, q);
- __wt_spin_unlock(session, &conn->api_lock);
+ __wt_spin_lock(session, &S2C(session)->api_lock);
+ TAILQ_INSERT_TAIL(&S2C(session)->dlhqh, dlh, q);
+ __wt_spin_unlock(session, &S2C(session)->api_lock);
dlh = NULL;
err: if (dlh != NULL)
WT_TRET(__wt_dlclose(session, dlh));
__wt_free(session, init_name);
__wt_free(session, terminate_name);
+ return (ret);
+}
- API_END_RET_NOTFOUND_MAP(session, ret);
+/*
+ * __conn_load_extension --
+ * WT_CONNECTION->load_extension method.
+ */
+static int
+__conn_load_extension(
+ WT_CONNECTION *wt_conn, const char *path, const char *config)
+{
+ WT_CONNECTION_IMPL *conn;
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ conn = (WT_CONNECTION_IMPL *)wt_conn;
+ CONNECTION_API_CALL(conn, session, load_extension, config, cfg);
+
+ ret = __conn_load_extension_int(session, path, cfg, false);
+
+err: API_END_RET_NOTFOUND_MAP(session, ret);
}
/*
@@ -886,18 +906,16 @@ err: if (dlh != NULL)
* Load the list of application-configured extensions.
*/
static int
-__conn_load_extensions(WT_SESSION_IMPL *session, const char *cfg[])
+__conn_load_extensions(
+ WT_SESSION_IMPL *session, const char *cfg[], bool early_load)
{
WT_CONFIG subconfig;
WT_CONFIG_ITEM cval, skey, sval;
- WT_CONNECTION_IMPL *conn;
WT_DECL_ITEM(exconfig);
WT_DECL_ITEM(expath);
WT_DECL_RET;
-
- conn = S2C(session);
-
- WT_ERR(__conn_load_default_extensions(conn));
+ const char *sub_cfg[] = {
+ WT_CONFIG_BASE(session, WT_CONNECTION_load_extension), NULL, NULL };
WT_ERR(__wt_config_gets(session, cfg, "extensions", &cval));
WT_ERR(__wt_config_subinit(session, &subconfig, &cval));
@@ -912,8 +930,9 @@ __conn_load_extensions(WT_SESSION_IMPL *session, const char *cfg[])
WT_ERR(__wt_buf_fmt(session,
exconfig, "%.*s", (int)sval.len, sval.str));
}
- WT_ERR(conn->iface.load_extension(&conn->iface,
- expath->data, (sval.len > 0) ? exconfig->data : NULL));
+ sub_cfg[1] = sval.len > 0 ? exconfig->data : NULL;
+ WT_ERR(__conn_load_extension_int(
+ session, expath->data, sub_cfg, early_load));
}
WT_ERR_NOTFOUND_OK(ret);
@@ -1192,13 +1211,12 @@ __conn_config_file(WT_SESSION_IMPL *session,
fh = NULL;
/* Configuration files are always optional. */
- WT_RET(__wt_exist(session, filename, &exist));
+ WT_RET(__wt_fs_exist(session, filename, &exist));
if (!exist)
return (0);
/* Open the configuration file. */
- WT_RET(__wt_open(
- session, filename, WT_FILE_TYPE_REGULAR, WT_OPEN_READONLY, &fh));
+ WT_RET(__wt_open(session, filename, WT_OPEN_FILE_TYPE_REGULAR, 0, &fh));
WT_ERR(__wt_filesize(session, fh, &size));
if (size == 0)
goto err;
@@ -1489,8 +1507,8 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[])
*/
exist = false;
if (!is_create)
- WT_ERR(__wt_exist(session, WT_WIREDTIGER, &exist));
- ret = __wt_open(session, WT_SINGLETHREAD, WT_FILE_TYPE_REGULAR,
+ WT_ERR(__wt_fs_exist(session, WT_WIREDTIGER, &exist));
+ ret = __wt_open(session, WT_SINGLETHREAD, WT_OPEN_FILE_TYPE_REGULAR,
is_create || exist ? WT_OPEN_CREATE : 0, &conn->lock_fh);
/*
@@ -1546,7 +1564,7 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[])
/* We own the lock file, optionally create the WiredTiger file. */
ret = __wt_open(session, WT_WIREDTIGER,
- WT_FILE_TYPE_REGULAR, is_create ? WT_OPEN_CREATE : 0, &fh);
+ WT_OPEN_FILE_TYPE_REGULAR, is_create ? WT_OPEN_CREATE : 0, &fh);
/*
* If we're read-only, check for success as well as handled errors.
@@ -1583,13 +1601,14 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[])
* and there's never a database home after that point without a turtle
* file. If the turtle file doesn't exist, it's a create.
*/
- WT_ERR(__wt_exist(session, WT_METADATA_TURTLE, &exist));
+ WT_ERR(__wt_fs_exist(session, WT_METADATA_TURTLE, &exist));
conn->is_new = exist ? 0 : 1;
if (conn->is_new) {
if (F_ISSET(conn, WT_CONN_READONLY))
- WT_ERR_MSG(session, EINVAL, "Creating a new database is"
- " incompatible with read-only configuration.");
+ WT_ERR_MSG(session, EINVAL,
+ "Creating a new database is incompatible with "
+ "read-only configuration");
len = (size_t)snprintf(buf, sizeof(buf),
"%s\n%s\n", WT_WIREDTIGER, WIREDTIGER_VERSION_STRING);
WT_ERR(__wt_write(session, fh, (wt_off_t)0, len, buf));
@@ -1754,14 +1773,14 @@ __wt_verbose_config(WT_SESSION_IMPL *session, const char *cfg[])
static int
__conn_write_base_config(WT_SESSION_IMPL *session, const char *cfg[])
{
- WT_FH *fh;
+ WT_FSTREAM *fs;
WT_CONFIG parser;
WT_CONFIG_ITEM cval, k, v;
WT_DECL_RET;
bool exist;
const char *base_config;
- fh = NULL;
+ fs = NULL;
base_config = NULL;
/*
@@ -1789,15 +1808,14 @@ __conn_write_base_config(WT_SESSION_IMPL *session, const char *cfg[])
* only NOT exist if we crashed before it was created; in other words,
* if the base configuration file exists, we're done.
*/
- WT_RET(__wt_exist(session, WT_BASECONFIG, &exist));
+ WT_RET(__wt_fs_exist(session, WT_BASECONFIG, &exist));
if (exist)
return (0);
- WT_RET(__wt_open(session,
- WT_BASECONFIG_SET, WT_FILE_TYPE_REGULAR,
- WT_OPEN_CREATE | WT_OPEN_EXCLUSIVE | WT_STREAM_WRITE, &fh));
+ WT_RET(__wt_fopen(session, WT_BASECONFIG_SET,
+ WT_OPEN_CREATE | WT_OPEN_EXCLUSIVE, WT_STREAM_WRITE, &fs));
- WT_ERR(__wt_fprintf(session, fh, "%s\n\n",
+ WT_ERR(__wt_fprintf(session, fs, "%s\n\n",
"# Do not modify this file.\n"
"#\n"
"# WiredTiger created this file when the database was created,\n"
@@ -1844,18 +1862,18 @@ __conn_write_base_config(WT_SESSION_IMPL *session, const char *cfg[])
--v.str;
v.len += 2;
}
- WT_ERR(__wt_fprintf(session, fh,
+ WT_ERR(__wt_fprintf(session, fs,
"%.*s=%.*s\n", (int)k.len, k.str, (int)v.len, v.str));
}
WT_ERR_NOTFOUND_OK(ret);
- /* Flush the handle and rename the file into place. */
- ret = __wt_sync_handle_and_rename(
- session, &fh, WT_BASECONFIG_SET, WT_BASECONFIG);
+ /* Flush the stream and rename the file into place. */
+ ret = __wt_sync_and_rename(
+ session, &fs, WT_BASECONFIG_SET, WT_BASECONFIG);
if (0) {
/* Close open file handle, remove any temporary file. */
-err: WT_TRET(__wt_close(session, &fh));
+err: WT_TRET(__wt_fclose(session, &fs));
WT_TRET(__wt_remove_if_exists(session, WT_BASECONFIG_SET));
}
@@ -1865,6 +1883,57 @@ err: WT_TRET(__wt_close(session, &fh));
}
/*
+ * __conn_set_file_system --
+ * Configure a custom file system implementation on database open.
+ */
+static int
+__conn_set_file_system(
+ WT_CONNECTION *wt_conn, WT_FILE_SYSTEM *file_system, const char *config)
+{
+ WT_CONNECTION_IMPL *conn;
+ WT_DECL_RET;
+ WT_SESSION_IMPL *session;
+
+ conn = (WT_CONNECTION_IMPL *)wt_conn;
+ CONNECTION_API_CALL(conn, session, set_file_system, config, cfg);
+ WT_UNUSED(cfg);
+
+ conn->file_system = file_system;
+
+err: API_END_RET(session, ret);
+}
+
+/*
+ * __conn_chk_file_system --
+ * Check the configured file system.
+ */
+static int
+__conn_chk_file_system(WT_SESSION_IMPL *session, bool readonly)
+{
+ WT_CONNECTION_IMPL *conn;
+
+ conn = S2C(session);
+
+#define WT_CONN_SET_FILE_SYSTEM_REQ(name) \
+ if (conn->file_system->name == NULL) \
+ WT_RET_MSG(session, EINVAL, \
+ "a WT_FILE_SYSTEM.%s method must be configured", #name)
+
+ WT_CONN_SET_FILE_SYSTEM_REQ(directory_list);
+ WT_CONN_SET_FILE_SYSTEM_REQ(directory_list_free);
+ /* not required: directory_sync */
+ WT_CONN_SET_FILE_SYSTEM_REQ(exist);
+ WT_CONN_SET_FILE_SYSTEM_REQ(open_file);
+ if (!readonly) {
+ WT_CONN_SET_FILE_SYSTEM_REQ(remove);
+ WT_CONN_SET_FILE_SYSTEM_REQ(rename);
+ }
+ WT_CONN_SET_FILE_SYSTEM_REQ(size);
+
+ return (0);
+}
+
+/*
* wiredtiger_open --
* Main library entry point: open a new connection to a WiredTiger
* database.
@@ -1888,12 +1957,13 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
__conn_add_compressor,
__conn_add_encryptor,
__conn_add_extractor,
+ __conn_set_file_system,
__conn_get_extension_api
};
static const WT_NAME_FLAG file_types[] = {
- { "checkpoint", WT_FILE_TYPE_CHECKPOINT },
- { "data", WT_FILE_TYPE_DATA },
- { "log", WT_FILE_TYPE_LOG },
+ { "checkpoint", WT_DIRECT_IO_CHECKPOINT },
+ { "data", WT_DIRECT_IO_DATA },
+ { "log", WT_DIRECT_IO_LOG },
{ NULL, 0 }
};
@@ -1983,10 +2053,27 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
F_SET(conn, WT_CONN_READONLY);
/*
- * After checking readonly and in-memory, but before we do anything that
- * touches the filesystem, configure the OS layer.
+ * Load early extensions before doing further initialization (one early
+ * extension is to configure a file system).
*/
- WT_ERR(__wt_os_init(session));
+ WT_ERR(__conn_load_extensions(session, cfg, true));
+
+ /*
+ * If the application didn't configure its own file system, configure
+ * one of ours. Check to ensure we have a valid file system.
+ */
+ if (conn->file_system == NULL) {
+ if (F_ISSET(conn, WT_CONN_IN_MEMORY))
+ WT_ERR(__wt_os_inmemory(session));
+ else
+#if defined(_MSC_VER)
+ WT_ERR(__wt_os_win(session));
+#else
+ WT_ERR(__wt_os_posix(session));
+#endif
+ }
+ WT_ERR(
+ __conn_chk_file_system(session, F_ISSET(conn, WT_CONN_READONLY)));
/*
* Capture the config_base setting file for later use. Again, if the
@@ -2036,7 +2123,7 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
__conn_config_append(cfg, version);
/* Ignore the base_config file if config_base_set is false. */
- if (config_base_set || F_ISSET(conn, WT_CONN_READONLY))
+ if (config_base_set)
WT_ERR(
__conn_config_file(session, WT_BASECONFIG, false, cfg, i1));
__conn_config_append(cfg, config);
@@ -2119,8 +2206,8 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
if (ret == 0) {
if (sval.val)
FLD_SET(conn->direct_io, ft->flag);
- } else if (ret != WT_NOTFOUND)
- goto err;
+ } else
+ WT_ERR_NOTFOUND_OK(ret);
}
WT_ERR(__wt_config_gets(session, cfg, "write_through", &cval));
@@ -2129,8 +2216,8 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
if (ret == 0) {
if (sval.val)
FLD_SET(conn->write_through, ft->flag);
- } else if (ret != WT_NOTFOUND)
- goto err;
+ } else
+ WT_ERR_NOTFOUND_OK(ret);
}
/*
@@ -2154,15 +2241,15 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
ret = __wt_config_subgets(session, &cval, ft->name, &sval);
if (ret == 0) {
switch (ft->flag) {
- case WT_FILE_TYPE_DATA:
+ case WT_DIRECT_IO_DATA:
conn->data_extend_len = sval.val;
break;
- case WT_FILE_TYPE_LOG:
+ case WT_DIRECT_IO_LOG:
conn->log_extend_len = sval.val;
break;
}
- } else if (ret != WT_NOTFOUND)
- goto err;
+ } else
+ WT_ERR_NOTFOUND_OK(ret);
}
WT_ERR(__wt_config_gets(session, cfg, "mmap", &cval));
@@ -2191,7 +2278,8 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
* everything else to be in place, and the extensions call back into the
* library.
*/
- WT_ERR(__conn_load_extensions(session, cfg));
+ WT_ERR(__conn_load_default_extensions(conn));
+ WT_ERR(__conn_load_extensions(session, cfg, false));
/*
* The metadata/log encryptor is configured after extensions, since
diff --git a/src/conn/conn_cache.c b/src/conn/conn_cache.c
index 9a2c394e9a6..4d33ac608bb 100644
--- a/src/conn/conn_cache.c
+++ b/src/conn/conn_cache.c
@@ -127,6 +127,7 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[])
WT_CACHE *cache;
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
+ int i;
conn = S2C(session);
@@ -157,13 +158,18 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[])
false, 10000, WT_MILLION, &cache->evict_cond));
WT_ERR(__wt_cond_alloc(session,
"eviction waiters", false, &cache->evict_waiter_cond));
- WT_ERR(__wt_spin_init(session, &cache->evict_lock, "cache eviction"));
+ WT_ERR(__wt_spin_init(session,
+ &cache->evict_queue_lock, "cache eviction queue"));
WT_ERR(__wt_spin_init(session, &cache->evict_walk_lock, "cache walk"));
/* Allocate the LRU eviction queue. */
cache->evict_slots = WT_EVICT_WALK_BASE + WT_EVICT_WALK_INCR;
- WT_ERR(__wt_calloc_def(session,
- cache->evict_slots, &cache->evict_queue));
+ for (i = 0; i < WT_EVICT_QUEUE_MAX; ++i) {
+ WT_ERR(__wt_calloc_def(session,
+ cache->evict_slots, &cache->evict_queues[i].evict_queue));
+ WT_ERR(__wt_spin_init(session,
+ &cache->evict_queues[i].evict_lock, "cache eviction"));
+ }
/*
* We get/set some values in the cache statistics (rather than have
@@ -229,6 +235,7 @@ __wt_cache_destroy(WT_SESSION_IMPL *session)
WT_CACHE *cache;
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
+ int i;
conn = S2C(session);
cache = conn->cache;
@@ -254,10 +261,13 @@ __wt_cache_destroy(WT_SESSION_IMPL *session)
WT_TRET(__wt_cond_auto_destroy(session, &cache->evict_cond));
WT_TRET(__wt_cond_destroy(session, &cache->evict_waiter_cond));
- __wt_spin_destroy(session, &cache->evict_lock);
+ __wt_spin_destroy(session, &cache->evict_queue_lock);
__wt_spin_destroy(session, &cache->evict_walk_lock);
- __wt_free(session, cache->evict_queue);
+ for (i = 0; i < WT_EVICT_QUEUE_MAX; ++i) {
+ __wt_spin_destroy(session, &cache->evict_queues[i].evict_lock);
+ __wt_free(session, cache->evict_queues[i].evict_queue);
+ }
__wt_free(session, conn->cache);
return (ret);
}
diff --git a/src/conn/conn_cache_pool.c b/src/conn/conn_cache_pool.c
index 72f23b015b7..1e34b514aa7 100644
--- a/src/conn/conn_cache_pool.c
+++ b/src/conn/conn_cache_pool.c
@@ -58,7 +58,6 @@ __wt_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg)
created = updating = false;
pool_name = NULL;
cp = NULL;
- size = 0;
if (F_ISSET(conn, WT_CONN_CACHE_POOL))
updating = true;
diff --git a/src/conn/conn_handle.c b/src/conn/conn_handle.c
index 5f4c38e7361..509966793e5 100644
--- a/src/conn/conn_handle.c
+++ b/src/conn/conn_handle.c
@@ -149,15 +149,17 @@ __wt_connection_destroy(WT_CONNECTION_IMPL *conn)
__wt_spin_destroy(session, &conn->page_lock[i]);
__wt_free(session, conn->page_lock);
+ /* Destroy the file-system configuration. */
+ if (conn->file_system != NULL && conn->file_system->terminate != NULL)
+ WT_TRET(conn->file_system->terminate(
+ conn->file_system, (WT_SESSION *)session));
+
/* Free allocated memory. */
__wt_free(session, conn->cfg);
__wt_free(session, conn->home);
__wt_free(session, conn->error_prefix);
__wt_free(session, conn->sessions);
- /* Destroy the OS configuration. */
- WT_TRET(__wt_os_cleanup(session));
-
__wt_free(NULL, conn);
return (ret);
}
diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c
index 6cb8ba3d0f9..5397962bc4f 100644
--- a/src/conn/conn_log.c
+++ b/src/conn/conn_log.c
@@ -178,6 +178,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
conn = S2C(session);
log = conn->log;
logcount = 0;
+ locked = false;
logfiles = NULL;
/*
@@ -198,14 +199,14 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
* Main archive code. Get the list of all log files and
* remove any earlier than the minimum log number.
*/
- WT_RET(__wt_dirlist(session, conn->log_path,
- WT_LOG_FILENAME, WT_DIRLIST_INCLUDE, &logfiles, &logcount));
+ WT_ERR(__wt_fs_directory_list(
+ session, conn->log_path, WT_LOG_FILENAME, &logfiles, &logcount));
/*
* We can only archive files if a hot backup is not in progress or
* if we are the backup.
*/
- WT_RET(__wt_readlock(session, conn->hot_backup_lock));
+ WT_ERR(__wt_readlock(session, conn->hot_backup_lock));
locked = true;
if (!conn->hot_backup || backup_file != 0) {
for (i = 0; i < logcount; i++) {
@@ -218,9 +219,6 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
}
WT_ERR(__wt_readunlock(session, conn->hot_backup_lock));
locked = false;
- __wt_log_files_free(session, logfiles, logcount);
- logfiles = NULL;
- logcount = 0;
/*
* Indicate what is our new earliest LSN. It is the start
@@ -232,8 +230,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
err: __wt_err(session, ret, "log archive server error");
if (locked)
WT_TRET(__wt_readunlock(session, conn->hot_backup_lock));
- if (logfiles != NULL)
- __wt_log_files_free(session, logfiles, logcount);
+ WT_TRET(__wt_fs_directory_list_free(session, &logfiles, logcount));
return (ret);
}
@@ -259,10 +256,9 @@ __log_prealloc_once(WT_SESSION_IMPL *session)
* Allocate up to the maximum number, accounting for any existing
* files that may not have been used yet.
*/
- WT_ERR(__wt_dirlist(session, conn->log_path,
- WT_LOG_PREPNAME, WT_DIRLIST_INCLUDE, &recfiles, &reccount));
- __wt_log_files_free(session, recfiles, reccount);
- recfiles = NULL;
+ WT_ERR(__wt_fs_directory_list(
+ session, conn->log_path, WT_LOG_PREPNAME, &recfiles, &reccount));
+
/*
* Adjust the number of files to pre-allocate if we find that
* the critical path had to allocate them since we last ran.
@@ -292,8 +288,7 @@ __log_prealloc_once(WT_SESSION_IMPL *session)
if (0)
err: __wt_err(session, ret, "log pre-alloc server error");
- if (recfiles != NULL)
- __wt_log_files_free(session, recfiles, reccount);
+ WT_TRET(__wt_fs_directory_list_free(session, &recfiles, reccount));
return (ret);
}
@@ -314,12 +309,15 @@ __wt_log_truncate_files(
WT_UNUSED(cfg);
conn = S2C(session);
- log = conn->log;
+ if (!FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
+ return (0);
if (F_ISSET(conn, WT_CONN_SERVER_RUN) &&
FLD_ISSET(conn->log_flags, WT_CONN_LOG_ARCHIVE))
WT_RET_MSG(session, EINVAL,
"Attempt to archive manually while a server is running");
+ log = conn->log;
+
backup_file = 0;
if (cursor != NULL)
backup_file = WT_CURSOR_BACKUP_ID(cursor);
@@ -327,6 +325,7 @@ __wt_log_truncate_files(
WT_RET(__wt_verbose(session, WT_VERB_LOG,
"log_truncate_files: Archive once up to %" PRIu32,
backup_file));
+
WT_RET(__wt_writelock(session, log->log_archive_lock));
locked = true;
WT_ERR(__log_archive_once(session, backup_file));
@@ -679,7 +678,6 @@ __log_wrlsn_server(void *arg)
log = conn->log;
yield = 0;
WT_INIT_LSN(&prev);
- did_work = false;
while (F_ISSET(conn, WT_CONN_LOG_SERVER_RUN)) {
/*
* Write out any log record buffers if anything was done
@@ -694,10 +692,8 @@ __log_wrlsn_server(void *arg)
else
WT_STAT_FAST_CONN_INCR(session, log_write_lsn_skip);
prev = log->alloc_lsn;
- if (yield == 0)
- did_work = true;
- else
- did_work = false;
+ did_work = yield == 0;
+
/*
* If __wt_log_wrlsn did work we want to yield instead of sleep.
*/
@@ -867,9 +863,9 @@ __wt_logmgr_create(WT_SESSION_IMPL *session, const char *cfg[])
"log write LSN"));
WT_RET(__wt_rwlock_alloc(session,
&log->log_archive_lock, "log archive lock"));
- if (FLD_ISSET(conn->direct_io, WT_FILE_TYPE_LOG))
- log->allocsize =
- WT_MAX((uint32_t)conn->buffer_alignment, WT_LOG_ALIGN);
+ if (FLD_ISSET(conn->direct_io, WT_DIRECT_IO_LOG))
+ log->allocsize = (uint32_t)
+ WT_MAX(conn->buffer_alignment, WT_LOG_ALIGN);
else
log->allocsize = WT_LOG_ALIGN;
WT_INIT_LSN(&log->alloc_lsn);
diff --git a/src/conn/conn_open.c b/src/conn/conn_open.c
index 38c3288209e..f5722d343f7 100644
--- a/src/conn/conn_open.c
+++ b/src/conn/conn_open.c
@@ -93,7 +93,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn)
* transaction ID will catch up with the current ID.
*/
for (;;) {
- __wt_txn_update_oldest(session, true);
+ WT_TRET(__wt_txn_update_oldest(session, true));
if (txn_global->oldest_id == txn_global->current)
break;
__wt_yield();
diff --git a/src/conn/conn_stat.c b/src/conn/conn_stat.c
index fccc4786402..855ff57808e 100644
--- a/src/conn/conn_stat.c
+++ b/src/conn/conn_stat.c
@@ -209,11 +209,11 @@ __statlog_dump(WT_SESSION_IMPL *session, const char *name, bool conn_stats)
}
if (FLD_ISSET(conn->stat_flags, WT_CONN_STAT_JSON)) {
- WT_ERR(__wt_fprintf(session, conn->stat_fh,
+ WT_ERR(__wt_fprintf(session, conn->stat_fs,
"{\"version\":\"%s\",\"localTime\":\"%s\"",
WIREDTIGER_VERSION_STRING, conn->stat_stamp));
WT_ERR(__wt_fprintf(
- session, conn->stat_fh, ",\"wiredTiger\":{"));
+ session, conn->stat_fs, ",\"wiredTiger\":{"));
while ((ret = cursor->next(cursor)) == 0) {
WT_ERR(cursor->get_value(cursor, &desc, &valstr, &val));
/* Check if we are starting a new section. */
@@ -225,23 +225,23 @@ __statlog_dump(WT_SESSION_IMPL *session, const char *name, bool conn_stats)
strncmp(desc, tmp->data, tmp->size) != 0) {
WT_ERR(__wt_buf_set(
session, tmp, desc, prefixlen));
- WT_ERR(__wt_fprintf(session, conn->stat_fh,
+ WT_ERR(__wt_fprintf(session, conn->stat_fs,
"%s\"%.*s\":{", first ? "" : "},",
(int)prefixlen, desc));
first = false;
groupfirst = true;
}
- WT_ERR(__wt_fprintf(session, conn->stat_fh,
+ WT_ERR(__wt_fprintf(session, conn->stat_fs,
"%s\"%s\":%" PRId64,
groupfirst ? "" : ",", endprefix + 2, val));
groupfirst = false;
}
WT_ERR_NOTFOUND_OK(ret);
- WT_ERR(__wt_fprintf(session, conn->stat_fh, "}}}\n"));
+ WT_ERR(__wt_fprintf(session, conn->stat_fs, "}}}\n"));
} else {
while ((ret = cursor->next(cursor)) == 0) {
WT_ERR(cursor->get_value(cursor, &desc, &valstr, &val));
- WT_ERR(__wt_fprintf(session, conn->stat_fh,
+ WT_ERR(__wt_fprintf(session, conn->stat_fs,
"%s %" PRId64 " %s %s\n",
conn->stat_stamp, val, name, desc));
}
@@ -354,7 +354,7 @@ __statlog_log_one(WT_SESSION_IMPL *session, WT_ITEM *path, WT_ITEM *tmp)
struct tm *tm, _tm;
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
- WT_FH *log_file;
+ WT_FSTREAM *log_stream;
conn = S2C(session);
@@ -367,18 +367,16 @@ __statlog_log_one(WT_SESSION_IMPL *session, WT_ITEM *path, WT_ITEM *tmp)
WT_RET_MSG(session, ENOMEM, "strftime path conversion");
/* If the path has changed, cycle the log file. */
- if ((log_file = conn->stat_fh) == NULL ||
+ if ((log_stream = conn->stat_fs) == NULL ||
path == NULL || strcmp(tmp->mem, path->mem) != 0) {
- conn->stat_fh = NULL;
- WT_RET(__wt_close(session, &log_file));
+ WT_RET(__wt_fclose(session, &conn->stat_fs));
if (path != NULL)
(void)strcpy(path->mem, tmp->mem);
- WT_RET(__wt_open(session, tmp->mem,
- WT_FILE_TYPE_REGULAR,
- WT_OPEN_CREATE | WT_OPEN_FIXED | WT_STREAM_APPEND,
- &log_file));
+ WT_RET(__wt_fopen(session, tmp->mem,
+ WT_OPEN_CREATE | WT_OPEN_FIXED, WT_STREAM_APPEND,
+ &log_stream));
}
- conn->stat_fh = log_file;
+ conn->stat_fs = log_stream;
/* Create the entry prefix for this time of day. */
if (strftime(tmp->mem, tmp->memsize, conn->stat_format, tm) == 0)
@@ -411,7 +409,7 @@ __statlog_log_one(WT_SESSION_IMPL *session, WT_ITEM *path, WT_ITEM *tmp)
WT_RET(__statlog_lsm_apply(session));
/* Flush. */
- return (__wt_fsync(session, conn->stat_fh, true));
+ return (__wt_fflush(session, conn->stat_fs));
}
/*
@@ -597,7 +595,7 @@ __wt_statlog_destroy(WT_SESSION_IMPL *session, bool is_close)
conn->stat_session = NULL;
conn->stat_tid_set = false;
conn->stat_format = NULL;
- WT_TRET(__wt_close(session, &conn->stat_fh));
+ WT_TRET(__wt_fclose(session, &conn->stat_fs));
conn->stat_path = NULL;
conn->stat_sources = NULL;
conn->stat_stamp = NULL;