summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2018-03-09 10:33:07 +1100
committerLuke Chen <luke.chen@mongodb.com>2018-03-09 10:33:07 +1100
commite54d2ce84bb9f1285228e75b63b7ef4e555601e6 (patch)
tree3b6e4c97f329d04bfc507bc27cf411accf80d147
parent64bbe539d70881b6f72cc7d8714432c532756e5a (diff)
downloadmongo-e54d2ce84bb9f1285228e75b63b7ef4e555601e6.tar.gz
Import wiredtiger: 0b36171f4aa0bea6ab6118b0d3bcf6329a24939e from branch mongodb-3.4
ref: e5e5c131d6..0b36171f4a for: 3.4.14 WT-3245 Avoid hangs on shutdown when a utility thread encounters an error WT-3904 Reconsider error path in log server thread WT-3938 Reduce memory usage with many tables and sessions WT-3946 Truncate segfault with a NULL start cursor WT-3962 WiredTiger turtle file "MoveFileExW: Access is denied." error.
-rw-r--r--src/third_party/wiredtiger/dist/api_data.py3
-rw-r--r--src/third_party/wiredtiger/dist/flags.py1
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/async/async_worker.c5
-rw-r--r--src/third_party/wiredtiger/src/config/config_def.c46
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_api.c3
-rw-r--r--src/third_party/wiredtiger/src/conn/conn_log.c29
-rw-r--r--src/third_party/wiredtiger/src/cursor/cur_index.c4
-rw-r--r--src/third_party/wiredtiger/src/cursor/cur_join.c2
-rw-r--r--src/third_party/wiredtiger/src/cursor/cur_table.c4
-rw-r--r--src/third_party/wiredtiger/src/evict/evict_lru.c2
-rw-r--r--src/third_party/wiredtiger/src/include/extern.h2
-rw-r--r--src/third_party/wiredtiger/src/include/flags.h3
-rw-r--r--src/third_party/wiredtiger/src/include/os.h4
-rw-r--r--src/third_party/wiredtiger/src/include/wiredtiger.in2
-rw-r--r--src/third_party/wiredtiger/src/meta/meta_table.c4
-rw-r--r--src/third_party/wiredtiger/src/meta/meta_turtle.c6
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_alter.c13
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_create.c6
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_drop.c4
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_list.c24
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_open.c29
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_rename.c2
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_stat.c11
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_truncate.c2
-rw-r--r--src/third_party/wiredtiger/src/schema/schema_worker.c9
-rw-r--r--src/third_party/wiredtiger/src/session/session_api.c13
27 files changed, 150 insertions, 85 deletions
diff --git a/src/third_party/wiredtiger/dist/api_data.py b/src/third_party/wiredtiger/dist/api_data.py
index 22600dd5e29..596099647be 100644
--- a/src/third_party/wiredtiger/dist/api_data.py
+++ b/src/third_party/wiredtiger/dist/api_data.py
@@ -753,6 +753,9 @@ wiredtiger_open_common =\
Config('session_scratch_max', '2MB', r'''
maximum memory to cache in each session''',
type='int', undoc=True),
+ Config('session_table_cache', 'true', r'''
+ Maintain a per-session cache of tables''',
+ type='boolean'),
Config('transaction_sync', '', r'''
how to sync log records when the transaction commits''',
type='category', subconfig=[
diff --git a/src/third_party/wiredtiger/dist/flags.py b/src/third_party/wiredtiger/dist/flags.py
index d80c80a37ce..1ce717f3586 100644
--- a/src/third_party/wiredtiger/dist/flags.py
+++ b/src/third_party/wiredtiger/dist/flags.py
@@ -110,6 +110,7 @@ flags = {
'CONN_SERVER_LSM',
'CONN_SERVER_STATISTICS',
'CONN_SERVER_SWEEP',
+ 'CONN_TABLE_CACHE',
'CONN_WAS_BACKUP',
],
'session' : [
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 966202ac5a9..e867147e59e 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -1,5 +1,5 @@
{
- "commit": "e5e5c131d6f37efa82aae2848d98f5ddc3fe0126",
+ "commit": "0b36171f4aa0bea6ab6118b0d3bcf6329a24939e",
"github": "wiredtiger/wiredtiger.git",
"vendor": "wiredtiger",
"branch": "mongodb-3.4"
diff --git a/src/third_party/wiredtiger/src/async/async_worker.c b/src/third_party/wiredtiger/src/async/async_worker.c
index 11f59ed14f1..89877652f1e 100644
--- a/src/third_party/wiredtiger/src/async/async_worker.c
+++ b/src/third_party/wiredtiger/src/async/async_worker.c
@@ -301,11 +301,10 @@ __wt_async_worker(void *arg)
WT_ERR(__async_op_dequeue(conn, session, &op));
if (op != NULL && op != &async->flush_op) {
/*
- * If an operation fails, we want the worker thread to
- * keep running, unless there is a panic.
+ * Operation failure doesn't cause the worker thread to
+ * exit.
*/
(void)__async_worker_op(session, op, &worker);
- WT_ERR(WT_SESSION_CHECK_PANIC(session));
} else if (async->flush_state == WT_ASYNC_FLUSHING) {
/*
* Worker flushing going on. Last worker to the party
diff --git a/src/third_party/wiredtiger/src/config/config_def.c b/src/third_party/wiredtiger/src/config/config_def.c
index f152fbacad4..c8a8c525751 100644
--- a/src/third_party/wiredtiger/src/config/config_def.c
+++ b/src/third_party/wiredtiger/src/config/config_def.c
@@ -733,6 +733,7 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open[] = {
{ "readonly", "boolean", NULL, NULL, NULL, 0 },
{ "session_max", "int", NULL, "min=1", NULL, 0 },
{ "session_scratch_max", "int", NULL, NULL, NULL, 0 },
+ { "session_table_cache", "boolean", NULL, NULL, NULL, 0 },
{ "shared_cache", "category",
NULL, NULL,
confchk_wiredtiger_open_shared_cache_subconfigs, 5 },
@@ -820,6 +821,7 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open_all[] = {
{ "readonly", "boolean", NULL, NULL, NULL, 0 },
{ "session_max", "int", NULL, "min=1", NULL, 0 },
{ "session_scratch_max", "int", NULL, NULL, NULL, 0 },
+ { "session_table_cache", "boolean", NULL, NULL, NULL, 0 },
{ "shared_cache", "category",
NULL, NULL,
confchk_wiredtiger_open_shared_cache_subconfigs, 5 },
@@ -904,6 +906,7 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open_basecfg[] = {
{ "readonly", "boolean", NULL, NULL, NULL, 0 },
{ "session_max", "int", NULL, "min=1", NULL, 0 },
{ "session_scratch_max", "int", NULL, NULL, NULL, 0 },
+ { "session_table_cache", "boolean", NULL, NULL, NULL, 0 },
{ "shared_cache", "category",
NULL, NULL,
confchk_wiredtiger_open_shared_cache_subconfigs, 5 },
@@ -986,6 +989,7 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open_usercfg[] = {
{ "readonly", "boolean", NULL, NULL, NULL, 0 },
{ "session_max", "int", NULL, "min=1", NULL, 0 },
{ "session_scratch_max", "int", NULL, NULL, NULL, 0 },
+ { "session_table_cache", "boolean", NULL, NULL, NULL, 0 },
{ "shared_cache", "category",
NULL, NULL,
confchk_wiredtiger_open_shared_cache_subconfigs, 5 },
@@ -1276,14 +1280,14 @@ static const WT_CONFIG_ENTRY config_entries[] = {
"file_max=100MB,path=\".\",prealloc=true,recover=on,"
"zero_fill=false),lsm_manager=(merge=true,worker_thread_max=4),"
"lsm_merge=true,mmap=true,multiprocess=false,readonly=false,"
- "session_max=100,session_scratch_max=2MB,shared_cache=(chunk=10MB"
- ",name=,quota=0,reserve=0,size=500MB),statistics=none,"
- "statistics_log=(json=false,on_close=false,path=\".\",sources=,"
- "timestamp=\"%b %d %H:%M:%S\",wait=0),"
+ "session_max=100,session_scratch_max=2MB,session_table_cache=true"
+ ",shared_cache=(chunk=10MB,name=,quota=0,reserve=0,size=500MB),"
+ "statistics=none,statistics_log=(json=false,on_close=false,"
+ "path=\".\",sources=,timestamp=\"%b %d %H:%M:%S\",wait=0),"
"transaction_sync=(enabled=false,method=fsync),"
"use_environment=true,use_environment_priv=false,verbose=,"
"write_through=",
- confchk_wiredtiger_open, 40
+ confchk_wiredtiger_open, 41
},
{ "wiredtiger_open_all",
"async=(enabled=false,ops_max=1024,threads=2),buffer_alignment=-1"
@@ -1300,14 +1304,14 @@ static const WT_CONFIG_ENTRY config_entries[] = {
"file_max=100MB,path=\".\",prealloc=true,recover=on,"
"zero_fill=false),lsm_manager=(merge=true,worker_thread_max=4),"
"lsm_merge=true,mmap=true,multiprocess=false,readonly=false,"
- "session_max=100,session_scratch_max=2MB,shared_cache=(chunk=10MB"
- ",name=,quota=0,reserve=0,size=500MB),statistics=none,"
- "statistics_log=(json=false,on_close=false,path=\".\",sources=,"
- "timestamp=\"%b %d %H:%M:%S\",wait=0),"
+ "session_max=100,session_scratch_max=2MB,session_table_cache=true"
+ ",shared_cache=(chunk=10MB,name=,quota=0,reserve=0,size=500MB),"
+ "statistics=none,statistics_log=(json=false,on_close=false,"
+ "path=\".\",sources=,timestamp=\"%b %d %H:%M:%S\",wait=0),"
"transaction_sync=(enabled=false,method=fsync),"
"use_environment=true,use_environment_priv=false,verbose=,"
"version=(major=0,minor=0),write_through=",
- confchk_wiredtiger_open_all, 41
+ confchk_wiredtiger_open_all, 42
},
{ "wiredtiger_open_basecfg",
"async=(enabled=false,ops_max=1024,threads=2),buffer_alignment=-1"
@@ -1323,12 +1327,13 @@ static const WT_CONFIG_ENTRY config_entries[] = {
"path=\".\",prealloc=true,recover=on,zero_fill=false),"
"lsm_manager=(merge=true,worker_thread_max=4),lsm_merge=true,"
"mmap=true,multiprocess=false,readonly=false,session_max=100,"
- "session_scratch_max=2MB,shared_cache=(chunk=10MB,name=,quota=0,"
- "reserve=0,size=500MB),statistics=none,statistics_log=(json=false"
- ",on_close=false,path=\".\",sources=,timestamp=\"%b %d %H:%M:%S\""
- ",wait=0),transaction_sync=(enabled=false,method=fsync),verbose=,"
+ "session_scratch_max=2MB,session_table_cache=true,"
+ "shared_cache=(chunk=10MB,name=,quota=0,reserve=0,size=500MB),"
+ "statistics=none,statistics_log=(json=false,on_close=false,"
+ "path=\".\",sources=,timestamp=\"%b %d %H:%M:%S\",wait=0),"
+ "transaction_sync=(enabled=false,method=fsync),verbose=,"
"version=(major=0,minor=0),write_through=",
- confchk_wiredtiger_open_basecfg, 35
+ confchk_wiredtiger_open_basecfg, 36
},
{ "wiredtiger_open_usercfg",
"async=(enabled=false,ops_max=1024,threads=2),buffer_alignment=-1"
@@ -1344,12 +1349,13 @@ static const WT_CONFIG_ENTRY config_entries[] = {
"path=\".\",prealloc=true,recover=on,zero_fill=false),"
"lsm_manager=(merge=true,worker_thread_max=4),lsm_merge=true,"
"mmap=true,multiprocess=false,readonly=false,session_max=100,"
- "session_scratch_max=2MB,shared_cache=(chunk=10MB,name=,quota=0,"
- "reserve=0,size=500MB),statistics=none,statistics_log=(json=false"
- ",on_close=false,path=\".\",sources=,timestamp=\"%b %d %H:%M:%S\""
- ",wait=0),transaction_sync=(enabled=false,method=fsync),verbose=,"
+ "session_scratch_max=2MB,session_table_cache=true,"
+ "shared_cache=(chunk=10MB,name=,quota=0,reserve=0,size=500MB),"
+ "statistics=none,statistics_log=(json=false,on_close=false,"
+ "path=\".\",sources=,timestamp=\"%b %d %H:%M:%S\",wait=0),"
+ "transaction_sync=(enabled=false,method=fsync),verbose=,"
"write_through=",
- confchk_wiredtiger_open_usercfg, 34
+ confchk_wiredtiger_open_usercfg, 35
},
{ NULL, NULL, NULL, 0 }
};
diff --git a/src/third_party/wiredtiger/src/conn/conn_api.c b/src/third_party/wiredtiger/src/conn/conn_api.c
index 4e8b4348a8e..103e4a68f04 100644
--- a/src/third_party/wiredtiger/src/conn/conn_api.c
+++ b/src/third_party/wiredtiger/src/conn/conn_api.c
@@ -2220,6 +2220,9 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler,
WT_ERR(__wt_config_gets(session, cfg, "readonly", &cval));
if (cval.val)
F_SET(conn, WT_CONN_READONLY);
+ WT_ERR(__wt_config_gets(session, cfg, "session_table_cache", &cval));
+ if (cval.val)
+ F_SET(conn, WT_CONN_TABLE_CACHE);
/* Configure error messages so we get them right early. */
WT_ERR(__wt_config_gets(session, cfg, "error_prefix", &cval));
diff --git a/src/third_party/wiredtiger/src/conn/conn_log.c b/src/third_party/wiredtiger/src/conn/conn_log.c
index bee1b0443f5..8b47d3b04c0 100644
--- a/src/third_party/wiredtiger/src/conn/conn_log.c
+++ b/src/third_party/wiredtiger/src/conn/conn_log.c
@@ -525,7 +525,7 @@ __log_file_server(void *arg)
}
if (0) {
-err: __wt_err(session, ret, "log close server error");
+err: WT_PANIC_MSG(session, ret, "log close server error");
}
WT_STAT_CONN_INCRV(session, log_server_sync_blocked, yield_count);
if (locked)
@@ -744,7 +744,8 @@ __log_wrlsn_server(void *arg)
WT_ERR(__wt_log_force_write(session, 1, NULL));
__wt_log_wrlsn(session, NULL);
if (0) {
-err: __wt_err(session, ret, "log wrlsn server error");
+err: WT_PANIC_MSG(session, ret, "log wrlsn server error");
+
}
return (WT_THREAD_RET_VALUE);
}
@@ -761,7 +762,7 @@ __log_server(void *arg)
WT_DECL_RET;
WT_LOG *log;
WT_SESSION_IMPL *session;
- uint64_t timediff;
+ uint64_t retry, timediff;
bool did_work, signalled;
session = arg;
@@ -787,6 +788,7 @@ __log_server(void *arg)
* takes to sync out an earlier file.
*/
did_work = true;
+ retry = 0;
while (F_ISSET(conn, WT_CONN_SERVER_LOG)) {
/*
* Slots depend on future activity. Force out buffered
@@ -831,7 +833,24 @@ __log_server(void *arg)
ret = __log_archive_once(session, 0);
__wt_writeunlock(
session, &log->log_archive_lock);
- WT_ERR(ret);
+ /*
+ * It is possible that an external
+ * process on some systems may prevent
+ * removal. If we get a permission
+ * error, retry a few times.
+ */
+ if (ret == EACCES &&
+ retry < WT_RETRY_MAX) {
+ retry++;
+ ret = 0;
+ } else {
+ /*
+ * Return the error if there is
+ * one or reset on success.
+ */
+ WT_ERR(ret);
+ retry = 0;
+ }
} else
__wt_verbose(session, WT_VERB_LOG,
"log_archive: Blocked due to open "
@@ -848,7 +867,7 @@ __log_server(void *arg)
}
if (0) {
-err: __wt_err(session, ret, "log server error");
+err: WT_PANIC_MSG(session, ret, "log server error");
}
return (WT_THREAD_RET_VALUE);
}
diff --git a/src/third_party/wiredtiger/src/cursor/cur_index.c b/src/third_party/wiredtiger/src/cursor/cur_index.c
index 6fc01c0421f..15c1271c992 100644
--- a/src/third_party/wiredtiger/src/cursor/cur_index.c
+++ b/src/third_party/wiredtiger/src/cursor/cur_index.c
@@ -382,7 +382,7 @@ __curindex_close(WT_CURSOR *cursor)
if (cindex->child != NULL)
WT_TRET(cindex->child->close(cindex->child));
- __wt_schema_release_table(session, cindex->table);
+ WT_TRET(__wt_schema_release_table(session, cindex->table));
/* The URI is owned by the index. */
cursor->internal_uri = NULL;
WT_TRET(__wt_cursor_close(cursor));
@@ -485,7 +485,7 @@ __wt_curindex_open(WT_SESSION_IMPL *session,
if ((ret = __wt_schema_open_index(
session, table, idxname, namesize, &idx)) != 0) {
- __wt_schema_release_table(session, table);
+ WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
WT_RET(__wt_calloc_one(session, &cindex));
diff --git a/src/third_party/wiredtiger/src/cursor/cur_join.c b/src/third_party/wiredtiger/src/cursor/cur_join.c
index 80afaf798dc..3681d36b452 100644
--- a/src/third_party/wiredtiger/src/cursor/cur_join.c
+++ b/src/third_party/wiredtiger/src/cursor/cur_join.c
@@ -325,7 +325,7 @@ __curjoin_close(WT_CURSOR *cursor)
JOINABLE_CURSOR_API_CALL(cursor, session, close, NULL);
- __wt_schema_release_table(session, cjoin->table);
+ WT_TRET(__wt_schema_release_table(session, cjoin->table));
/* This is owned by the table */
cursor->key_format = NULL;
if (cjoin->projection != NULL) {
diff --git a/src/third_party/wiredtiger/src/cursor/cur_table.c b/src/third_party/wiredtiger/src/cursor/cur_table.c
index f6855172e90..ffa9ca35926 100644
--- a/src/third_party/wiredtiger/src/cursor/cur_table.c
+++ b/src/third_party/wiredtiger/src/cursor/cur_table.c
@@ -786,7 +786,7 @@ __curtable_close(WT_CURSOR *cursor)
__wt_free(session, ctable->cg_cursors);
__wt_free(session, ctable->cg_valcopy);
__wt_free(session, ctable->idx_cursors);
- __wt_schema_release_table(session, ctable->table);
+ WT_TRET(__wt_schema_release_table(session, ctable->table));
/* The URI is owned by the table. */
cursor->internal_uri = NULL;
WT_TRET(__wt_cursor_close(cursor));
@@ -942,7 +942,7 @@ __wt_curtable_open(WT_SESSION_IMPL *session,
ret = __wt_open_cursor(session,
table->cgroups[0]->source, NULL, cfg, cursorp);
- __wt_schema_release_table(session, table);
+ WT_TRET(__wt_schema_release_table(session, table));
if (ret == 0) {
/* Fix up the public URI to match what was passed in. */
cursor = *cursorp;
diff --git a/src/third_party/wiredtiger/src/evict/evict_lru.c b/src/third_party/wiredtiger/src/evict/evict_lru.c
index 4cfaba07b51..6e850f67b3e 100644
--- a/src/third_party/wiredtiger/src/evict/evict_lru.c
+++ b/src/third_party/wiredtiger/src/evict/evict_lru.c
@@ -1510,7 +1510,7 @@ retry: while (slot < max_entries) {
* candidates and we aren't finding more.
*/
if (slot < max_entries && (retries < 2 ||
- (retries < 10 &&
+ (retries < WT_RETRY_MAX &&
(slot == queue->evict_entries || slot > start_slot)))) {
start_slot = slot;
++retries;
diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h
index e77de41344c..3c45b290dd8 100644
--- a/src/third_party/wiredtiger/src/include/extern.h
+++ b/src/third_party/wiredtiger/src/include/extern.h
@@ -565,7 +565,7 @@ extern int __wt_schema_index_source(WT_SESSION_IMPL *session, WT_TABLE *table, c
extern int __wt_schema_create( WT_SESSION_IMPL *session, const char *uri, const char *config) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_schema_get_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
-extern void __wt_schema_release_table(WT_SESSION_IMPL *session, WT_TABLE *table);
+extern int __wt_schema_release_table(WT_SESSION_IMPL *session, WT_TABLE *table) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern void __wt_schema_destroy_colgroup(WT_SESSION_IMPL *session, WT_COLGROUP **colgroupp);
extern int __wt_schema_destroy_index(WT_SESSION_IMPL *session, WT_INDEX **idxp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
extern int __wt_schema_destroy_table(WT_SESSION_IMPL *session, WT_TABLE **tablep) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result));
diff --git a/src/third_party/wiredtiger/src/include/flags.h b/src/third_party/wiredtiger/src/include/flags.h
index d7c0e0f9472..0e6cf7657ed 100644
--- a/src/third_party/wiredtiger/src/include/flags.h
+++ b/src/third_party/wiredtiger/src/include/flags.h
@@ -21,7 +21,8 @@
#define WT_CONN_SERVER_LSM 0x00008000
#define WT_CONN_SERVER_STATISTICS 0x00010000
#define WT_CONN_SERVER_SWEEP 0x00020000
-#define WT_CONN_WAS_BACKUP 0x00040000
+#define WT_CONN_TABLE_CACHE 0x00040000
+#define WT_CONN_WAS_BACKUP 0x00080000
#define WT_EVICTING 0x00000002
#define WT_EVICT_INMEM_SPLIT 0x00000004
#define WT_EVICT_IN_MEMORY 0x00000008
diff --git a/src/third_party/wiredtiger/src/include/os.h b/src/third_party/wiredtiger/src/include/os.h
index 73d89268392..2c03b115e7c 100644
--- a/src/third_party/wiredtiger/src/include/os.h
+++ b/src/third_party/wiredtiger/src/include/os.h
@@ -34,9 +34,11 @@
(ret) = __wt_errno(); \
} while (0)
+#define WT_RETRY_MAX 10
+
#define WT_SYSCALL_RETRY(call, ret) do { \
int __retry; \
- for (__retry = 0; __retry < 10; ++__retry) { \
+ for (__retry = 0; __retry < WT_RETRY_MAX; ++__retry) { \
WT_SYSCALL(call, ret); \
switch (ret) { \
case EAGAIN: \
diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in
index b2f49ef030d..30bff37017a 100644
--- a/src/third_party/wiredtiger/src/include/wiredtiger.in
+++ b/src/third_party/wiredtiger/src/include/wiredtiger.in
@@ -2458,6 +2458,8 @@ struct __wt_connection {
* readonly for more information., a boolean flag; default \c false.}
* @config{session_max, maximum expected number of sessions (including server
* threads)., an integer greater than or equal to 1; default \c 100.}
+ * @config{session_table_cache, Maintain a per-session cache of tables., a
+ * boolean flag; default \c true.}
* @config{shared_cache = (, shared cache configuration options. A database
* should configure either a cache_size or a shared_cache not both. Enabling a
* shared cache uses a session from the configured session_max., a set of
diff --git a/src/third_party/wiredtiger/src/meta/meta_table.c b/src/third_party/wiredtiger/src/meta/meta_table.c
index 895b8a9c565..a970694b9d7 100644
--- a/src/third_party/wiredtiger/src/meta/meta_table.c
+++ b/src/third_party/wiredtiger/src/meta/meta_table.c
@@ -277,7 +277,9 @@ __wt_metadata_search(WT_SESSION_IMPL *session, const char *key, char **valuep)
* that Coverity complains a lot, add an error check to get some
* peace and quiet.
*/
- if ((ret = __wt_turtle_read(session, key, valuep)) != 0)
+ WT_WITH_TURTLE_LOCK(session,
+ ret = __wt_turtle_read(session, key, valuep));
+ if (ret != 0)
__wt_free(session, *valuep);
return (ret);
}
diff --git a/src/third_party/wiredtiger/src/meta/meta_turtle.c b/src/third_party/wiredtiger/src/meta/meta_turtle.c
index 5a089471059..f7ea6fe99c5 100644
--- a/src/third_party/wiredtiger/src/meta/meta_turtle.c
+++ b/src/third_party/wiredtiger/src/meta/meta_turtle.c
@@ -246,6 +246,9 @@ __wt_turtle_read(WT_SESSION_IMPL *session, const char *key, char **valuep)
*valuep = NULL;
+ /* Require single-threading. */
+ WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_TURTLE));
+
/*
* Open the turtle file; there's one case where we won't find the turtle
* file, yet still succeed. We create the metadata file before creating
@@ -302,6 +305,9 @@ __wt_turtle_update(WT_SESSION_IMPL *session, const char *key, const char *value)
fs = NULL;
+ /* Require single-threading. */
+ WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_TURTLE));
+
/*
* Create the turtle setup file: we currently re-write it from scratch
* every time.
diff --git a/src/third_party/wiredtiger/src/schema/schema_alter.c b/src/third_party/wiredtiger/src/schema/schema_alter.c
index 26d800aa98e..edb3c6f77ae 100644
--- a/src/third_party/wiredtiger/src/schema/schema_alter.c
+++ b/src/third_party/wiredtiger/src/schema/schema_alter.c
@@ -61,13 +61,16 @@ __alter_colgroup(
{
WT_COLGROUP *colgroup;
WT_DECL_RET;
+ WT_TABLE *table;
WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_TABLE));
/* If we can get the colgroup, perform any potential alterations. */
if ((ret = __wt_schema_get_colgroup(
- session, uri, false, NULL, &colgroup)) == 0)
+ session, uri, false, &table, &colgroup)) == 0) {
WT_TRET(__wt_schema_alter(session, colgroup->source, cfg));
+ WT_TRET(__wt_schema_release_table(session, table));
+ }
return (ret);
}
@@ -82,11 +85,14 @@ __alter_index(
{
WT_INDEX *idx;
WT_DECL_RET;
+ WT_TABLE *table;
/* If we can get the index, perform any potential alterations. */
if ((ret = __wt_schema_get_index(
- session, uri, false, NULL, &idx)) == 0)
+ session, uri, false, &table, &idx)) == 0) {
WT_TRET(__wt_schema_alter(session, idx->source, cfg));
+ WT_TRET(__wt_schema_release_table(session, table));
+ }
return (ret);
}
@@ -127,7 +133,8 @@ __alter_table(WT_SESSION_IMPL *session, const char *uri, const char *cfg[])
WT_ERR(__wt_schema_alter(
session, colgroup->source, cfg));
}
-err: __wt_schema_release_table(session, table);
+
+err: WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
diff --git a/src/third_party/wiredtiger/src/schema/schema_create.c b/src/third_party/wiredtiger/src/schema/schema_create.c
index 0677fa711a5..49c0274994c 100644
--- a/src/third_party/wiredtiger/src/schema/schema_create.c
+++ b/src/third_party/wiredtiger/src/schema/schema_create.c
@@ -273,7 +273,7 @@ err: __wt_free(session, cgconf);
__wt_buf_free(session, &fmt);
__wt_buf_free(session, &namebuf);
- __wt_schema_release_table(session, table);
+ WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
@@ -540,7 +540,7 @@ err: __wt_free(session, idxconf);
__wt_buf_free(session, &fmt);
__wt_buf_free(session, &namebuf);
- __wt_schema_release_table(session, table);
+ WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
@@ -615,7 +615,7 @@ err: if (table != NULL) {
}
}
if (table != NULL)
- __wt_schema_release_table(session, table);
+ WT_TRET(__wt_schema_release_table(session, table));
__wt_free(session, cgname);
__wt_free(session, tableconf);
return (ret);
diff --git a/src/third_party/wiredtiger/src/schema/schema_drop.c b/src/third_party/wiredtiger/src/schema/schema_drop.c
index 49801e4e5f9..18817c4fa2d 100644
--- a/src/third_party/wiredtiger/src/schema/schema_drop.c
+++ b/src/third_party/wiredtiger/src/schema/schema_drop.c
@@ -67,6 +67,7 @@ __drop_colgroup(
session, uri, force, &table, &colgroup)) == 0) {
table->cg_complete = false;
WT_TRET(__wt_schema_drop(session, colgroup->source, cfg));
+ WT_TRET(__wt_schema_release_table(session, table));
}
WT_TRET(__wt_metadata_remove(session, uri));
@@ -90,6 +91,7 @@ __drop_index(
session, uri, force, &table, &idx)) == 0) {
table->idx_complete = false;
WT_TRET(__wt_schema_drop(session, idx->source, cfg));
+ WT_TRET(__wt_schema_release_table(session, table));
}
WT_TRET(__wt_metadata_remove(session, uri));
@@ -151,7 +153,7 @@ __drop_table(WT_SESSION_IMPL *session, const char *uri, const char *cfg[])
WT_ERR(__wt_metadata_remove(session, uri));
err: if (table != NULL)
- __wt_schema_release_table(session, table);
+ WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
diff --git a/src/third_party/wiredtiger/src/schema/schema_list.c b/src/third_party/wiredtiger/src/schema/schema_list.c
index 3dc51b6cb43..434038c6bc8 100644
--- a/src/third_party/wiredtiger/src/schema/schema_list.c
+++ b/src/third_party/wiredtiger/src/schema/schema_list.c
@@ -30,9 +30,12 @@ __schema_add_table(WT_SESSION_IMPL *session,
session, name, namelen, ok_incomplete, &table));
WT_RET(ret);
- bucket = table->name_hash % WT_HASH_ARRAY_SIZE;
- TAILQ_INSERT_HEAD(&session->tables, table, q);
- TAILQ_INSERT_HEAD(&session->tablehash[bucket], table, hashq);
+ if (!table->is_simple || F_ISSET(S2C(session), WT_CONN_TABLE_CACHE)) {
+ bucket = table->name_hash % WT_HASH_ARRAY_SIZE;
+ TAILQ_INSERT_HEAD(&session->tables, table, q);
+ TAILQ_INSERT_HEAD(&session->tablehash[bucket], table, hashq);
+ }
+
*tablep = table;
return (0);
@@ -112,11 +115,14 @@ __wt_schema_get_table(WT_SESSION_IMPL *session,
* __wt_schema_release_table --
* Release a table handle.
*/
-void
+int
__wt_schema_release_table(WT_SESSION_IMPL *session, WT_TABLE *table)
{
WT_ASSERT(session, table->refcnt > 0);
- --table->refcnt;
+ if (--table->refcnt == 0 &&
+ table->is_simple && !F_ISSET(S2C(session), WT_CONN_TABLE_CACHE))
+ WT_RET(__wt_schema_destroy_table(session, &table));
+ return (0);
}
/*
@@ -229,9 +235,11 @@ __wt_schema_remove_table(WT_SESSION_IMPL *session, WT_TABLE *table)
uint64_t bucket;
WT_ASSERT(session, table->refcnt <= 1);
- bucket = table->name_hash % WT_HASH_ARRAY_SIZE;
- TAILQ_REMOVE(&session->tables, table, q);
- TAILQ_REMOVE(&session->tablehash[bucket], table, hashq);
+ if (!table->is_simple || F_ISSET(S2C(session), WT_CONN_TABLE_CACHE)) {
+ bucket = table->name_hash % WT_HASH_ARRAY_SIZE;
+ TAILQ_REMOVE(&session->tables, table, q);
+ TAILQ_REMOVE(&session->tablehash[bucket], table, hashq);
+ }
return (__wt_schema_destroy_table(session, &table));
}
diff --git a/src/third_party/wiredtiger/src/schema/schema_open.c b/src/third_party/wiredtiger/src/schema/schema_open.c
index 081650d74a8..2df6bae45f3 100644
--- a/src/third_party/wiredtiger/src/schema/schema_open.c
+++ b/src/third_party/wiredtiger/src/schema/schema_open.c
@@ -530,8 +530,8 @@ __wt_schema_get_colgroup(WT_SESSION_IMPL *session,
const char *tablename, *tend;
u_int i;
- if (tablep != NULL)
- *tablep = NULL;
+ WT_ASSERT(session, tablep != NULL);
+ *tablep = NULL;
*colgroupp = NULL;
tablename = uri;
@@ -548,15 +548,12 @@ __wt_schema_get_colgroup(WT_SESSION_IMPL *session,
colgroup = table->cgroups[i];
if (strcmp(colgroup->name, uri) == 0) {
*colgroupp = colgroup;
- if (tablep != NULL)
- *tablep = table;
- else
- __wt_schema_release_table(session, table);
+ *tablep = table;
return (0);
}
}
- __wt_schema_release_table(session, table);
+ WT_RET(__wt_schema_release_table(session, table));
if (quiet)
WT_RET(ENOENT);
WT_RET_MSG(session, ENOENT, "%s not found in table", uri);
@@ -576,8 +573,8 @@ __wt_schema_get_index(WT_SESSION_IMPL *session,
const char *tablename, *tend;
u_int i;
- if (tablep != NULL)
- *tablep = NULL;
+ WT_ASSERT(session, tablep != NULL);
+ *tablep = NULL;
*indexp = NULL;
tablename = uri;
@@ -592,11 +589,8 @@ __wt_schema_get_index(WT_SESSION_IMPL *session,
for (i = 0; i < table->nindices; i++) {
idx = table->indices[i];
if (idx != NULL && strcmp(idx->name, uri) == 0) {
- if (tablep != NULL)
- *tablep = table;
- else
- __wt_schema_release_table(session, table);
*indexp = idx;
+ *tablep = table;
return (0);
}
}
@@ -604,15 +598,12 @@ __wt_schema_get_index(WT_SESSION_IMPL *session,
/* Otherwise, open it. */
WT_ERR(__wt_schema_open_index(
session, table, tend + 1, strlen(tend + 1), indexp));
- if (tablep != NULL)
- *tablep = table;
+ *tablep = table;
+ return (0);
-err: __wt_schema_release_table(session, table);
+err: WT_TRET(__wt_schema_release_table(session, table));
WT_RET(ret);
- if (*indexp != NULL)
- return (0);
-
if (quiet)
WT_RET(ENOENT);
WT_RET_MSG(session, ENOENT, "%s not found in table", uri);
diff --git a/src/third_party/wiredtiger/src/schema/schema_rename.c b/src/third_party/wiredtiger/src/schema/schema_rename.c
index a374f4c2831..9effedd2cde 100644
--- a/src/third_party/wiredtiger/src/schema/schema_rename.c
+++ b/src/third_party/wiredtiger/src/schema/schema_rename.c
@@ -233,7 +233,7 @@ __rename_table(WT_SESSION_IMPL *session,
WT_ERR(__metadata_rename(session, uri, newuri));
err: if (table != NULL)
- __wt_schema_release_table(session, table);
+ WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
diff --git a/src/third_party/wiredtiger/src/schema/schema_stat.c b/src/third_party/wiredtiger/src/schema/schema_stat.c
index 345f9164e9b..9bcd2439619 100644
--- a/src/third_party/wiredtiger/src/schema/schema_stat.c
+++ b/src/third_party/wiredtiger/src/schema/schema_stat.c
@@ -19,14 +19,17 @@ __wt_curstat_colgroup_init(WT_SESSION_IMPL *session,
WT_COLGROUP *colgroup;
WT_DECL_ITEM(buf);
WT_DECL_RET;
+ WT_TABLE *table;
- WT_RET(__wt_schema_get_colgroup(session, uri, false, NULL, &colgroup));
+ WT_RET(__wt_schema_get_colgroup(
+ session, uri, false, &table, &colgroup));
WT_RET(__wt_scr_alloc(session, 0, &buf));
WT_ERR(__wt_buf_fmt(session, buf, "statistics:%s", colgroup->source));
ret = __wt_curstat_init(session, buf->data, NULL, cfg, cst);
err: __wt_scr_free(session, &buf);
+ WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
@@ -41,14 +44,16 @@ __wt_curstat_index_init(WT_SESSION_IMPL *session,
WT_DECL_ITEM(buf);
WT_DECL_RET;
WT_INDEX *idx;
+ WT_TABLE *table;
- WT_RET(__wt_schema_get_index(session, uri, false, NULL, &idx));
+ WT_RET(__wt_schema_get_index(session, uri, false, &table, &idx));
WT_RET(__wt_scr_alloc(session, 0, &buf));
WT_ERR(__wt_buf_fmt(session, buf, "statistics:%s", idx->source));
ret = __wt_curstat_init(session, buf->data, NULL, cfg, cst);
err: __wt_scr_free(session, &buf);
+ WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
@@ -184,7 +189,7 @@ __wt_curstat_table_init(WT_SESSION_IMPL *session,
__wt_curstat_dsrc_final(cst);
-err: __wt_schema_release_table(session, table);
+err: WT_TRET(__wt_schema_release_table(session, table));
__wt_scr_free(session, &buf);
return (ret);
diff --git a/src/third_party/wiredtiger/src/schema/schema_truncate.c b/src/third_party/wiredtiger/src/schema/schema_truncate.c
index 563bafa8ffc..3046305e819 100644
--- a/src/third_party/wiredtiger/src/schema/schema_truncate.c
+++ b/src/third_party/wiredtiger/src/schema/schema_truncate.c
@@ -33,7 +33,7 @@ __truncate_table(WT_SESSION_IMPL *session, const char *uri, const char *cfg[])
WT_ERR(__wt_schema_truncate(
session, table->indices[i]->source, cfg));
-err: __wt_schema_release_table(session, table);
+err: WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
diff --git a/src/third_party/wiredtiger/src/schema/schema_worker.c b/src/third_party/wiredtiger/src/schema/schema_worker.c
index 62cdd7d367b..9fb68720723 100644
--- a/src/third_party/wiredtiger/src/schema/schema_worker.c
+++ b/src/third_party/wiredtiger/src/schema/schema_worker.c
@@ -64,14 +64,17 @@ __wt_schema_worker(WT_SESSION_IMPL *session,
}
} else if (WT_PREFIX_MATCH(uri, "colgroup:")) {
WT_ERR(__wt_schema_get_colgroup(
- session, uri, false, NULL, &colgroup));
+ session, uri, false, &table, &colgroup));
WT_ERR(__wt_schema_worker(session,
colgroup->source, file_func, name_func, cfg, open_flags));
+ WT_ERR(__wt_schema_release_table(session, table));
} else if (WT_PREFIX_SKIP(tablename, "index:")) {
idx = NULL;
- WT_ERR(__wt_schema_get_index(session, uri, false, NULL, &idx));
+ WT_ERR(__wt_schema_get_index(
+ session, uri, false, &table, &idx));
WT_ERR(__wt_schema_worker(session, idx->source,
file_func, name_func, cfg, open_flags));
+ WT_ERR(__wt_schema_release_table(session, table));
} else if (WT_PREFIX_MATCH(uri, "lsm:")) {
WT_ERR(__wt_lsm_tree_worker(session,
uri, file_func, name_func, cfg, open_flags));
@@ -128,6 +131,6 @@ __wt_schema_worker(WT_SESSION_IMPL *session,
WT_ERR(__wt_bad_object_type(session, uri));
err: if (table != NULL)
- __wt_schema_release_table(session, table);
+ WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c
index 5ce6135cfca..386084b78d9 100644
--- a/src/third_party/wiredtiger/src/session/session_api.c
+++ b/src/third_party/wiredtiger/src/session/session_api.c
@@ -328,6 +328,7 @@ __session_open_cursor_int(WT_SESSION_IMPL *session, const char *uri,
WT_COLGROUP *colgroup;
WT_DATA_SOURCE *dsrc;
WT_DECL_RET;
+ WT_TABLE *table;
*cursorp = NULL;
@@ -355,9 +356,10 @@ __session_open_cursor_int(WT_SESSION_IMPL *session, const char *uri,
* the underlying data source.
*/
WT_RET(__wt_schema_get_colgroup(
- session, uri, false, NULL, &colgroup));
+ session, uri, false, &table, &colgroup));
WT_RET(__wt_open_cursor(
session, colgroup->source, owner, cfg, cursorp));
+ WT_RET(__wt_schema_release_table(session, table));
} else if (WT_PREFIX_MATCH(uri, "config:"))
WT_RET(__wt_curconfig_open(
session, uri, cfg, cursorp));
@@ -1211,12 +1213,15 @@ __wt_session_range_truncate(WT_SESSION_IMPL *session,
done:
err: /*
- * Close any locally-opened start cursor. Reset application cursors,
- * they've possibly moved and the application cannot use them.
+ * Close any locally-opened start cursor.
+ *
+ * Reset application cursors, they've possibly moved and the
+ * application cannot use them. Note that we can make it here with a
+ * NULL start cursor (e.g., if the truncate range is empty).
*/
if (local_start)
WT_TRET(start->close(start));
- else
+ else if (start != NULL)
WT_TRET(start->reset(start));
if (stop != NULL)
WT_TRET(stop->reset(stop));