summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/conn
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/conn')
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_api.c4
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_cache.c40
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_cache_pool.c68
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_ckpt.c18
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_dhandle.c16
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_handle.c2
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_log.c121
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_open.c33
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_stat.c5
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_sweep.c29
10 files changed, 164 insertions, 172 deletions
diff --git a/src/third_party/wiredtiger/src/conn/conn_api.c b/src/third_party/wiredtiger/src/conn/conn_api.c
index 1c6b0c2b500..ab7657c3a89 100644
--- a/src/third_party/wiredtiger/src/conn/conn_api.c
+++ b/src/third_party/wiredtiger/src/conn/conn_api.c
@@ -1727,6 +1727,7 @@ __wt_verbose_config(WT_SESSION_IMPL *session, const char *cfg[])
{ "shared_cache", WT_VERB_SHARED_CACHE },
{ "split", WT_VERB_SPLIT },
{ "temporary", WT_VERB_TEMPORARY },
+ { "thread_group", WT_VERB_THREAD_GROUP },
{ "transaction", WT_VERB_TRANSACTION },
{ "verify", WT_VERB_VERIFY },
{ "version", WT_VERB_VERSION },
@@ -2270,8 +2271,7 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
conn->page_size = __wt_get_vm_pagesize();
/* Now that we know if verbose is configured, output the version. */
- WT_ERR(__wt_verbose(
- session, WT_VERB_VERSION, "%s", WIREDTIGER_VERSION_STRING));
+ __wt_verbose(session, WT_VERB_VERSION, "%s", WIREDTIGER_VERSION_STRING);
/*
* Open the connection, then reset the local session as the real one
diff --git a/src/third_party/wiredtiger/src/conn/conn_cache.c b/src/third_party/wiredtiger/src/conn/conn_cache.c
index e8bb7187418..ba1e0210334 100644
--- a/src/third_party/wiredtiger/src/conn/conn_cache.c
+++ b/src/third_party/wiredtiger/src/conn/conn_cache.c
@@ -18,7 +18,7 @@ __cache_config_local(WT_SESSION_IMPL *session, bool shared, const char *cfg[])
WT_CACHE *cache;
WT_CONFIG_ITEM cval;
WT_CONNECTION_IMPL *conn;
- uint32_t evict_workers_max, evict_workers_min;
+ uint32_t evict_threads_max, evict_threads_min;
conn = S2C(session);
cache = conn->cache;
@@ -48,25 +48,20 @@ __cache_config_local(WT_SESSION_IMPL *session, bool shared, const char *cfg[])
WT_RET(__wt_config_gets(session, cfg, "eviction_dirty_trigger", &cval));
cache->eviction_dirty_trigger = (u_int)cval.val;
- /*
- * The eviction thread configuration options include the main eviction
- * thread and workers. Our implementation splits them out. Adjust for
- * the difference when parsing the configuration.
- */
WT_RET(__wt_config_gets(session, cfg, "eviction.threads_max", &cval));
WT_ASSERT(session, cval.val > 0);
- evict_workers_max = (uint32_t)cval.val - 1;
+ evict_threads_max = (uint32_t)cval.val;
WT_RET(__wt_config_gets(session, cfg, "eviction.threads_min", &cval));
WT_ASSERT(session, cval.val > 0);
- evict_workers_min = (uint32_t)cval.val - 1;
+ evict_threads_min = (uint32_t)cval.val;
- if (evict_workers_min > evict_workers_max)
+ if (evict_threads_min > evict_threads_max)
WT_RET_MSG(session, EINVAL,
"eviction=(threads_min) cannot be greater than "
"eviction=(threads_max)");
- conn->evict_workers_max = evict_workers_max;
- conn->evict_workers_min = evict_workers_min;
+ conn->evict_threads_max = evict_threads_max;
+ conn->evict_threads_min = evict_threads_min;
return (0);
}
@@ -114,6 +109,16 @@ __wt_cache_config(WT_SESSION_IMPL *session, bool reconfigure, const char *cfg[])
WT_RET(__wt_conn_cache_pool_open(session));
}
+ /*
+ * Resize the thread group if reconfiguring, otherwise the thread group
+ * will be initialized as part of creating the cache.
+ */
+ if (reconfigure)
+ WT_RET(__wt_thread_group_resize(
+ session, &conn->evict_threads,
+ conn->evict_threads_min, conn->evict_threads_max,
+ WT_THREAD_CAN_WAIT | WT_THREAD_PANIC_FAIL));
+
return (0);
}
@@ -156,8 +161,6 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[])
WT_ERR(__wt_cond_auto_alloc(session, "cache eviction server",
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_pass_lock, "evict pass"));
WT_ERR(__wt_spin_init(session,
&cache->evict_queue_lock, "cache eviction queue"));
@@ -176,9 +179,11 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[])
&cache->evict_queues[i].evict_lock, "cache eviction"));
}
- /* Ensure there is always a non-NULL current queue. */
- cache->evict_current_queue =
- &cache->evict_queues[WT_EVICT_URGENT_QUEUE + 1];
+ /* Ensure there are always non-NULL queues. */
+ cache->evict_current_queue = cache->evict_fill_queue =
+ &cache->evict_queues[0];
+ cache->evict_other_queue = &cache->evict_queues[1];
+ cache->evict_urgent_queue = &cache->evict_queues[WT_EVICT_URGENT_QUEUE];
/*
* We get/set some values in the cache statistics (rather than have
@@ -240,7 +245,7 @@ __wt_cache_stats_update(WT_SESSION_IMPL *session)
* The number of files with active walks ~= number of hazard pointers
* in the walk session. Note: reading without locking.
*/
- if (conn->evict_session != NULL)
+ if (conn->evict_server_running)
WT_STAT_SET(session, stats, cache_eviction_walks_active,
cache->walk_session->nhazard);
}
@@ -283,7 +288,6 @@ __wt_cache_destroy(WT_SESSION_IMPL *session)
cache->pages_dirty_intl + cache->pages_dirty_leaf);
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_pass_lock);
__wt_spin_destroy(session, &cache->evict_queue_lock);
__wt_spin_destroy(session, &cache->evict_walk_lock);
diff --git a/src/third_party/wiredtiger/src/conn/conn_cache_pool.c b/src/third_party/wiredtiger/src/conn/conn_cache_pool.c
index 75ecb6b3b4a..15517f37b6a 100644
--- a/src/third_party/wiredtiger/src/conn/conn_cache_pool.c
+++ b/src/third_party/wiredtiger/src/conn/conn_cache_pool.c
@@ -108,8 +108,8 @@ __wt_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg)
"cache pool server", false, &cp->cache_pool_cond));
__wt_process.cache_pool = cp;
- WT_ERR(__wt_verbose(session,
- WT_VERB_SHARED_CACHE, "Created cache pool %s", cp->name));
+ __wt_verbose(session,
+ WT_VERB_SHARED_CACHE, "Created cache pool %s", cp->name);
} else if (!updating &&
strcmp(__wt_process.cache_pool->name, pool_name) != 0)
/* Only a single cache pool is supported. */
@@ -212,12 +212,12 @@ __wt_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg)
/* Wake up the cache pool server so any changes are noticed. */
if (updating)
- WT_ERR(__wt_cond_signal(
- session, __wt_process.cache_pool->cache_pool_cond));
+ __wt_cond_signal(
+ session, __wt_process.cache_pool->cache_pool_cond);
- WT_ERR(__wt_verbose(session, WT_VERB_SHARED_CACHE,
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
"Configured cache pool %s. Size: %" PRIu64
- ", chunk size: %" PRIu64, cp->name, cp->size, cp->chunk));
+ ", chunk size: %" PRIu64, cp->name, cp->size, cp->chunk);
F_SET(conn, WT_CONN_CACHE_POOL);
err: __wt_spin_unlock(session, &__wt_process.spinlock);
@@ -267,8 +267,8 @@ __wt_conn_cache_pool_open(WT_SESSION_IMPL *session)
TAILQ_INSERT_TAIL(&cp->cache_pool_qh, conn, cpq);
__wt_spin_unlock(session, &cp->cache_pool_lock);
- WT_RET(__wt_verbose(session, WT_VERB_SHARED_CACHE,
- "Added %s to cache pool %s", conn->home, cp->name));
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
+ "Added %s to cache pool %s", conn->home, cp->name);
/*
* Each connection participating in the cache pool starts a manager
@@ -282,7 +282,7 @@ __wt_conn_cache_pool_open(WT_SESSION_IMPL *session)
__wt_cache_pool_server, cache->cp_session));
/* Wake up the cache pool server to get our initial chunk. */
- WT_RET(__wt_cond_signal(session, cp->cache_pool_cond));
+ __wt_cond_signal(session, cp->cache_pool_cond);
return (0);
}
@@ -324,8 +324,8 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session)
* queue. We did increment the reference count, so proceed regardless.
*/
if (found) {
- WT_TRET(__wt_verbose(session, WT_VERB_SHARED_CACHE,
- "Removing %s from cache pool", entry->home));
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
+ "Removing %s from cache pool", entry->home);
TAILQ_REMOVE(&cp->cache_pool_qh, entry, cpq);
/* Give the connection's resources back to the pool. */
@@ -341,7 +341,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session)
cp_locked = false;
F_CLR(cache, WT_CACHE_POOL_RUN);
- WT_TRET(__wt_cond_signal(session, cp->cache_pool_cond));
+ __wt_cond_signal(session, cp->cache_pool_cond);
WT_TRET(__wt_thread_join(session, cache->cp_tid));
wt_session = &cache->cp_session->iface;
@@ -372,8 +372,8 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session)
}
if (!F_ISSET(cp, WT_CACHE_POOL_ACTIVE)) {
- WT_TRET(__wt_verbose(
- session, WT_VERB_SHARED_CACHE, "Destroying cache pool"));
+ __wt_verbose(
+ session, WT_VERB_SHARED_CACHE, "Destroying cache pool");
__wt_spin_lock(session, &__wt_process.spinlock);
/*
* We have been holding the pool lock - no connections could
@@ -401,8 +401,8 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session)
/* Notify other participants if we were managing */
if (F_ISSET(cache, WT_CACHE_POOL_MANAGER)) {
cp->pool_managed = 0;
- WT_TRET(__wt_verbose(session, WT_VERB_SHARED_CACHE,
- "Shutting down shared cache manager connection"));
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
+ "Shutting down shared cache manager connection");
}
}
@@ -538,14 +538,14 @@ __cache_pool_assess(WT_SESSION_IMPL *session, uint64_t *phighest)
if (cache->cp_pass_pressure > highest)
highest = cache->cp_pass_pressure;
- WT_RET(__wt_verbose(session, WT_VERB_SHARED_CACHE,
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
"Assess entry. reads: %" PRIu64 ", app evicts: %" PRIu64
", app waits: %" PRIu64 ", pressure: %" PRIu64,
- reads, app_evicts, app_waits, cache->cp_pass_pressure));
+ reads, app_evicts, app_waits, cache->cp_pass_pressure);
}
- WT_RET(__wt_verbose(session, WT_VERB_SHARED_CACHE,
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
"Highest eviction count: %" PRIu64 ", entries: %" PRIu64,
- highest, entries));
+ highest, entries);
*phighest = highest;
return (0);
@@ -577,10 +577,10 @@ __cache_pool_adjust(WT_SESSION_IMPL *session,
highest_percentile = (highest / 100) + 1;
if (WT_VERBOSE_ISSET(session, WT_VERB_SHARED_CACHE)) {
- WT_RET(__wt_verbose(session,
- WT_VERB_SHARED_CACHE, "Cache pool distribution: "));
- WT_RET(__wt_verbose(session, WT_VERB_SHARED_CACHE,
- "\t" "cache (MB), pressure, skips, busy, %% full:"));
+ __wt_verbose(session,
+ WT_VERB_SHARED_CACHE, "Cache pool distribution: ");
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
+ "\t" "cache (MB), pressure, skips, busy, %% full:");
}
for (entry = forward ? TAILQ_FIRST(&cp->cache_pool_qh) :
@@ -602,10 +602,10 @@ __cache_pool_adjust(WT_SESSION_IMPL *session,
pressure = cache->cp_pass_pressure / highest_percentile;
busy = __wt_eviction_needed(entry->default_session, &pct_full);
- WT_RET(__wt_verbose(session, WT_VERB_SHARED_CACHE,
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
"\t%5" PRIu64 ", %3" PRIu64 ", %2" PRIu32 ", %d, %2u",
entry->cache_size >> 20, pressure, cache->cp_skip_count,
- busy, pct_full));
+ busy, pct_full);
/* Allow to stabilize after changes. */
if (cache->cp_skip_count > 0 && --cache->cp_skip_count > 0)
@@ -699,9 +699,9 @@ __cache_pool_adjust(WT_SESSION_IMPL *session,
entry->cache_size -= adjustment;
cp->currently_used -= adjustment;
}
- WT_RET(__wt_verbose(session, WT_VERB_SHARED_CACHE,
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
"Allocated %s%" PRId64 " to %s",
- grow ? "" : "-", adjustment, entry->home));
+ grow ? "" : "-", adjustment, entry->home);
/*
* TODO: Add a loop waiting for connection to give up
@@ -721,7 +721,6 @@ __wt_cache_pool_server(void *arg)
{
WT_CACHE *cache;
WT_CACHE_POOL *cp;
- WT_DECL_RET;
WT_SESSION_IMPL *session;
bool forward;
@@ -734,8 +733,8 @@ __wt_cache_pool_server(void *arg)
while (F_ISSET(cp, WT_CACHE_POOL_ACTIVE) &&
F_ISSET(cache, WT_CACHE_POOL_RUN)) {
if (cp->currently_used <= cp->size)
- WT_ERR(__wt_cond_wait(session,
- cp->cache_pool_cond, WT_MILLION));
+ __wt_cond_wait(
+ session, cp->cache_pool_cond, WT_MILLION);
/*
* Re-check pool run flag - since we want to avoid getting the
@@ -748,8 +747,8 @@ __wt_cache_pool_server(void *arg)
/* Try to become the managing thread */
if (__wt_atomic_cas8(&cp->pool_managed, 0, 1)) {
F_SET(cache, WT_CACHE_POOL_MANAGER);
- WT_ERR(__wt_verbose(session, WT_VERB_SHARED_CACHE,
- "Cache pool switched manager thread"));
+ __wt_verbose(session, WT_VERB_SHARED_CACHE,
+ "Cache pool switched manager thread");
}
/*
@@ -762,8 +761,5 @@ __wt_cache_pool_server(void *arg)
}
}
- if (0) {
-err: WT_PANIC_MSG(session, ret, "cache pool manager server error");
- }
return (WT_THREAD_RET_VALUE);
}
diff --git a/src/third_party/wiredtiger/src/conn/conn_ckpt.c b/src/third_party/wiredtiger/src/conn/conn_ckpt.c
index d54c65c4767..5e9d8f70193 100644
--- a/src/third_party/wiredtiger/src/conn/conn_ckpt.c
+++ b/src/third_party/wiredtiger/src/conn/conn_ckpt.c
@@ -38,6 +38,15 @@ __ckpt_server_config(WT_SESSION_IMPL *session, const char **cfg, bool *startp)
if (conn->ckpt_usecs != 0 ||
(conn->ckpt_logsize != 0 &&
FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))) {
+ /*
+ * If checkpointing based on log data, use a minimum of the
+ * log file size. The logging subsystem has already been
+ * initialized.
+ */
+ if (conn->ckpt_logsize != 0 &&
+ FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
+ conn->ckpt_logsize = WT_MAX(
+ conn->ckpt_logsize, conn->log_file_max);
/* Checkpoints are incompatible with in-memory configuration */
WT_RET(__wt_config_gets(session, cfg, "in_memory", &cval));
if (cval.val != 0)
@@ -76,8 +85,7 @@ __ckpt_server(void *arg)
* NOTE: If the user only configured logsize, then usecs
* will be 0 and this wait won't return until signalled.
*/
- WT_ERR(
- __wt_cond_wait(session, conn->ckpt_cond, conn->ckpt_usecs));
+ __wt_cond_wait(session, conn->ckpt_cond, conn->ckpt_usecs);
/* Checkpoint the database. */
WT_ERR(wt_session->checkpoint(wt_session, NULL));
@@ -93,7 +101,7 @@ __ckpt_server(void *arg)
* signalled, do a tiny wait to clear it so we don't do
* another checkpoint immediately.
*/
- WT_ERR(__wt_cond_wait(session, conn->ckpt_cond, 1));
+ __wt_cond_wait(session, conn->ckpt_cond, 1);
}
}
@@ -191,7 +199,7 @@ __wt_checkpoint_server_destroy(WT_SESSION_IMPL *session)
F_CLR(conn, WT_CONN_SERVER_CHECKPOINT);
if (conn->ckpt_tid_set) {
- WT_TRET(__wt_cond_signal(session, conn->ckpt_cond));
+ __wt_cond_signal(session, conn->ckpt_cond);
WT_TRET(__wt_thread_join(session, conn->ckpt_tid));
conn->ckpt_tid_set = false;
}
@@ -228,7 +236,7 @@ __wt_checkpoint_signal(WT_SESSION_IMPL *session, wt_off_t logsize)
conn = S2C(session);
WT_ASSERT(session, WT_CKPT_LOGSIZE(conn));
if (logsize >= conn->ckpt_logsize && !conn->ckpt_signalled) {
- WT_RET(__wt_cond_signal(session, conn->ckpt_cond));
+ __wt_cond_signal(session, conn->ckpt_cond);
conn->ckpt_signalled = 1;
}
return (0);
diff --git a/src/third_party/wiredtiger/src/conn/conn_dhandle.c b/src/third_party/wiredtiger/src/conn/conn_dhandle.c
index f52fccc7d1c..9eb4d4a7746 100644
--- a/src/third_party/wiredtiger/src/conn/conn_dhandle.c
+++ b/src/third_party/wiredtiger/src/conn/conn_dhandle.c
@@ -12,19 +12,15 @@
* __conn_dhandle_destroy --
* Destroy a data handle.
*/
-static int
+static void
__conn_dhandle_destroy(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle)
{
- WT_DECL_RET;
-
- ret = __wt_rwlock_destroy(session, &dhandle->rwlock);
+ __wt_rwlock_destroy(session, &dhandle->rwlock);
__wt_free(session, dhandle->name);
__wt_free(session, dhandle->checkpoint);
__wt_free(session, dhandle->handle);
__wt_spin_destroy(session, &dhandle->close_lock);
__wt_overwrite_and_free(session, dhandle);
-
- return (ret);
}
/*
@@ -83,7 +79,7 @@ __conn_dhandle_alloc(WT_SESSION_IMPL *session,
*dhandlep = dhandle;
return (0);
-err: WT_TRET(__conn_dhandle_destroy(session, dhandle));
+err: __conn_dhandle_destroy(session, dhandle);
return (ret);
}
@@ -576,14 +572,14 @@ __wt_conn_dhandle_discard_single(
set_pass_intr = false;
if (!F_ISSET(session, WT_SESSION_LOCKED_HANDLE_LIST)) {
set_pass_intr = true;
- (void)__wt_atomic_add32(&S2C(session)->cache->pass_intr, 1);
+ (void)__wt_atomic_addv32(&S2C(session)->cache->pass_intr, 1);
}
/* Try to remove the handle, protected by the data handle lock. */
WT_WITH_HANDLE_LIST_LOCK(session,
tret = __conn_dhandle_remove(session, final));
if (set_pass_intr)
- (void)__wt_atomic_sub32(&S2C(session)->cache->pass_intr, 1);
+ (void)__wt_atomic_subv32(&S2C(session)->cache->pass_intr, 1);
WT_TRET(tret);
/*
@@ -591,7 +587,7 @@ __wt_conn_dhandle_discard_single(
*/
if (ret == 0 || final) {
__conn_btree_config_clear(session);
- WT_TRET(__conn_dhandle_destroy(session, dhandle));
+ __conn_dhandle_destroy(session, dhandle);
session->dhandle = NULL;
}
diff --git a/src/third_party/wiredtiger/src/conn/conn_handle.c b/src/third_party/wiredtiger/src/conn/conn_handle.c
index 509966793e5..5ff8b7f798b 100644
--- a/src/third_party/wiredtiger/src/conn/conn_handle.c
+++ b/src/third_party/wiredtiger/src/conn/conn_handle.c
@@ -138,7 +138,7 @@ __wt_connection_destroy(WT_CONNECTION_IMPL *conn)
__wt_spin_destroy(session, &conn->dhandle_lock);
__wt_spin_destroy(session, &conn->encryptor_lock);
__wt_spin_destroy(session, &conn->fh_lock);
- WT_TRET(__wt_rwlock_destroy(session, &conn->hot_backup_lock));
+ __wt_rwlock_destroy(session, &conn->hot_backup_lock);
__wt_spin_destroy(session, &conn->las_lock);
__wt_spin_destroy(session, &conn->metadata_lock);
__wt_spin_destroy(session, &conn->reconfig_lock);
diff --git a/src/third_party/wiredtiger/src/conn/conn_log.c b/src/third_party/wiredtiger/src/conn/conn_log.c
index 18ed71e4688..6c05376f9ce 100644
--- a/src/third_party/wiredtiger/src/conn/conn_log.c
+++ b/src/third_party/wiredtiger/src/conn/conn_log.c
@@ -173,7 +173,7 @@ __logmgr_config(
WT_RET(__logmgr_sync_cfg(session, cfg));
if (conn->log_cond != NULL)
- WT_RET(__wt_cond_auto_signal(session, conn->log_cond));
+ __wt_cond_auto_signal(session, conn->log_cond);
return (0);
}
@@ -222,8 +222,8 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
else
min_lognum = WT_MIN(
log->ckpt_lsn.l.file, log->sync_lsn.l.file);
- WT_RET(__wt_verbose(session, WT_VERB_LOG,
- "log_archive: archive to log number %" PRIu32, min_lognum));
+ __wt_verbose(session, WT_VERB_LOG,
+ "log_archive: archive to log number %" PRIu32, min_lognum);
/*
* Main archive code. Get the list of all log files and
@@ -236,7 +236,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
* We can only archive files if a hot backup is not in progress or
* if we are the backup.
*/
- WT_ERR(__wt_readlock(session, conn->hot_backup_lock));
+ __wt_readlock(session, conn->hot_backup_lock);
locked = true;
if (!conn->hot_backup || backup_file != 0) {
for (i = 0; i < logcount; i++) {
@@ -247,7 +247,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
session, WT_LOG_FILENAME, lognum));
}
}
- WT_ERR(__wt_readunlock(session, conn->hot_backup_lock));
+ __wt_readunlock(session, conn->hot_backup_lock);
locked = false;
/*
@@ -259,7 +259,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
if (0)
err: __wt_err(session, ret, "log archive server error");
if (locked)
- WT_TRET(__wt_readunlock(session, conn->hot_backup_lock));
+ __wt_readunlock(session, conn->hot_backup_lock);
WT_TRET(__wt_fs_directory_list_free(session, &logfiles, logcount));
return (ret);
}
@@ -295,9 +295,9 @@ __log_prealloc_once(WT_SESSION_IMPL *session)
*/
if (log->prep_missed > 0) {
conn->log_prealloc += log->prep_missed;
- WT_ERR(__wt_verbose(session, WT_VERB_LOG,
+ __wt_verbose(session, WT_VERB_LOG,
"Missed %" PRIu32 ". Now pre-allocating up to %" PRIu32,
- log->prep_missed, conn->log_prealloc));
+ log->prep_missed, conn->log_prealloc);
}
WT_STAT_FAST_CONN_SET(session, log_prealloc_max, conn->log_prealloc);
/*
@@ -335,7 +335,6 @@ __wt_log_truncate_files(
WT_DECL_RET;
WT_LOG *log;
uint32_t backup_file;
- bool locked;
WT_UNUSED(cfg);
conn = S2C(session);
@@ -352,18 +351,12 @@ __wt_log_truncate_files(
if (cursor != NULL)
backup_file = WT_CURSOR_BACKUP_ID(cursor);
WT_ASSERT(session, backup_file <= log->alloc_lsn.l.file);
- WT_RET(__wt_verbose(session, WT_VERB_LOG,
- "log_truncate_files: Archive once up to %" PRIu32,
- backup_file));
+ __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));
- WT_ERR(__wt_writeunlock(session, log->log_archive_lock));
- locked = false;
-err:
- if (locked)
- WT_RET(__wt_writeunlock(session, log->log_archive_lock));
+ __wt_writelock(session, log->log_archive_lock);
+ ret = __log_archive_once(session, backup_file);
+ __wt_writeunlock(session, log->log_archive_lock);
return (ret);
}
@@ -429,12 +422,14 @@ __log_file_server(void *arg)
*/
WT_ERR(__wt_fsync(session, close_fh, true));
/*
- * We want to make sure the file size reflects
- * actual data and has minimal pre-allocated
- * zeroed space.
+ * We want to have the file size reflect actual
+ * data with minimal pre-allocated zeroed space.
+ * The underlying file system may not support
+ * truncate, which is OK, it's just more work
+ * during cursor traversal.
*/
- WT_ERR(__wt_ftruncate(session,
- close_fh, close_end_lsn.l.offset));
+ WT_ERR_ERROR_OK(__wt_ftruncate(session,
+ close_fh, close_end_lsn.l.offset), ENOTSUP);
WT_SET_LSN(&close_end_lsn,
close_end_lsn.l.file + 1, 0);
__wt_spin_lock(session, &log->log_sync_lock);
@@ -443,8 +438,7 @@ __log_file_server(void *arg)
WT_ASSERT(session, __wt_log_cmp(
&close_end_lsn, &log->sync_lsn) >= 0);
log->sync_lsn = close_end_lsn;
- WT_ERR(__wt_cond_signal(
- session, log->log_sync_cond));
+ __wt_cond_signal(session, log->log_sync_cond);
locked = false;
__wt_spin_unlock(session, &log->log_sync_lock);
}
@@ -492,14 +486,14 @@ __log_file_server(void *arg)
min_lsn.l.file ==
log->sync_lsn.l.file);
log->sync_lsn = min_lsn;
- WT_ERR(__wt_cond_signal(
- session, log->log_sync_cond));
+ __wt_cond_signal(
+ session, log->log_sync_cond);
}
locked = false;
__wt_spin_unlock(session, &log->log_sync_lock);
} else {
- WT_ERR(__wt_cond_auto_signal(
- session, conn->log_wrlsn_cond));
+ __wt_cond_auto_signal(
+ session, conn->log_wrlsn_cond);
/*
* We do not want to wait potentially a second
* to process this. Yield to give the wrlsn
@@ -511,8 +505,7 @@ __log_file_server(void *arg)
}
}
/* Wait until the next event. */
- WT_ERR(__wt_cond_wait(
- session, conn->log_file_cond, WT_MILLION / 10));
+ __wt_cond_wait(session, conn->log_file_cond, WT_MILLION / 10);
}
if (0) {
@@ -546,11 +539,10 @@ typedef struct {
* are contiguous. The purpose of this function is to advance the
* write_lsn in LSN order after the buffer is written to the log file.
*/
-int
+void
__wt_log_wrlsn(WT_SESSION_IMPL *session, int *yield)
{
WT_CONNECTION_IMPL *conn;
- WT_DECL_RET;
WT_LOG *log;
WT_LOG_WRLSN_ENTRY written[WT_SLOT_POOL];
WT_LOGSLOT *coalescing, *slot;
@@ -669,21 +661,19 @@ restart:
(uint32_t)slot->slot_last_offset;
log->write_start_lsn = slot->slot_start_lsn;
log->write_lsn = slot->slot_end_lsn;
- WT_ERR(__wt_cond_signal(
- session, log->log_write_cond));
+ __wt_cond_signal(session, log->log_write_cond);
WT_STAT_FAST_CONN_INCR(session, log_write_lsn);
/*
* Signal the close thread if needed.
*/
if (F_ISSET(slot, WT_SLOT_CLOSEFH))
- WT_ERR(__wt_cond_signal(
- session, conn->log_file_cond));
+ __wt_cond_signal(
+ session, conn->log_file_cond);
}
__wt_log_slot_free(session, slot);
}
}
-err: __wt_spin_unlock(session, &log->log_writelsn_lock);
- return (ret);
+ __wt_spin_unlock(session, &log->log_writelsn_lock);
}
/*
@@ -716,7 +706,7 @@ __log_wrlsn_server(void *arg)
*/
if (__wt_log_cmp(&prev, &log->alloc_lsn) != 0 ||
__wt_log_cmp(&log->write_lsn, &log->alloc_lsn) != 0)
- WT_ERR(__wt_log_wrlsn(session, &yield));
+ __wt_log_wrlsn(session, &yield);
else
WT_STAT_FAST_CONN_INCR(session, log_write_lsn_skip);
prev = log->alloc_lsn;
@@ -732,15 +722,15 @@ __log_wrlsn_server(void *arg)
* Send in false because if we did any work we would
* not be on this path.
*/
- WT_ERR(__wt_cond_auto_wait(
- session, conn->log_wrlsn_cond, did_work));
+ __wt_cond_auto_wait(
+ session, conn->log_wrlsn_cond, did_work);
}
/*
* On close we need to do this one more time because there could
* be straggling log writes that need to be written.
*/
WT_ERR(__wt_log_force_write(session, 1, NULL));
- WT_ERR(__wt_log_wrlsn(session, NULL));
+ __wt_log_wrlsn(session, NULL);
if (0) {
err: __wt_err(session, ret, "log wrlsn server error");
}
@@ -760,12 +750,12 @@ __log_server(void *arg)
WT_LOG *log;
WT_SESSION_IMPL *session;
uint64_t timediff;
- bool did_work, locked, signalled;
+ bool did_work, signalled;
session = arg;
conn = S2C(session);
log = conn->log;
- locked = signalled = false;
+ signalled = false;
/*
* Set this to the number of milliseconds we want to run archive and
@@ -812,14 +802,11 @@ __log_server(void *arg)
* agreed not to rename or remove any files in
* the database directory.
*/
- WT_ERR(__wt_readlock(
- session, conn->hot_backup_lock));
- locked = true;
+ __wt_readlock(session, conn->hot_backup_lock);
if (!conn->hot_backup)
- WT_ERR(__log_prealloc_once(session));
- WT_ERR(__wt_readunlock(
- session, conn->hot_backup_lock));
- locked = false;
+ ret = __log_prealloc_once(session);
+ __wt_readunlock(session, conn->hot_backup_lock);
+ WT_ERR(ret);
}
/*
@@ -829,31 +816,27 @@ __log_server(void *arg)
if (__wt_try_writelock(
session, log->log_archive_lock) == 0) {
ret = __log_archive_once(session, 0);
- WT_TRET(__wt_writeunlock(
- session, log->log_archive_lock));
+ __wt_writeunlock(
+ session, log->log_archive_lock);
WT_ERR(ret);
} else
- WT_ERR(
- __wt_verbose(session, WT_VERB_LOG,
+ __wt_verbose(session, WT_VERB_LOG,
"log_archive: Blocked due to open "
- "log cursor holding archive lock"));
+ "log cursor holding archive lock");
}
}
/* Wait until the next event. */
WT_ERR(__wt_epoch(session, &start));
- WT_ERR(__wt_cond_auto_wait_signal(session, conn->log_cond,
- did_work, &signalled));
+ __wt_cond_auto_wait_signal(session,
+ conn->log_cond, did_work, &signalled);
WT_ERR(__wt_epoch(session, &now));
timediff = WT_TIMEDIFF_MS(now, start);
}
if (0) {
err: __wt_err(session, ret, "log server error");
- if (locked)
- WT_TRET(__wt_readunlock(
- session, conn->hot_backup_lock));
}
return (WT_THREAD_RET_VALUE);
}
@@ -974,7 +957,7 @@ __wt_logmgr_open(WT_SESSION_IMPL *session)
if (conn->log_session != NULL) {
WT_ASSERT(session, conn->log_cond != NULL);
WT_ASSERT(session, conn->log_tid_set == true);
- WT_RET(__wt_cond_auto_signal(session, conn->log_cond));
+ __wt_cond_auto_signal(session, conn->log_cond);
} else {
/* The log server gets its own session. */
WT_RET(__wt_open_internal_session(conn,
@@ -1016,12 +999,12 @@ __wt_logmgr_destroy(WT_SESSION_IMPL *session)
return (0);
}
if (conn->log_tid_set) {
- WT_TRET(__wt_cond_auto_signal(session, conn->log_cond));
+ __wt_cond_auto_signal(session, conn->log_cond);
WT_TRET(__wt_thread_join(session, conn->log_tid));
conn->log_tid_set = false;
}
if (conn->log_file_tid_set) {
- WT_TRET(__wt_cond_signal(session, conn->log_file_cond));
+ __wt_cond_signal(session, conn->log_file_cond);
WT_TRET(__wt_thread_join(session, conn->log_file_tid));
conn->log_file_tid_set = false;
}
@@ -1031,7 +1014,7 @@ __wt_logmgr_destroy(WT_SESSION_IMPL *session)
conn->log_file_session = NULL;
}
if (conn->log_wrlsn_tid_set) {
- WT_TRET(__wt_cond_auto_signal(session, conn->log_wrlsn_cond));
+ __wt_cond_auto_signal(session, conn->log_wrlsn_cond);
WT_TRET(__wt_thread_join(session, conn->log_wrlsn_tid));
conn->log_wrlsn_tid_set = false;
}
@@ -1058,7 +1041,7 @@ __wt_logmgr_destroy(WT_SESSION_IMPL *session)
WT_TRET(__wt_cond_destroy(session, &conn->log->log_sync_cond));
WT_TRET(__wt_cond_destroy(session, &conn->log->log_write_cond));
- WT_TRET(__wt_rwlock_destroy(session, &conn->log->log_archive_lock));
+ __wt_rwlock_destroy(session, &conn->log->log_archive_lock);
__wt_spin_destroy(session, &conn->log->log_lock);
__wt_spin_destroy(session, &conn->log->log_slot_lock);
__wt_spin_destroy(session, &conn->log->log_sync_lock);
diff --git a/src/third_party/wiredtiger/src/conn/conn_open.c b/src/third_party/wiredtiger/src/conn/conn_open.c
index 9c978fed843..69b50147bf5 100644
--- a/src/third_party/wiredtiger/src/conn/conn_open.c
+++ b/src/third_party/wiredtiger/src/conn/conn_open.c
@@ -157,7 +157,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn)
WT_TRET(__wt_cache_destroy(session));
/* Discard transaction state. */
- WT_TRET(__wt_txn_global_destroy(session));
+ __wt_txn_global_destroy(session);
/* Close extensions, first calling any unload entry point. */
while ((dlh = TAILQ_FIRST(&conn->dlhqh)) != NULL) {
@@ -186,27 +186,18 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn)
}
/*
- * The session's split stash isn't discarded during normal session close
- * because it may persist past the life of the session. Discard it now.
+ * The session split stash, hazard information and handle arrays aren't
+ * discarded during normal session close, they persist past the life of
+ * the session. Discard them now.
*/
- if ((s = conn->sessions) != NULL)
- for (i = 0; i < conn->session_size; ++s, ++i)
- __wt_split_stash_discard_all(session, s);
-
- /*
- * The session's hazard pointer memory isn't discarded during normal
- * session close because access to it isn't serialized. Discard it
- * now.
- */
- if ((s = conn->sessions) != NULL)
- for (i = 0; i < conn->session_size; ++s, ++i) {
- /*
- * If hash arrays were allocated, free them now.
- */
- __wt_free(session, s->dhhash);
- __wt_free(session, s->tablehash);
- __wt_free(session, s->hazard);
- }
+ if (!F_ISSET(conn, WT_CONN_LEAK_MEMORY))
+ if ((s = conn->sessions) != NULL)
+ for (i = 0; i < conn->session_size; ++s, ++i) {
+ __wt_free(session, s->dhhash);
+ __wt_free(session, s->tablehash);
+ __wt_split_stash_discard_all(session, s);
+ __wt_free(session, s->hazard);
+ }
/* Destroy the handle. */
WT_TRET(__wt_connection_destroy(conn));
diff --git a/src/third_party/wiredtiger/src/conn/conn_stat.c b/src/third_party/wiredtiger/src/conn/conn_stat.c
index 4e7cac59c4a..0894d1c6058 100644
--- a/src/third_party/wiredtiger/src/conn/conn_stat.c
+++ b/src/third_party/wiredtiger/src/conn/conn_stat.c
@@ -528,8 +528,7 @@ __statlog_server(void *arg)
while (F_ISSET(conn, WT_CONN_SERVER_RUN) &&
F_ISSET(conn, WT_CONN_SERVER_STATISTICS)) {
/* Wait until the next event. */
- WT_ERR(
- __wt_cond_wait(session, conn->stat_cond, conn->stat_usecs));
+ __wt_cond_wait(session, conn->stat_cond, conn->stat_usecs);
if (!FLD_ISSET(conn->stat_flags, WT_CONN_STAT_NONE))
WT_ERR(__statlog_log_one(session, &path, &tmp));
@@ -636,7 +635,7 @@ __wt_statlog_destroy(WT_SESSION_IMPL *session, bool is_close)
/* Stop the server thread. */
F_CLR(conn, WT_CONN_SERVER_STATISTICS);
if (conn->stat_tid_set) {
- WT_TRET(__wt_cond_signal(session, conn->stat_cond));
+ __wt_cond_signal(session, conn->stat_cond);
WT_TRET(__wt_thread_join(session, conn->stat_tid));
conn->stat_tid_set = false;
}
diff --git a/src/third_party/wiredtiger/src/conn/conn_sweep.c b/src/third_party/wiredtiger/src/conn/conn_sweep.c
index 5d24ea61607..dda296f50f3 100644
--- a/src/third_party/wiredtiger/src/conn/conn_sweep.c
+++ b/src/third_party/wiredtiger/src/conn/conn_sweep.c
@@ -97,7 +97,7 @@ __sweep_expire_one(WT_SESSION_IMPL *session)
*/
ret = __wt_conn_btree_sync_and_close(session, false, true);
-err: WT_TRET(__wt_writeunlock(session, dhandle->rwlock));
+err: __wt_writeunlock(session, dhandle->rwlock);
return (ret);
}
@@ -207,7 +207,7 @@ __sweep_remove_one(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle)
* don't retry the discard until it times out again.
*/
if (ret != 0) {
-err: WT_TRET(__wt_writeunlock(session, dhandle->rwlock));
+err: __wt_writeunlock(session, dhandle->rwlock);
}
return (ret);
@@ -258,10 +258,12 @@ __sweep_server(void *arg)
WT_DECL_RET;
WT_SESSION_IMPL *session;
time_t now;
+ uint64_t last_las_sweep_id, oldest_id;
u_int dead_handles;
session = arg;
conn = S2C(session);
+ last_las_sweep_id = WT_TXN_NONE;
/*
* Sweep for dead and excess handles.
@@ -269,8 +271,8 @@ __sweep_server(void *arg)
while (F_ISSET(conn, WT_CONN_SERVER_RUN) &&
F_ISSET(conn, WT_CONN_SERVER_SWEEP)) {
/* Wait until the next event. */
- WT_ERR(__wt_cond_wait(session,
- conn->sweep_cond, conn->sweep_interval * WT_MILLION));
+ __wt_cond_wait(session,
+ conn->sweep_cond, conn->sweep_interval * WT_MILLION);
WT_ERR(__wt_seconds(session, &now));
WT_STAT_FAST_CONN_INCR(session, dh_sweeps);
@@ -278,9 +280,22 @@ __sweep_server(void *arg)
/*
* Sweep the lookaside table. If the lookaside table hasn't yet
* been written, there's no work to do.
+ *
+ * Don't sweep the lookaside table if the cache is stuck full.
+ * The sweep uses the cache and can exacerbate the problem.
+ * If we try to sweep when the cache is full or we aren't
+ * making progress in eviction, sweeping can wind up constantly
+ * bringing in and evicting pages from the lookaside table,
+ * which will stop the WT_CACHE_STUCK flag from being set.
*/
- if (__wt_las_is_written(session))
- WT_ERR(__wt_las_sweep(session));
+ if (__wt_las_is_written(session) &&
+ !F_ISSET(conn->cache, WT_CACHE_STUCK)) {
+ oldest_id = __wt_txn_oldest_id(session);
+ if (WT_TXNID_LT(last_las_sweep_id, oldest_id)) {
+ WT_ERR(__wt_las_sweep(session));
+ last_las_sweep_id = oldest_id;
+ }
+ }
/*
* Mark handles with a time of death, and report whether any
@@ -401,7 +416,7 @@ __wt_sweep_destroy(WT_SESSION_IMPL *session)
F_CLR(conn, WT_CONN_SERVER_SWEEP);
if (conn->sweep_tid_set) {
- WT_TRET(__wt_cond_signal(session, conn->sweep_cond));
+ __wt_cond_signal(session, conn->sweep_cond);
WT_TRET(__wt_thread_join(session, conn->sweep_tid));
conn->sweep_tid_set = 0;
}