diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-09-09 15:49:31 +1000 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2016-09-09 15:58:39 +1000 |
commit | 29b5a329c5c72fe87d1627bd99e682d9d5e2e34c (patch) | |
tree | 1dc8949286121eb16b472d4f5e4ea391baebc5de /src/third_party | |
parent | bda317e9c852b27f0fe7d148e5c08499d2f8ec49 (diff) | |
download | mongo-29b5a329c5c72fe87d1627bd99e682d9d5e2e34c.tar.gz |
Import wiredtiger: 569c70d13a7b3da0fe8eb1bac06a86865cb36a7c from branch mongodb-3.4
ref: 7d3c0f9f50..569c70d13a
for: 3.3.13
SERVER-25843 Coverity analysis defect 99856: Redundant test
SERVER-25845 Coverity analysis defect 99859: Explicit null dereferenced
SERVER-25846 Coverity analysis defect 99861: Dereference after null check
WT-2221 Document which statistics are available via a "fast" configuration vs. an "all" configuration
WT-2233 Investigate changing when the eviction server switches to aggressive mode.
WT-2323 Allocate a transaction id at the beginning of join cursor iteration
WT-2555 make format run on Windows
WT-2788 Java: freed memory overwrite during handle close can cause JNI crash
WT-2816 Improve WiredTiger eviction performance
WT-2824 wtperf displays connection and table create configurations twice
WT-2842 split wtperf's configuration into per-database and per-run parts
WT-2866 Eviction server algorithm tuning
WT-2867 Review and fix barrier usage in __lsm_tree_close
WT-2870 Rename wtperf checkpoint schema jobs
WT-2871 __wt_verbose has the wrong GCC format attributes
WT-2872 Recent stuck cache test/stress failures.
WT-2873 Refactor CRC32 code
WT-2875 Test test_wt2853_perf can run too long under valgrind
WT-2876 Extend wtperf to support a log like table
WT-2878 Verbose changes affected performance
WT-2881 Add -Wpedantic to clang compiler warning flags
WT-2882 Add CRC32 hardware scons detection, disable CRC hardware support on ARM for now
WT-2883 wiredtiger_open with verbose=handleops recursive loop
WT-2885 __wt_checkpoint_signal lint
WT-2886 Decide how in-memory configuration and eviction_dirty_target interact
WT-2888 Switch functions to return void where possible
WT-2892 hot backup can race with block truncate
WT-2896 Coverity #1362535: resource leak
WT-2897 Checkpoints can become corrupted on failure
WT-2901 Add option to disable checkpoint dirty stepdown phase
Diffstat (limited to 'src/third_party')
140 files changed, 2665 insertions, 1439 deletions
diff --git a/src/third_party/wiredtiger/SConscript b/src/third_party/wiredtiger/SConscript index 50db73c4d6b..e99d0cd759f 100644 --- a/src/third_party/wiredtiger/SConscript +++ b/src/third_party/wiredtiger/SConscript @@ -136,13 +136,13 @@ env.Alias('generated-sources', "wiredtiger.h") # included. # condition_map = { - 'POSIX_HOST' : not env.TargetOSIs('windows'), - 'POWERPC_HOST' : env['TARGET_ARCH'] == 'ppc64le', + 'POSIX_HOST' : not env.TargetOSIs('windows'), 'WINDOWS_HOST' : env.TargetOSIs('windows'), - # This isn't perfect. But should cover for our build environments - # See WT-2873 for planned improvements - 'X86_HOST' : not env['TARGET_ARCH'] == 'ppc64le' and not (env['TARGET_ARCH'] == 's390x' and get_option("use-s390x-crc32") == "on"), - 'ZSERIES_HOST' : env['TARGET_ARCH'] == 's390x' and get_option("use-s390x-crc32") == "on", + + 'ARM64_HOST' : env['TARGET_ARCH'] == 'aarch64', + 'POWERPC_HOST' : env['TARGET_ARCH'] == 'ppc64le', + 'X86_HOST' : env['TARGET_ARCH'] == 'x86_64', + 'ZSERIES_HOST' : env['TARGET_ARCH'] == 's390x', } def filtered_filelist(f): @@ -165,6 +165,15 @@ if useSnappy: env.Append(CPPDEFINES=['HAVE_BUILTIN_EXTENSION_SNAPPY']) wtsources.append("ext/compressors/snappy/snappy_compress.c") +# Use hardware by default on all platforms if available. +# If not available at runtime, we fall back to software in some cases. +# +# On zSeries we may disable because SLES 11 kernel doe not support the instructions. +if not (env['TARGET_ARCH'] == 's390x' and get_option("use-s390x-crc32") == "off"): + # Disable ARM hardware CRC for now - the extensions aren't always available + if env['TARGET_ARCH'] != 'aarch64': + env.Append(CPPDEFINES=["HAVE_CRC32_HARDWARE"]) + wtlib = env.Library( target="wiredtiger", source=wtsources, diff --git a/src/third_party/wiredtiger/SConstruct b/src/third_party/wiredtiger/SConstruct index 55b3a2af4eb..0ccdf59babc 100644 --- a/src/third_party/wiredtiger/SConstruct +++ b/src/third_party/wiredtiger/SConstruct @@ -245,6 +245,7 @@ wtheader = env.Substfile( # included. # condition_map = { + 'ARM64_HOST' : False, 'POSIX_HOST' : env['PLATFORM'] == 'posix', 'POWERPC_HOST' : False, 'WINDOWS_HOST' : env['PLATFORM'] == 'win32', @@ -443,28 +444,22 @@ t = env.Program("t_fops", "test/fops/t.c"], LIBS=[wtlib, shim, testutil] + wtlibs) env.Append(CPPPATH=["test/utility"]) -env.Alias("check", env.SmokeTest(t)) Default(t) -if useBdb: - benv = env.Clone() - - benv.Append(CPPDEFINES=['BERKELEY_DB_PATH=\\"' + useBdb.replace("\\", "\\\\") + '\\"']) - - t = benv.Program("t_format", - ["test/format/backup.c", - "test/format/bdb.c", - "test/format/bulk.c", - "test/format/compact.c", - "test/format/config.c", - "test/format/ops.c", - "test/format/salvage.c", - "test/format/t.c", - "test/format/util.c", - "test/format/wts.c"], - LIBS=[wtlib, shim, "libdb61"] + wtlibs) - env.Alias("test", env.SmokeTest(t)) - Default(t) +t = env.Program("t_format", + ["test/format/backup.c", + "test/format/bulk.c", + "test/format/compact.c", + "test/format/config.c", + "test/format/lrt.c", + "test/format/ops.c", + "test/format/rebalance.c", + "test/format/salvage.c", + "test/format/t.c", + "test/format/util.c", + "test/format/wts.c"], + LIBS=[wtlib, shim, testutil] + wtlibs) +Default(t) #env.Program("t_thread", #["test/thread/file.c", diff --git a/src/third_party/wiredtiger/bench/wtperf/config.c b/src/third_party/wiredtiger/bench/wtperf/config.c index a2960902ec1..48127afc10e 100644 --- a/src/third_party/wiredtiger/bench/wtperf/config.c +++ b/src/third_party/wiredtiger/bench/wtperf/config.c @@ -97,7 +97,7 @@ config_unescape(char *orig) * config_copy -- * CONFIG structure initialization, based on a source configuration. */ -int +void config_copy(CONFIG *dest, const CONFIG *src) { CONFIG_QUEUE_ENTRY *conf_line, *tmp_line; @@ -156,7 +156,6 @@ config_copy(CONFIG *dest, const CONFIG *src) tmp_line->string = dstrdup(conf_line->string); TAILQ_INSERT_TAIL(&dest->config_head, tmp_line, c); } - return (0); } /* @@ -174,7 +173,10 @@ config_free(CONFIG *cfg) free(cfg->monitor_dir); free(cfg->partial_config); free(cfg->reopen_config); + + /* Free the various URIs */ free(cfg->base_uri); + free(cfg->log_table_uri); if (cfg->uris != NULL) { for (i = 0; i < cfg->table_count; i++) diff --git a/src/third_party/wiredtiger/bench/wtperf/runners/checkpoint_schema_race.wtperf b/src/third_party/wiredtiger/bench/wtperf/runners/checkpoint-schema-race.wtperf index ade8e88ee9b..ade8e88ee9b 100644 --- a/src/third_party/wiredtiger/bench/wtperf/runners/checkpoint_schema_race.wtperf +++ b/src/third_party/wiredtiger/bench/wtperf/runners/checkpoint-schema-race.wtperf diff --git a/src/third_party/wiredtiger/bench/wtperf/runners/checkpoint_stress_schema_ops.wtperf b/src/third_party/wiredtiger/bench/wtperf/runners/checkpoint-stress-schema-ops.wtperf index b69ead7f8b1..b69ead7f8b1 100644 --- a/src/third_party/wiredtiger/bench/wtperf/runners/checkpoint_stress_schema_ops.wtperf +++ b/src/third_party/wiredtiger/bench/wtperf/runners/checkpoint-stress-schema-ops.wtperf diff --git a/src/third_party/wiredtiger/bench/wtperf/runners/mongodb-secondary-apply.wtperf b/src/third_party/wiredtiger/bench/wtperf/runners/mongodb-secondary-apply.wtperf new file mode 100644 index 00000000000..f9e41184f95 --- /dev/null +++ b/src/third_party/wiredtiger/bench/wtperf/runners/mongodb-secondary-apply.wtperf @@ -0,0 +1,21 @@ +# Simulate the MongoDB oplog apply threads on a secondary. +conn_config="cache_size=10GB,session_max=1000,eviction=(threads_min=4,threads_max=4),log=(enabled=false),transaction_sync=(enabled=false),checkpoint_sync=true,checkpoint=(wait=60),statistics=(fast),statistics_log=(json,wait=1)" +table_config="allocation_size=4k,memory_page_max=5MB,prefix_compression=false,split_pct=75,leaf_page_max=32k,internal_page_max=16k,type=file" +# Spread the workload out over several tables. +table_count=4 +# We like compression. +compression=snappy +icount=1000 +populate_threads=1 +reopen_connection=true +log_like_table=true +report_interval=5 +run_time=360 +# Configure multiple threads doing a limited number of operations each. Enclose +# a few operations in an explicit transaction to simulate MongoDB apply on a +# secondary. +threads=((count=16,throttle=1000,inserts=1,ops_per_txn=3)) +# Configure a moderately large value size +value_sz=1800 +sample_interval=5 +sample_rate=1 diff --git a/src/third_party/wiredtiger/bench/wtperf/wtperf.c b/src/third_party/wiredtiger/bench/wtperf/wtperf.c index d3d54fff6e3..bf6b156bb69 100644 --- a/src/third_party/wiredtiger/bench/wtperf/wtperf.c +++ b/src/third_party/wiredtiger/bench/wtperf/wtperf.c @@ -37,6 +37,7 @@ static const CONFIG default_cfg = { NULL, /* partial logging */ NULL, /* reopen config */ NULL, /* base_uri */ + NULL, /* log_table_uri */ NULL, /* uris */ NULL, /* conn */ NULL, /* logf */ @@ -55,6 +56,7 @@ static const CONFIG default_cfg = { 0, /* truncate operations */ 0, /* update operations */ 0, /* insert key */ + 0, /* log like table key */ 0, /* checkpoint in progress */ 0, /* thread error */ 0, /* notify threads to stop */ @@ -512,11 +514,11 @@ worker(void *arg) CONFIG_THREAD *thread; TRACK *trk; WT_CONNECTION *conn; - WT_CURSOR **cursors, *cursor, *tmp_cursor; + WT_CURSOR **cursors, *cursor, *log_table_cursor, *tmp_cursor; WT_SESSION *session; size_t i; int64_t ops, ops_per_txn; - uint64_t next_val, usecs; + uint64_t log_id, next_val, usecs; uint8_t *op, *op_end; int measure_latency, ret, truncated; char *value_buf, *key_buf, *value; @@ -526,6 +528,7 @@ worker(void *arg) cfg = thread->cfg; conn = cfg->conn; cursors = NULL; + log_table_cursor = NULL; /* -Wconditional-initialized */ ops = 0; ops_per_txn = thread->workload->ops_per_txn; session = NULL; @@ -560,6 +563,16 @@ worker(void *arg) goto err; } } + if (cfg->log_like_table) { + if ((ret = session->open_cursor(session, + cfg->log_table_uri, NULL, NULL, &log_table_cursor)) != 0) { + lprintf(cfg, ret, 0, + "worker: WT_SESSION.open_cursor: %s", + cfg->log_table_uri); + goto err; + } + } + /* Setup the timer for throttling. */ if (thread->workload->throttle != 0) setup_throttle(thread); @@ -575,7 +588,7 @@ worker(void *arg) op = thread->workload->ops; op_end = op + sizeof(thread->workload->ops); - if (ops_per_txn != 0 && + if ((ops_per_txn != 0 || cfg->log_like_table) && (ret = session->begin_transaction(session, NULL)) != 0) { lprintf(cfg, ret, 0, "First transaction begin failed"); goto err; @@ -768,6 +781,20 @@ op_err: if (ret == WT_ROLLBACK && ops_per_txn != 0) { goto err; /* can't happen */ } + /* Update the log-like table. */ + if (cfg->log_like_table && + (*op != WORKER_READ && *op != WORKER_TRUNCATE)) { + log_id = __wt_atomic_add64(&cfg->log_like_table_key, 1); + log_table_cursor->set_key(log_table_cursor, log_id); + log_table_cursor->set_value( + log_table_cursor, value_buf); + if ((ret = + log_table_cursor->insert(log_table_cursor)) != 0) { + lprintf(cfg, ret, 0, "Cursor insert failed"); + goto err; + } + } + /* Release the cursor, if we have multiple tables. */ if (cfg->table_count > 1 && ret == 0 && *op != WORKER_INSERT && *op != WORKER_INSERT_RMW) { @@ -793,8 +820,12 @@ op_err: if (ret == WT_ROLLBACK && ops_per_txn != 0) { ++trk->ops; } - /* Commit our work if configured for explicit transactions */ - if (ops_per_txn != 0 && ops++ % ops_per_txn == 0) { + /* + * Commit the transaction if grouping operations together + * or tracking changes in our log table. + */ + if ((cfg->log_like_table && ops_per_txn == 0) || + (ops_per_txn != 0 && ops++ % ops_per_txn == 0)) { if ((ret = session->commit_transaction( session, NULL)) != 0) { lprintf(cfg, ret, 0, @@ -819,6 +850,7 @@ op_err: if (ret == WT_ROLLBACK && ops_per_txn != 0) { */ if (--thread->throttle_cfg.ops_count == 0) worker_throttle(thread); + } if ((ret = session->close(session, NULL)) != 0) { @@ -1879,6 +1911,10 @@ create_uris(CONFIG *cfg) else sprintf(uri, "%s%05d", cfg->base_uri, i); } + + /* Create the log-like-table URI. */ + cfg->log_table_uri = dcalloc(base_uri_len + 11, 1); + sprintf(cfg->log_table_uri, "%s_log_table", cfg->base_uri); } static int @@ -1905,6 +1941,11 @@ create_tables(CONFIG *cfg) return (ret); } } + if (cfg->log_like_table && (ret = session->create(session, + cfg->log_table_uri, "key_format=Q,value_format=S")) != 0) { + lprintf(cfg, ret, 0, "Error creating log table %s", buf); + return (ret); + } for (i = 0; i < cfg->table_count; i++) { if (cfg->log_partial && i > 0) { @@ -1965,8 +2006,7 @@ start_all_runs(CONFIG *cfg) for (i = 0; i < cfg->database_count; i++) { next_cfg = dcalloc(1, sizeof(CONFIG)); configs[i] = next_cfg; - if ((ret = config_copy(next_cfg, cfg)) != 0) - goto err; + config_copy(next_cfg, cfg); /* Setup a unique home directory for each database. */ new_home = dmalloc(home_len + 5); @@ -2197,8 +2237,7 @@ main(int argc, char *argv[]) /* Setup the default configuration values. */ cfg = &_cfg; memset(cfg, 0, sizeof(*cfg)); - if (config_copy(cfg, &default_cfg)) - goto err; + config_copy(cfg, &default_cfg); cfg->home = dstrdup(DEFAULT_HOME); cfg->monitor_dir = dstrdup(DEFAULT_MONITOR_DIR); @@ -2329,7 +2368,7 @@ main(int argc, char *argv[]) if (cfg->verbose > 1 || user_cconfig != NULL || cfg->session_count_idle > 0 || cfg->compress_ext != NULL || cfg->async_config != NULL) { - req_len = strlen(cfg->conn_config) + strlen(debug_cconfig) + 3; + req_len = strlen(debug_cconfig) + 3; if (user_cconfig != NULL) req_len += strlen(user_cconfig); if (cfg->async_config != NULL) @@ -2349,21 +2388,23 @@ main(int argc, char *argv[]) /* * This is getting hard to parse. */ - snprintf(cc_buf, req_len, "%s%s%s%s%s%s%s%s", - cfg->conn_config, + snprintf(cc_buf, req_len, "%s%s%s%s%s%s%s", cfg->async_config ? cfg->async_config : "", cfg->compress_ext ? cfg->compress_ext : "", - cfg->verbose > 1 ? ",": "", - cfg->verbose > 1 ? debug_cconfig : "", + cfg->verbose > 1 && strlen(debug_cconfig) ? ",": "", + cfg->verbose > 1 && + strlen(debug_cconfig) ? debug_cconfig : "", sess_cfg ? sess_cfg : "", user_cconfig ? ",": "", user_cconfig ? user_cconfig : ""); - if ((ret = config_opt_str(cfg, "conn_config", cc_buf)) != 0) - goto err; + if (strlen(cc_buf)) + if ((ret = config_opt_str( + cfg, "conn_config", cc_buf)) != 0) + goto err; } if (cfg->verbose > 1 || cfg->index || user_tconfig != NULL || cfg->compress_table != NULL) { - req_len = strlen(cfg->table_config) + strlen(debug_tconfig) + 3; + req_len = strlen(debug_tconfig) + 3; if (user_tconfig != NULL) req_len += strlen(user_tconfig); if (cfg->compress_table != NULL) @@ -2374,16 +2415,18 @@ main(int argc, char *argv[]) /* * This is getting hard to parse. */ - snprintf(tc_buf, req_len, "%s%s%s%s%s%s%s", - cfg->table_config, + snprintf(tc_buf, req_len, "%s%s%s%s%s%s", cfg->index ? INDEX_COL_NAMES : "", cfg->compress_table ? cfg->compress_table : "", - cfg->verbose > 1 ? ",": "", - cfg->verbose > 1 ? debug_tconfig : "", + cfg->verbose > 1 && strlen(debug_tconfig) ? ",": "", + cfg->verbose > 1 && + strlen(debug_tconfig) ? debug_tconfig : "", user_tconfig ? ",": "", user_tconfig ? user_tconfig : ""); - if ((ret = config_opt_str(cfg, "table_config", tc_buf)) != 0) - goto err; + if (strlen(tc_buf)) + if ((ret = config_opt_str( + cfg, "table_config", tc_buf)) != 0) + goto err; } if (cfg->log_partial && cfg->table_count > 1) { req_len = strlen(cfg->table_config) + diff --git a/src/third_party/wiredtiger/bench/wtperf/wtperf.h b/src/third_party/wiredtiger/bench/wtperf/wtperf.h index e0467f4f3a1..1bb94db2634 100644 --- a/src/third_party/wiredtiger/bench/wtperf/wtperf.h +++ b/src/third_party/wiredtiger/bench/wtperf/wtperf.h @@ -43,7 +43,7 @@ typedef struct __truncate_queue_entry TRUNCATE_QUEUE_ENTRY; #define EXT_PFX ",extensions=(" #define EXT_SFX ")" #define EXTPATH "../../ext/compressors/" /* Extensions path */ -#define BLKCMP_PFX ",block_compressor=" +#define BLKCMP_PFX "block_compressor=" #define LZ4_BLK BLKCMP_PFX "lz4" #define LZ4_EXT \ @@ -121,6 +121,7 @@ struct __config { /* Configuration structure */ char *partial_config; /* Config string for partial logging */ char *reopen_config; /* Config string for conn reopen */ char *base_uri; /* Object URI */ + char *log_table_uri; /* URI for log table */ char **uris; /* URIs if multiple tables */ WT_CONNECTION *conn; /* Database connection */ @@ -151,6 +152,7 @@ struct __config { /* Configuration structure */ uint64_t update_ops; /* update operations */ uint64_t insert_key; /* insert key */ + uint64_t log_like_table_key; /* used to allocate IDs for log table */ volatile int ckpt; /* checkpoint in progress */ volatile int error; /* thread error */ @@ -261,7 +263,7 @@ struct __config_thread { /* Per-thread structure */ void cleanup_truncate_config(CONFIG *); int config_compress(CONFIG *); void config_free(CONFIG *); -int config_copy(CONFIG *, const CONFIG *); +void config_copy(CONFIG *, const CONFIG *); int config_opt_file(CONFIG *, const char *); int config_opt_line(CONFIG *, const char *); int config_opt_str(CONFIG *, const char *, const char *); diff --git a/src/third_party/wiredtiger/bench/wtperf/wtperf_opt.i b/src/third_party/wiredtiger/bench/wtperf/wtperf_opt.i index f1f26bd0d01..17517ffe477 100644 --- a/src/third_party/wiredtiger/bench/wtperf/wtperf_opt.i +++ b/src/third_party/wiredtiger/bench/wtperf/wtperf_opt.i @@ -120,6 +120,8 @@ DEF_OPT_AS_BOOL(insert_rmw, 0, "execute a read prior to each insert in workload phase") DEF_OPT_AS_UINT32(key_sz, 20, "key size") DEF_OPT_AS_BOOL(log_partial, 0, "perform partial logging on first table only.") +DEF_OPT_AS_BOOL(log_like_table, 0, + "Append all modification operations to another shared table.") DEF_OPT_AS_UINT32(min_throughput, 0, "notify if any throughput measured is less than this amount. " "Aborts or prints warning based on min_throughput_fatal setting. " diff --git a/src/third_party/wiredtiger/build_posix/aclocal/options.m4 b/src/third_party/wiredtiger/build_posix/aclocal/options.m4 index 5f9b8748df2..1f6a1690279 100644 --- a/src/third_party/wiredtiger/build_posix/aclocal/options.m4 +++ b/src/third_party/wiredtiger/build_posix/aclocal/options.m4 @@ -47,6 +47,19 @@ AM_CONDITIONAL([HAVE_BUILTIN_EXTENSION_ZLIB], [test "$wt_cv_with_builtin_extension_zlib" = "yes"]) AC_MSG_RESULT($with_builtins) +AH_TEMPLATE( + HAVE_CRC32_HARDWARE, [Define to 1 to configure CRC32 hardware support.]) +AC_MSG_CHECKING(if --enable-crc32-hardware option specified) +AC_ARG_ENABLE(crc32-hardware, + AC_HELP_STRING([--enable-crc32-hardware], + [Enable CRC32 hardware support.]), r=$enableval, r=yes) +case "$r" in +no) wt_cv_enable_crc32_hardware=no;; +*) AC_DEFINE(HAVE_CRC32_HARDWARE) + wt_cv_enable_crc32_hardware=yes;; +esac +AC_MSG_RESULT($wt_cv_enable_crc32_hardware) + AH_TEMPLATE(HAVE_DIAGNOSTIC, [Define to 1 for diagnostic tests.]) AC_MSG_CHECKING(if --enable-diagnostic option specified) AC_ARG_ENABLE(diagnostic, diff --git a/src/third_party/wiredtiger/build_posix/configure.ac.in b/src/third_party/wiredtiger/build_posix/configure.ac.in index 00aa0bc9f95..cbd9e4e4123 100644 --- a/src/third_party/wiredtiger/build_posix/configure.ac.in +++ b/src/third_party/wiredtiger/build_posix/configure.ac.in @@ -65,6 +65,10 @@ AS_CASE([$host_cpu], [s390x*], [wt_cv_zseries="yes"], [wt_cv_zseries="no"]) AM_CONDITIONAL([ZSERIES_HOST], [test "$wt_cv_zseries" = "yes"]) +AS_CASE([$host_cpu], + [aarch64*], [wt_cv_arm64="yes"], + [wt_cv_arm64="no"]) +AM_CONDITIONAL([ARM64_HOST], [test "$wt_cv_arm64" = "yes"]) # This is a workaround as part of WT-2459. Currently, clang (v3.7) does not # support compiling the ASM code we have to perform the CRC checks on PowerPC. diff --git a/src/third_party/wiredtiger/build_win/wiredtiger_config.h b/src/third_party/wiredtiger/build_win/wiredtiger_config.h index ad82b13f8a8..83ddc6eb194 100644 --- a/src/third_party/wiredtiger/build_win/wiredtiger_config.h +++ b/src/third_party/wiredtiger/build_win/wiredtiger_config.h @@ -22,6 +22,9 @@ /* Define to 1 if you have the `clock_gettime' function. */ /* #undef HAVE_CLOCK_GETTIME */ +/* Define to 1 to enable CRC32 hardware support. */ +/* #undef HAVE_CRC32_HARDWARE */ + /* Define to 1 for diagnostic tests. */ /* #undef HAVE_DIAGNOSTIC */ diff --git a/src/third_party/wiredtiger/dist/api_data.py b/src/third_party/wiredtiger/dist/api_data.py index e732e42d36d..0f4506f608c 100644 --- a/src/third_party/wiredtiger/dist/api_data.py +++ b/src/third_party/wiredtiger/dist/api_data.py @@ -170,7 +170,7 @@ file_config = format_meta + [ It is stored in clear text, and thus is available when the wiredtiger database is reopened. On the first use of a (name, keyid) combination, the WT_ENCRYPTOR::customize - function is called with the keyid as an argument.'''), + function is called with the keyid as an argument'''), ]), Config('format', 'btree', r''' the file format''', @@ -238,10 +238,10 @@ file_config = format_meta + [ min=0, undoc=True), Config('log', '', r''' the transaction log configuration for this object. Only valid if - log is enabled in ::wiredtiger_open.''', + log is enabled in ::wiredtiger_open''', type='category', subconfig=[ Config('enabled', 'true', r''' - if false, this object has checkpoint-level durability.''', + if false, this object has checkpoint-level durability''', type='boolean'), ]), Config('memory_page_max', '5MB', r''' @@ -352,7 +352,7 @@ connection_runtime_config = [ Config('threads', '2', r''' the number of worker threads to service asynchronous requests. Each worker thread uses a session from the configured - session_max.''', + session_max''', min='1', max='20'), # !!! Must match WT_ASYNC_MAX_WORKERS ]), Config('cache_size', '100MB', r''' @@ -388,7 +388,7 @@ connection_runtime_config = [ Config('error_prefix', '', r''' prefix string for error messages'''), Config('eviction', '', r''' - eviction configuration options.''', + eviction configuration options''', type='category', subconfig=[ Config('threads_max', '1', r''' maximum number of threads WiredTiger will start to help evict @@ -402,16 +402,21 @@ connection_runtime_config = [ vary depending on the current eviction load''', min=1, max=20), ]), + Config('eviction_checkpoint_target', '5', r''' + perform eviction at the beginning of checkpoints to bring the dirty + content in cache to this level, expressed as a percentage of the total + cache size. Ignored if set to zero or \c in_memory is \c true''', + min=0, max=99), Config('eviction_dirty_target', '5', r''' perform eviction in worker threads when the cache contains at least this much dirty content, expressed as a percentage of the total cache - size.''', + size. Ignored if \c in_memory is \c true''', min=1, max=99), Config('eviction_dirty_trigger', '20', r''' trigger application threads to perform eviction when the cache contains at least this much dirty content, expressed as a percentage of the total cache size. This setting only alters behavior if it is lower than - eviction_trigger''', + eviction_trigger. Ignored if \c in_memory is \c true''', min=1, max=99), Config('eviction_target', '80', r''' perform eviction in worker threads when the cache contains at least @@ -421,7 +426,7 @@ connection_runtime_config = [ Config('eviction_trigger', '95', r''' trigger application threads to perform eviction when the cache contains at least this much content, expressed as a percentage of the - total cache size.''', min=10, max=99), + total cache size''', min=10, max=99), Config('file_manager', '', r''' control how file handles are managed''', type='category', subconfig=[ @@ -439,7 +444,7 @@ connection_runtime_config = [ Config('lsm_manager', '', r''' configure database wide options for LSM tree management. The LSM manager is started automatically the first time an LSM tree is opened. - The LSM manager uses a session from the configured session_max.''', + The LSM manager uses a session from the configured session_max''', type='category', subconfig=[ Config('worker_thread_max', '4', r''' Configure a set of threads to manage merging LSM trees in @@ -532,7 +537,7 @@ log_configuration_common = [ automatically archive unneeded log files''', type='boolean'), Config('prealloc', 'true', r''' - pre-allocate log files.''', + pre-allocate log files''', type='boolean'), Config('zero_fill', 'false', r''' manually write zeroes into log files''', @@ -653,7 +658,7 @@ wiredtiger_open_common =\ direct I/O, and including \c "checkpoint" will cause WiredTiger data files opened at a checkpoint (i.e: read only) to use direct I/O. \c direct_io should be combined with \c write_through to get the - equivalent of \c O_DIRECT on Windows.''', + equivalent of \c O_DIRECT on Windows''', type='list', choices=['checkpoint', 'data', 'log']), Config('encryption', '', r''' configure an encryptor for system wide metadata and logs. @@ -672,13 +677,13 @@ wiredtiger_open_common =\ It is stored in clear text, and thus is available when the wiredtiger database is reopened. On the first use of a (name, keyid) combination, the WT_ENCRYPTOR::customize - function is called with the keyid as an argument.'''), + function is called with the keyid as an argument'''), Config('secretkey', '', r''' A string that is passed to the WT_ENCRYPTOR::customize function. It is never stored in clear text, so must be given to any subsequent ::wiredtiger_open calls to reopen the database. It must also be provided to any "wt" commands used with - this database.'''), + this database'''), ]), Config('extensions', '', r''' list of shared library extensions to load (using dlopen). @@ -739,7 +744,7 @@ wiredtiger_open_common =\ files to write through cache, including \c "log" will cause WiredTiger log files to write through cache. \c write_through should be combined with \c direct_io to get the equivalent of POSIX \c O_DIRECT on - Windows.''', + Windows''', type='list', choices=['data', 'log']), ] @@ -986,7 +991,7 @@ methods = { Config('timeout_ms', '1200000', r''' maximum amount of time to wait for background sync to complete in milliseconds. A value of zero disables the timeout and returns - immediately.''', + immediately''', type='int'), ]), @@ -1089,7 +1094,7 @@ methods = { Config('names', '', r''' drop specific named snapshots''', type='list'), Config('to', '', r''' - drop all snapshots up to and including the specified name.'''), + drop all snapshots up to and including the specified name'''), ]), Config('name', '', r'''specify a name for the snapshot'''), ]), diff --git a/src/third_party/wiredtiger/dist/filelist b/src/third_party/wiredtiger/dist/filelist index e16ae879a33..19fa1122a27 100644 --- a/src/third_party/wiredtiger/dist/filelist +++ b/src/third_party/wiredtiger/dist/filelist @@ -47,9 +47,11 @@ src/btree/row_key.c src/btree/row_modify.c src/btree/row_srch.c src/cache/cache_las.c +src/checksum/arm64/crc32-arm64.c ARM64_HOST src/checksum/power8/crc32.S POWERPC_HOST src/checksum/power8/crc32_wrapper.c POWERPC_HOST -src/checksum/x86/checksum.c X86_HOST +src/checksum/software/checksum.c +src/checksum/x86/crc32-x86.c X86_HOST src/checksum/zseries/crc32-s390x.c ZSERIES_HOST src/checksum/zseries/crc32le-vx.S ZSERIES_HOST src/config/config.c diff --git a/src/third_party/wiredtiger/dist/s_prototypes b/src/third_party/wiredtiger/dist/s_prototypes index 89fa750d106..5633c3b5140 100755 --- a/src/third_party/wiredtiger/dist/s_prototypes +++ b/src/third_party/wiredtiger/dist/s_prototypes @@ -46,7 +46,7 @@ proto() -e p < $1 } -# proto -- +# externs -- # generate the list of prototypes given a file list externs() { @@ -76,6 +76,7 @@ externs f=../src/include/extern.h l=`sed \ -e '/^[a-z]/!d' \ + -e '/\/checksum\/arm64/d' \ -e '/\/checksum\/power8/d' \ -e '/\/checksum\/zseries/d' \ -e '/os_posix/d' \ diff --git a/src/third_party/wiredtiger/dist/s_string.ok b/src/third_party/wiredtiger/dist/s_string.ok index 30a2f1b77e9..1887cbd936f 100644 --- a/src/third_party/wiredtiger/dist/s_string.ok +++ b/src/third_party/wiredtiger/dist/s_string.ok @@ -328,6 +328,7 @@ StoreLoad StoreStore TAILQ TCMalloc +TESTUTIL TODO TORTIOUS TSO @@ -472,6 +473,7 @@ call's calloc cas catfmt +cb ccr cd centric @@ -550,6 +552,7 @@ curtable cust customp cv +cx cxa dT data's @@ -643,6 +646,7 @@ extlist fadvise fallocate fblocks +fc fclose fcntl fd diff --git a/src/third_party/wiredtiger/dist/s_void b/src/third_party/wiredtiger/dist/s_void new file mode 100644 index 00000000000..ab2f23a5fdd --- /dev/null +++ b/src/third_party/wiredtiger/dist/s_void @@ -0,0 +1,134 @@ +#! /bin/sh + +t=__wt.$$ +trap 'rm -f $t; exit 0' 0 1 2 3 13 15 + +cd .. + +# Turn a C file into a line per function that returns an int. +file_parse() +{ + sed -n \ + -e '/^int$/b loop' \ + -e '/^static int$/b loop' \ + -e 'd' \ + -e ': loop' \ + -e 'H' \ + -e 'n' \ + -e '/^}$/!b loop' \ + -e 'H' \ + -e 'x' \ + -e 's/\n/ /g' \ + -e 'p' \ + -e 's/.*//' \ + -e 'x' \ + -e 'd' $1 +} + +# Strip out a list of functions that will be flagged, but are OK. +func_ok() +{ + sed \ + -e '/int __bm_stat$/d' \ + -e '/int __checkpoint_presync$/d' \ + -e '/int __compact_uri_analyze$/d' \ + -e '/int __curlog_reset$/d' \ + -e '/int __handle_close_default$/d' \ + -e '/int __handle_progress_default$/d' \ + -e '/int __im_file_close$/d' \ + -e '/int __im_file_lock$/d' \ + -e '/int __im_file_size$/d' \ + -e '/int __im_file_sync$/d' \ + -e '/int __im_fs_directory_list_free$/d' \ + -e '/int __im_fs_exist$/d' \ + -e '/int __posix_file_close$/d' \ + -e '/int __posix_terminate$/d' \ + -e '/int __rec_destroy_session$/d' \ + -e '/int __win_terminate$/d' \ + -e '/int __wt_block_compact_end$/d' \ + -e '/int __wt_block_compact_start$/d' \ + -e '/int __wt_block_manager_size$/d' \ + -e '/int __wt_block_write_size$/d' \ + -e '/int __wt_curjoin_joined$/d' \ + -e '/int __wt_cursor_close$/d' \ + -e '/int __wt_cursor_noop$/d' \ + -e '/int __wt_epoch$/d' \ + -e '/int __wt_errno$/d' \ + -e '/int __wt_get_vm_pagesize$/d' \ + -e '/int __wt_lsm_manager_pop_entry$/d' \ + -e '/int __wt_once$/d' \ + -e '/int __wt_posix_directory_list_free$/d' \ + -e '/int __wt_stat_connection_desc$/d' \ + -e '/int __wt_stat_dsrc_desc$/d' \ + -e '/int __wt_stat_join_desc$/d' \ + -e '/int __wt_win_directory_list_free$/d' \ + -e '/int bdb_compare_reverse$/d' \ + -e '/int csv_terminate$/d' \ + -e '/int demo_file_close$/d' \ + -e '/int demo_file_lock$/d' \ + -e '/int demo_file_size$/d' \ + -e '/int demo_file_sync$/d' \ + -e '/int demo_fs_directory_list_free$/d' \ + -e '/int demo_fs_exist$/d' \ + -e '/int handle_message$/d' \ + -e '/int handle_progress$/d' \ + -e '/int helium_cursor_reset$/d' \ + -e '/int helium_session_verify$/d' \ + -e '/int log_print_err$/d' \ + -e '/int lz4_error$/d' \ + -e '/int lz4_pre_size$/d' \ + -e '/int lz4_terminate$/d' \ + -e '/int main$/d' \ + -e '/int nop_decompress$/d' \ + -e '/int nop_decrypt$/d' \ + -e '/int nop_pre_size$/d' \ + -e '/int nop_sizing$/d' \ + -e '/int nop_terminate$/d' \ + -e '/int nop_terminate$/d' \ + -e '/int os_errno$/d' \ + -e '/int revint_terminate$/d' \ + -e '/int rotn_error$/d' \ + -e '/int rotn_sizing$/d' \ + -e '/int rotn_terminate$/d' \ + -e '/int uri2name$/d' \ + -e '/int usage$/d' \ + -e '/int util_err$/d' \ + -e '/int wiredtiger_extension_init$/d' \ + -e '/int wiredtiger_extension_terminate$/d' \ + -e '/int wiredtiger_pack_close$/d' \ + -e '/int wt_snappy_pre_size$/d' \ + -e '/int wt_snappy_terminate$/d' \ + -e '/int zlib_error$/d' \ + -e '/int zlib_terminate$/d' +} + +# Complain about functions which return an "int" but which don't return except +# at the end of the function. This script is a kluge and isn't run by default. +for f in `find bench ext src test -name '*.[ci]'`; do + if expr "$f" : '.*/windows_shim.c' > /dev/null; then + continue + fi + + # Turn each function into a single line, then discard the function's + # final "return" call, then discard any function that still has some + # form of return assignment or call. + file_parse $f | + sed -e 's/return ([^)]*); }$//' \ + -e '/[A-Z]*_API_CALL[A-Z_]*(/d' \ + -e '/WT_CURSOR_NEEDKEY(/d' \ + -e '/WT_CURSOR_NEEDVALUE(/d' \ + -e '/WT_ERR[A-Z_]*(/d' \ + -e '/WT_ILLEGAL_VALUE[A-Z_]*(/d' \ + -e '/WT_PANIC[A-Z_]*(/d' \ + -e '/WT_RET[A-Z_]*(/d' \ + -e '/WT_TRET(/d' \ + -e '/[^a-z_]ret = /d' \ + -e '/[^a-z_]return (/d' \ + -e 's/^\([^(]*\).*/\1/' \ + -e 's/^ *//' | + func_ok > $t + test -s $t && { + echo "========== $f" + cat $t + } +done diff --git a/src/third_party/wiredtiger/dist/stat.py b/src/third_party/wiredtiger/dist/stat.py index 7961bf7053f..c3c85bbe9b4 100644 --- a/src/third_party/wiredtiger/dist/stat.py +++ b/src/third_party/wiredtiger/dist/stat.py @@ -41,7 +41,16 @@ compare_srcfile(tmp_file, '../src/include/stat.h') def print_defines_one(capname, base, stats): for v, l in enumerate(stats, base): - f.write('/*! %s */\n' % '\n * '.join(textwrap.wrap(l.desc, 70))) + desc = l.desc + if 'all_only' in l.flags: + desc += ', only reported if statistics=all is set' + if len(textwrap.wrap(desc, 70)) > 1: + f.write('/*!\n') + f.write(' * %s\n' % '\n * '.join(textwrap.wrap(desc, 70))) + f.write(' */\n') + else: + f.write('/*! %s */\n' % desc) + #f.write('/*! %s */\n' % '\n * '.join(textwrap.wrap(desc, 70))) f.write('#define\tWT_STAT_' + capname + '_' + l.name.upper() + "\t" * max(1, 6 - int((len('WT_STAT_' + capname + '_' + l.name)) / 8)) + str(v) + '\n') diff --git a/src/third_party/wiredtiger/dist/stat_data.py b/src/third_party/wiredtiger/dist/stat_data.py index af410a341bd..a050849ad76 100644 --- a/src/third_party/wiredtiger/dist/stat_data.py +++ b/src/third_party/wiredtiger/dist/stat_data.py @@ -9,6 +9,7 @@ # # Data-source statistics are normally aggregated across the set of underlying # objects. Additional optional configuration flags are available: +# all_only Only gets reported when statistics=all set # max_aggregate Take the maximum value when aggregating statistics # no_clear Value not cleared when statistics cleared # no_scale Don't scale value per second in the logging tool script @@ -202,7 +203,6 @@ connection_stats = [ CacheStat('cache_eviction_queue_not_empty', 'eviction server candidate queue not empty when topping up'), CacheStat('cache_eviction_server_evicting', 'eviction server evicting pages'), CacheStat('cache_eviction_server_slept', 'eviction server slept, because we did not make progress with eviction'), - CacheStat('cache_eviction_server_toobig', 'eviction server skipped very large page'), CacheStat('cache_eviction_slow', 'eviction server unable to reach eviction goal'), CacheStat('cache_eviction_split_internal', 'internal pages split during eviction'), CacheStat('cache_eviction_split_leaf', 'leaf pages split during eviction'), @@ -421,13 +421,13 @@ dsrc_stats = [ # Btree statistics ########################################## BtreeStat('btree_checkpoint_generation', 'btree checkpoint generation', 'no_clear,no_scale'), - BtreeStat('btree_column_deleted', 'column-store variable-size deleted values', 'no_scale'), - BtreeStat('btree_column_fix', 'column-store fixed-size leaf pages', 'no_scale'), - BtreeStat('btree_column_internal', 'column-store internal pages', 'no_scale'), - BtreeStat('btree_column_rle', 'column-store variable-size RLE encoded values', 'no_scale'), - BtreeStat('btree_column_variable', 'column-store variable-size leaf pages', 'no_scale'), + BtreeStat('btree_column_deleted', 'column-store variable-size deleted values', 'no_scale,all_only'), + BtreeStat('btree_column_fix', 'column-store fixed-size leaf pages', 'no_scale,all_only'), + BtreeStat('btree_column_internal', 'column-store internal pages', 'no_scale,all_only'), + BtreeStat('btree_column_rle', 'column-store variable-size RLE encoded values', 'no_scale,all_only'), + BtreeStat('btree_column_variable', 'column-store variable-size leaf pages', 'no_scale,all_only'), BtreeStat('btree_compact_rewrite', 'pages rewritten by compaction'), - BtreeStat('btree_entries', 'number of key/value pairs', 'no_scale'), + BtreeStat('btree_entries', 'number of key/value pairs', 'no_scale,all_only'), BtreeStat('btree_fixed_len', 'fixed-record size', 'max_aggregate,no_scale,size'), BtreeStat('btree_maximum_depth', 'maximum tree depth', 'max_aggregate,no_scale'), BtreeStat('btree_maxintlkey', 'maximum internal page key size', 'max_aggregate,no_scale,size'), @@ -435,9 +435,9 @@ dsrc_stats = [ BtreeStat('btree_maxleafkey', 'maximum leaf page key size', 'max_aggregate,no_scale,size'), BtreeStat('btree_maxleafpage', 'maximum leaf page size', 'max_aggregate,no_scale,size'), BtreeStat('btree_maxleafvalue', 'maximum leaf page value size', 'max_aggregate,no_scale,size'), - BtreeStat('btree_overflow', 'overflow pages', 'no_scale'), - BtreeStat('btree_row_internal', 'row-store internal pages', 'no_scale'), - BtreeStat('btree_row_leaf', 'row-store leaf pages', 'no_scale'), + BtreeStat('btree_overflow', 'overflow pages', 'no_scale,all_only'), + BtreeStat('btree_row_internal', 'row-store internal pages', 'no_scale,all_only'), + BtreeStat('btree_row_leaf', 'row-store leaf pages', 'no_scale,all_only'), ########################################## # LSM statistics diff --git a/src/third_party/wiredtiger/examples/c/ex_encrypt.c b/src/third_party/wiredtiger/examples/c/ex_encrypt.c index 3b3323bc091..5d5cc66c87f 100644 --- a/src/third_party/wiredtiger/examples/c/ex_encrypt.c +++ b/src/third_party/wiredtiger/examples/c/ex_encrypt.c @@ -76,12 +76,12 @@ typedef struct { #define IV_LEN 16 /* - * make_cksum -- + * make_checksum -- * This is where one would call a checksum function on the encrypted * buffer. Here we just put a constant value in it. */ static void -make_cksum(uint8_t *dst) +make_checksum(uint8_t *dst) { int i; /* @@ -220,7 +220,7 @@ rotate_encrypt(WT_ENCRYPTOR *encryptor, WT_SESSION *session, * Checksum the encrypted buffer and add the IV. */ i = 0; - make_cksum(&dst[i]); + make_checksum(&dst[i]); i += CHKSUM_LEN; make_iv(&dst[i]); *result_lenp = dst_len; diff --git a/src/third_party/wiredtiger/ext/collators/revint/revint_collator.c b/src/third_party/wiredtiger/ext/collators/revint/revint_collator.c index 30b5dc67556..b8ebbdc8585 100644 --- a/src/third_party/wiredtiger/ext/collators/revint/revint_collator.c +++ b/src/third_party/wiredtiger/ext/collators/revint/revint_collator.c @@ -54,8 +54,8 @@ revint_compare(WT_COLLATOR *collator, const REVINT_COLLATOR *revint_collator; WT_EXTENSION_API *wtapi; WT_PACK_STREAM *pstream; - int ret; int64_t i1, i2, p1, p2; + int ret; i1 = i2 = p1 = p2 = 0; revint_collator = (const REVINT_COLLATOR *)collator; @@ -82,23 +82,23 @@ revint_compare(WT_COLLATOR *collator, if ((ret = wtapi->unpack_start( wtapi, session, "ii", k1->data, k1->size, &pstream)) != 0 || (ret = wtapi->unpack_int(wtapi, pstream, &i1)) != 0) - goto err; + return (ret); if ((ret = wtapi->unpack_int(wtapi, pstream, &p1)) != 0) /* A missing primary key is OK and sorts first. */ p1 = INT64_MIN; if ((ret = wtapi->pack_close(wtapi, pstream, NULL)) != 0) - goto err; + return (ret); /* Unpack the second pair of numbers. */ if ((ret = wtapi->unpack_start( wtapi, session, "ii", k2->data, k2->size, &pstream)) != 0 || (ret = wtapi->unpack_int(wtapi, pstream, &i2)) != 0) - goto err; + return (ret); if ((ret = wtapi->unpack_int(wtapi, pstream, &p2)) != 0) /* A missing primary key is OK and sorts first. */ p2 = INT64_MIN; if ((ret = wtapi->pack_close(wtapi, pstream, NULL)) != 0) - goto err; + return (ret); /* sorting is reversed */ if (i1 < i2) @@ -113,7 +113,7 @@ revint_compare(WT_COLLATOR *collator, else *cmp = 0; /* index key and primary key are same */ -err: return (ret); + return (0); } /* diff --git a/src/third_party/wiredtiger/ext/encryptors/rotn/rotn_encrypt.c b/src/third_party/wiredtiger/ext/encryptors/rotn/rotn_encrypt.c index 3b5379ca410..4d614e2e409 100644 --- a/src/third_party/wiredtiger/ext/encryptors/rotn/rotn_encrypt.c +++ b/src/third_party/wiredtiger/ext/encryptors/rotn/rotn_encrypt.c @@ -101,12 +101,12 @@ rotn_error(ROTN_ENCRYPTOR *encryptor, WT_SESSION *session, int err, } /* - * make_cksum -- + * make_checksum -- * This is where one would call a checksum function on the encrypted * buffer. Here we just put a constant value in it. */ static void -make_cksum(uint8_t *dst) +make_checksum(uint8_t *dst) { int i; /* @@ -212,7 +212,7 @@ rotn_encrypt(WT_ENCRYPTOR *encryptor, WT_SESSION *session, * Checksum the encrypted buffer and add the IV. */ i = 0; - make_cksum(&dst[i]); + make_checksum(&dst[i]); i += CHKSUM_LEN; make_iv(&dst[i]); *result_lenp = dst_len; diff --git a/src/third_party/wiredtiger/lang/java/Makefile.am b/src/third_party/wiredtiger/lang/java/Makefile.am index 192e44a05d2..7184fe610dc 100644 --- a/src/third_party/wiredtiger/lang/java/Makefile.am +++ b/src/third_party/wiredtiger/lang/java/Makefile.am @@ -46,6 +46,7 @@ JAVA_JUNIT = \ $(JAVATEST)/AsyncTest.java \ $(JAVATEST)/BackupCursorTest.java \ $(JAVATEST)/ConfigTest.java \ + $(JAVATEST)/ConcurrentCloseTest.java \ $(JAVATEST)/CursorTest.java \ $(JAVATEST)/CursorTest02.java \ $(JAVATEST)/ExceptionTest.java \ diff --git a/src/third_party/wiredtiger/lang/java/wiredtiger.i b/src/third_party/wiredtiger/lang/java/wiredtiger.i index c04bae63cbc..d6e0660dc2c 100644 --- a/src/third_party/wiredtiger/lang/java/wiredtiger.i +++ b/src/third_party/wiredtiger/lang/java/wiredtiger.i @@ -240,7 +240,6 @@ WT_CLASS(type, class, name) %typemap(freearg, numinputs=0) class ## _CLOSED *name { closeHandler(jenv, savesess2, jcb2); - priv = NULL; } %enddef diff --git a/src/third_party/wiredtiger/src/async/async_api.c b/src/third_party/wiredtiger/src/async/async_api.c index d55732abfb5..0a855514a07 100644 --- a/src/third_party/wiredtiger/src/async/async_api.c +++ b/src/third_party/wiredtiger/src/async/async_api.c @@ -541,7 +541,7 @@ retry: async->flush_op.state = WT_ASYNCOP_READY; WT_RET(__wt_async_op_enqueue(session, &async->flush_op)); while (async->flush_state != WT_ASYNC_FLUSH_COMPLETE) - __wt_cond_wait(NULL, async->flush_cond, 100000); + __wt_cond_wait(session, async->flush_cond, 100000); /* * Flush is done. Clear the flags. */ diff --git a/src/third_party/wiredtiger/src/async/async_op.c b/src/third_party/wiredtiger/src/async/async_op.c index 970c33c3360..2bdc9e4ec8e 100644 --- a/src/third_party/wiredtiger/src/async/async_op.c +++ b/src/third_party/wiredtiger/src/async/async_op.c @@ -205,7 +205,7 @@ __async_get_type(WT_ASYNC_OP *asyncop) * __async_op_init -- * Initialize all the op handle fields. */ -static int +static void __async_op_init(WT_CONNECTION_IMPL *conn, WT_ASYNC_OP_IMPL *op, uint32_t id) { WT_ASYNC_OP *asyncop; @@ -243,7 +243,6 @@ __async_op_init(WT_CONNECTION_IMPL *conn, WT_ASYNC_OP_IMPL *op, uint32_t id) op->internal_id = id; op->state = WT_ASYNCOP_FREE; - return (0); } /* @@ -330,7 +329,7 @@ __wt_async_op_init(WT_SESSION_IMPL *session) /* * Initialize the flush op structure. */ - WT_RET(__async_op_init(conn, &async->flush_op, OPS_INVALID_INDEX)); + __async_op_init(conn, &async->flush_op, OPS_INVALID_INDEX); /* * Allocate and initialize the work queue. This is sized so that @@ -346,7 +345,7 @@ __wt_async_op_init(WT_SESSION_IMPL *session) WT_ERR(__wt_calloc_def(session, conn->async_size, &async->async_ops)); for (i = 0; i < conn->async_size; i++) { op = &async->async_ops[i]; - WT_ERR(__async_op_init(conn, op, i)); + __async_op_init(conn, op, i); } return (0); diff --git a/src/third_party/wiredtiger/src/block/block_addr.c b/src/third_party/wiredtiger/src/block/block_addr.c index d8cc1d627cf..dadd17de4a6 100644 --- a/src/third_party/wiredtiger/src/block/block_addr.c +++ b/src/third_party/wiredtiger/src/block/block_addr.c @@ -15,7 +15,7 @@ */ static int __block_buffer_to_addr(uint32_t allocsize, - const uint8_t **pp, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump) + const uint8_t **pp, wt_off_t *offsetp, uint32_t *sizep, uint32_t *checksump) { uint64_t o, s, c; @@ -37,11 +37,11 @@ __block_buffer_to_addr(uint32_t allocsize, */ if (s == 0) { *offsetp = 0; - *sizep = *cksump = 0; + *sizep = *checksump = 0; } else { *offsetp = (wt_off_t)(o + 1) * allocsize; *sizep = (uint32_t)s * allocsize; - *cksump = (uint32_t)c; + *checksump = (uint32_t)c; } return (0); } @@ -52,7 +52,7 @@ __block_buffer_to_addr(uint32_t allocsize, */ int __wt_block_addr_to_buffer(WT_BLOCK *block, - uint8_t **pp, wt_off_t offset, uint32_t size, uint32_t cksum) + uint8_t **pp, wt_off_t offset, uint32_t size, uint32_t checksum) { uint64_t o, s, c; @@ -63,7 +63,7 @@ __wt_block_addr_to_buffer(WT_BLOCK *block, } else { o = (uint64_t)offset / block->allocsize - 1; s = size / block->allocsize; - c = cksum; + c = checksum; } WT_RET(__wt_vpack_uint(pp, 0, o)); WT_RET(__wt_vpack_uint(pp, 0, s)); @@ -78,10 +78,10 @@ __wt_block_addr_to_buffer(WT_BLOCK *block, */ int __wt_block_buffer_to_addr(WT_BLOCK *block, - const uint8_t *p, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump) + const uint8_t *p, wt_off_t *offsetp, uint32_t *sizep, uint32_t *checksump) { return (__block_buffer_to_addr( - block->allocsize, &p, offsetp, sizep, cksump)); + block->allocsize, &p, offsetp, sizep, checksump)); } /* @@ -93,14 +93,15 @@ __wt_block_addr_invalid(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool live) { wt_off_t offset; - uint32_t cksum, size; + uint32_t checksum, size; WT_UNUSED(session); WT_UNUSED(addr_size); WT_UNUSED(live); /* Crack the cookie. */ - WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); + WT_RET( + __wt_block_buffer_to_addr(block, addr, &offset, &size, &checksum)); #ifdef HAVE_DIAGNOSTIC /* @@ -124,17 +125,18 @@ __wt_block_addr_string(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, const uint8_t *addr, size_t addr_size) { wt_off_t offset; - uint32_t cksum, size; + uint32_t checksum, size; WT_UNUSED(addr_size); /* Crack the cookie. */ - WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); + WT_RET( + __wt_block_buffer_to_addr(block, addr, &offset, &size, &checksum)); /* Printable representation. */ WT_RET(__wt_buf_fmt(session, buf, "[%" PRIuMAX "-%" PRIuMAX ", %" PRIu32 ", %" PRIu32 "]", - (uintmax_t)offset, (uintmax_t)offset + size, size, cksum)); + (uintmax_t)offset, (uintmax_t)offset + size, size, checksum)); return (0); } @@ -156,13 +158,13 @@ __block_buffer_to_ckpt(WT_SESSION_IMPL *session, pp = &p; WT_RET(__block_buffer_to_addr(allocsize, pp, - &ci->root_offset, &ci->root_size, &ci->root_cksum)); + &ci->root_offset, &ci->root_size, &ci->root_checksum)); WT_RET(__block_buffer_to_addr(allocsize, pp, - &ci->alloc.offset, &ci->alloc.size, &ci->alloc.cksum)); + &ci->alloc.offset, &ci->alloc.size, &ci->alloc.checksum)); WT_RET(__block_buffer_to_addr(allocsize, pp, - &ci->avail.offset, &ci->avail.size, &ci->avail.cksum)); + &ci->avail.offset, &ci->avail.size, &ci->avail.checksum)); WT_RET(__block_buffer_to_addr(allocsize, pp, - &ci->discard.offset, &ci->discard.size, &ci->discard.cksum)); + &ci->discard.offset, &ci->discard.size, &ci->discard.checksum)); WT_RET(__wt_vunpack_uint(pp, 0, &a)); ci->file_size = (wt_off_t)a; WT_RET(__wt_vunpack_uint(pp, 0, &a)); @@ -214,13 +216,13 @@ __wt_block_ckpt_to_buffer(WT_SESSION_IMPL *session, (*pp)++; WT_RET(__wt_block_addr_to_buffer(block, pp, - ci->root_offset, ci->root_size, ci->root_cksum)); + ci->root_offset, ci->root_size, ci->root_checksum)); WT_RET(__wt_block_addr_to_buffer(block, pp, - ci->alloc.offset, ci->alloc.size, ci->alloc.cksum)); + ci->alloc.offset, ci->alloc.size, ci->alloc.checksum)); WT_RET(__wt_block_addr_to_buffer(block, pp, - ci->avail.offset, ci->avail.size, ci->avail.cksum)); + ci->avail.offset, ci->avail.size, ci->avail.checksum)); WT_RET(__wt_block_addr_to_buffer(block, pp, - ci->discard.offset, ci->discard.size, ci->discard.cksum)); + ci->discard.offset, ci->discard.size, ci->discard.checksum)); a = (uint64_t)ci->file_size; WT_RET(__wt_vpack_uint(pp, 0, a)); a = (uint64_t)ci->ckpt_size; diff --git a/src/third_party/wiredtiger/src/block/block_ckpt.c b/src/third_party/wiredtiger/src/block/block_ckpt.c index 1e7f4ff09ae..b7ac953cdb1 100644 --- a/src/third_party/wiredtiger/src/block/block_ckpt.c +++ b/src/third_party/wiredtiger/src/block/block_ckpt.c @@ -117,7 +117,7 @@ __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block, if (ci->root_offset != WT_BLOCK_INVALID_OFFSET) { endp = root_addr; WT_ERR(__wt_block_addr_to_buffer(block, &endp, - ci->root_offset, ci->root_size, ci->root_cksum)); + ci->root_offset, ci->root_size, ci->root_checksum)); *root_addr_sizep = WT_PTRDIFF(endp, root_addr); } @@ -216,7 +216,7 @@ __wt_block_ckpt_destroy(WT_SESSION_IMPL *session, WT_BLOCK_CKPT *ci) */ int __wt_block_checkpoint(WT_SESSION_IMPL *session, - WT_BLOCK *block, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_cksum) + WT_BLOCK *block, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_checksum) { WT_BLOCK_CKPT *ci; WT_DECL_RET; @@ -237,11 +237,11 @@ __wt_block_checkpoint(WT_SESSION_IMPL *session, */ if (buf == NULL) { ci->root_offset = WT_BLOCK_INVALID_OFFSET; - ci->root_size = ci->root_cksum = 0; + ci->root_size = ci->root_checksum = 0; } else WT_ERR(__wt_block_write_off(session, block, buf, - &ci->root_offset, &ci->root_size, &ci->root_cksum, - data_cksum, true, false)); + &ci->root_offset, &ci->root_size, &ci->root_checksum, + data_checksum, true, false)); /* * Checkpoints are potentially reading/writing/merging lots of blocks, @@ -362,10 +362,10 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) WT_DECL_ITEM(tmp); WT_DECL_RET; uint64_t ckpt_size; - bool deleting, locked; + bool deleting, fatal, locked; ci = &block->live; - locked = false; + fatal = locked = false; #ifdef HAVE_DIAGNOSTIC WT_RET(__ckpt_verify(session, ckptbase)); @@ -391,23 +391,20 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) * This function is the first step, the second step is in the resolve * function. * - * If we're called to checkpoint the same file twice, without the second - * resolution step, it's an error at an upper level and our choices are - * all bad: either leak blocks or risk crashing with our caller not - * having saved the checkpoint information to stable storage. Leaked - * blocks are a safer choice, but that means file verify will fail for - * the rest of "forever", and the chance of us allocating a block and - * then crashing such that it matters is reasonably low: don't leak the - * blocks. + * If we're called to checkpoint the same file twice (without the second + * resolution step), or re-entered for any reason, it's an error in our + * caller, and our choices are all bad: leak blocks or potentially crash + * with our caller not yet having saved previous checkpoint information + * to stable storage. */ - if (block->ckpt_inprogress) { - __wt_errx(session, - "%s: checkpointed without first resolving the previous " - "checkpoint", - block->name); - - WT_RET(__wt_block_checkpoint_resolve(session, block)); - } + __wt_spin_lock(session, &block->live_lock); + if (block->ckpt_inprogress) + ret = __wt_block_panic(session, EINVAL, + "%s: unexpected checkpoint ordering", block->name); + else + block->ckpt_inprogress = true; + __wt_spin_unlock(session, &block->live_lock); + WT_RET(ret); /* * Extents newly available as a result of deleting previous checkpoints @@ -464,6 +461,15 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) } /* + * Failures are now fatal: we can't currently back out the merge of any + * deleted checkpoint extent lists into the live system's extent lists, + * so continuing after error would leave the live system's extent lists + * corrupted for any subsequent checkpoint (and potentially, should a + * subsequent checkpoint succeed, for recovery). + */ + fatal = true; + + /* * Hold a lock so the live extent lists and the file size can't change * underneath us. I suspect we'll tighten this if checkpoints take too * much time away from real work: we read the historic checkpoint @@ -653,9 +659,11 @@ live_update: "list"); #endif - block->ckpt_inprogress = true; +err: if (ret != 0 && fatal) + ret = __wt_block_panic(session, ret, + "%s: fatal checkpoint failure", block->name); -err: if (locked) + if (locked) __wt_spin_unlock(session, &block->live_lock); /* Discard any checkpoint information we loaded. */ @@ -767,15 +775,16 @@ __wt_block_checkpoint_resolve(WT_SESSION_IMPL *session, WT_BLOCK *block) * Resolve the checkpoint after our caller has written the checkpoint * information to stable storage. */ - if (!block->ckpt_inprogress) - WT_RET_MSG(session, WT_ERROR, - "%s: checkpoint resolved, but no checkpoint in progress", - block->name); - block->ckpt_inprogress = false; - __wt_spin_lock(session, &block->live_lock); - ret = __wt_block_extlist_merge( - session, block, &ci->ckpt_avail, &ci->avail); + if (!block->ckpt_inprogress) + WT_ERR(__wt_block_panic(session, WT_ERROR, + "%s: checkpoint resolution with no checkpoint in progress", + block->name)); + + if ((ret = __wt_block_extlist_merge( + session, block, &ci->ckpt_avail, &ci->avail)) != 0) + WT_ERR(__wt_block_panic(session, ret, + "%s: fatal checkpoint failure", block->name)); __wt_spin_unlock(session, &block->live_lock); /* Discard the lists remaining after the checkpoint call. */ @@ -783,6 +792,10 @@ __wt_block_checkpoint_resolve(WT_SESSION_IMPL *session, WT_BLOCK *block) __wt_block_extlist_free(session, &ci->ckpt_alloc); __wt_block_extlist_free(session, &ci->ckpt_discard); + __wt_spin_lock(session, &block->live_lock); + block->ckpt_inprogress = 0; +err: __wt_spin_unlock(session, &block->live_lock); + return (ret); } @@ -811,7 +824,7 @@ __ckpt_string(WT_SESSION_IMPL *session, PRIuMAX "-%" PRIuMAX ", %" PRIu32 ", %" PRIu32 "]", (uintmax_t)ci->root_offset, (uintmax_t)(ci->root_offset + ci->root_size), - ci->root_size, ci->root_cksum)); + ci->root_size, ci->root_checksum)); if (ci->alloc.offset == WT_BLOCK_INVALID_OFFSET) WT_RET(__wt_buf_catfmt(session, buf, ", alloc=[Empty]")); else @@ -820,7 +833,7 @@ __ckpt_string(WT_SESSION_IMPL *session, PRIuMAX "-%" PRIuMAX ", %" PRIu32 ", %" PRIu32 "]", (uintmax_t)ci->alloc.offset, (uintmax_t)(ci->alloc.offset + ci->alloc.size), - ci->alloc.size, ci->alloc.cksum)); + ci->alloc.size, ci->alloc.checksum)); if (ci->avail.offset == WT_BLOCK_INVALID_OFFSET) WT_RET(__wt_buf_catfmt(session, buf, ", avail=[Empty]")); else @@ -829,7 +842,7 @@ __ckpt_string(WT_SESSION_IMPL *session, PRIuMAX "-%" PRIuMAX ", %" PRIu32 ", %" PRIu32 "]", (uintmax_t)ci->avail.offset, (uintmax_t)(ci->avail.offset + ci->avail.size), - ci->avail.size, ci->avail.cksum)); + ci->avail.size, ci->avail.checksum)); if (ci->discard.offset == WT_BLOCK_INVALID_OFFSET) WT_RET(__wt_buf_catfmt(session, buf, ", discard=[Empty]")); else @@ -838,7 +851,7 @@ __ckpt_string(WT_SESSION_IMPL *session, PRIuMAX "-%" PRIuMAX ", %" PRIu32 ", %" PRIu32 "]", (uintmax_t)ci->discard.offset, (uintmax_t)(ci->discard.offset + ci->discard.size), - ci->discard.size, ci->discard.cksum)); + ci->discard.size, ci->discard.checksum)); WT_RET(__wt_buf_catfmt(session, buf, ", file size=%" PRIuMAX, (uintmax_t)ci->file_size)); diff --git a/src/third_party/wiredtiger/src/block/block_compact.c b/src/third_party/wiredtiger/src/block/block_compact.c index a5e510445cc..6d5d48bdb22 100644 --- a/src/third_party/wiredtiger/src/block/block_compact.c +++ b/src/third_party/wiredtiger/src/block/block_compact.c @@ -157,13 +157,14 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session, WT_EXT *ext; WT_EXTLIST *el; wt_off_t limit, offset; - uint32_t size, cksum; + uint32_t size, checksum; WT_UNUSED(addr_size); *skipp = true; /* Return a default skip. */ /* Crack the cookie. */ - WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); + WT_RET( + __wt_block_buffer_to_addr(block, addr, &offset, &size, &checksum)); /* * If this block is in the chosen percentage of the file and there's a @@ -221,11 +222,11 @@ __block_dump_avail(WT_SESSION_IMPL *session, WT_BLOCK *block, bool start) if (!start) { __wt_verbose(session, WT_VERB_COMPACT, - "pages reviewed: %" PRIuMAX, block->compact_pages_reviewed); + "pages reviewed: %" PRIu64, block->compact_pages_reviewed); __wt_verbose(session, WT_VERB_COMPACT, - "pages skipped: %" PRIuMAX, block->compact_pages_skipped); + "pages skipped: %" PRIu64, block->compact_pages_skipped); __wt_verbose(session, WT_VERB_COMPACT, - "pages written: %" PRIuMAX, block->compact_pages_written); + "pages written: %" PRIu64, block->compact_pages_written); } __wt_verbose(session, WT_VERB_COMPACT, diff --git a/src/third_party/wiredtiger/src/block/block_ext.c b/src/third_party/wiredtiger/src/block/block_ext.c index d618bf70010..8a4d2b08bef 100644 --- a/src/third_party/wiredtiger/src/block/block_ext.c +++ b/src/third_party/wiredtiger/src/block/block_ext.c @@ -587,13 +587,14 @@ __wt_block_free(WT_SESSION_IMPL *session, { WT_DECL_RET; wt_off_t offset; - uint32_t cksum, size; + uint32_t checksum, size; WT_UNUSED(addr_size); WT_STAT_FAST_DATA_INCR(session, block_free); /* Crack the cookie. */ - WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); + WT_RET( + __wt_block_buffer_to_addr(block, addr, &offset, &size, &checksum)); __wt_verbose(session, WT_VERB_BLOCK, "free %" PRIdMAX "/%" PRIdMAX, (intmax_t)offset, (intmax_t)size); @@ -1174,7 +1175,7 @@ __wt_block_extlist_read(WT_SESSION_IMPL *session, WT_RET(__wt_scr_alloc(session, el->size, &tmp)); WT_ERR(__wt_block_read_off( - session, block, tmp, el->offset, el->size, el->cksum)); + session, block, tmp, el->offset, el->size, el->checksum)); #define WT_EXTLIST_READ(p, v) do { \ uint64_t _v; \ @@ -1257,7 +1258,7 @@ __wt_block_extlist_write(WT_SESSION_IMPL *session, entries = el->entries + (additional == NULL ? 0 : additional->entries); if (entries == 0) { el->offset = WT_BLOCK_INVALID_OFFSET; - el->cksum = el->size = 0; + el->checksum = el->size = 0; return (0); } @@ -1309,8 +1310,8 @@ __wt_block_extlist_write(WT_SESSION_IMPL *session, #endif /* Write the extent list to disk. */ - WT_ERR(__wt_block_write_off(session, - block, tmp, &el->offset, &el->size, &el->cksum, true, true, true)); + WT_ERR(__wt_block_write_off(session, block, + tmp, &el->offset, &el->size, &el->checksum, true, true, true)); /* * Remove the allocated blocks from the system's allocation list, extent diff --git a/src/third_party/wiredtiger/src/block/block_mgr.c b/src/third_party/wiredtiger/src/block/block_mgr.c index eff25f34304..653ae3dbb6b 100644 --- a/src/third_party/wiredtiger/src/block/block_mgr.c +++ b/src/third_party/wiredtiger/src/block/block_mgr.c @@ -61,11 +61,11 @@ __bm_block_header(WT_BM *bm) * Write a buffer into a block, creating a checkpoint. */ static int -__bm_checkpoint(WT_BM *bm, - WT_SESSION_IMPL *session, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_cksum) +__bm_checkpoint(WT_BM *bm, WT_SESSION_IMPL *session, + WT_ITEM *buf, WT_CKPT *ckptbase, bool data_checksum) { return (__wt_block_checkpoint( - session, bm->block, buf, ckptbase, data_cksum)); + session, bm->block, buf, ckptbase, data_checksum)); } /* @@ -73,12 +73,12 @@ __bm_checkpoint(WT_BM *bm, * Write a buffer into a block, creating a checkpoint; readonly version. */ static int -__bm_checkpoint_readonly(WT_BM *bm, - WT_SESSION_IMPL *session, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_cksum) +__bm_checkpoint_readonly(WT_BM *bm, WT_SESSION_IMPL *session, + WT_ITEM *buf, WT_CKPT *ckptbase, bool data_checksum) { WT_UNUSED(buf); WT_UNUSED(ckptbase); - WT_UNUSED(data_cksum); + WT_UNUSED(data_checksum); return (__bm_readonly(bm, session)); } @@ -480,10 +480,10 @@ __bm_verify_start(WT_BM *bm, */ static int __bm_write(WT_BM *bm, WT_SESSION_IMPL *session, WT_ITEM *buf, - uint8_t *addr, size_t *addr_sizep, bool data_cksum, bool checkpoint_io) + uint8_t *addr, size_t *addr_sizep, bool data_checksum, bool checkpoint_io) { return (__wt_block_write(session, - bm->block, buf, addr, addr_sizep, data_cksum, checkpoint_io)); + bm->block, buf, addr, addr_sizep, data_checksum, checkpoint_io)); } /* @@ -493,12 +493,12 @@ __bm_write(WT_BM *bm, WT_SESSION_IMPL *session, WT_ITEM *buf, */ static int __bm_write_readonly(WT_BM *bm, WT_SESSION_IMPL *session, WT_ITEM *buf, - uint8_t *addr, size_t *addr_sizep, bool data_cksum, bool checkpoint_io) + uint8_t *addr, size_t *addr_sizep, bool data_checksum, bool checkpoint_io) { WT_UNUSED(buf); WT_UNUSED(addr); WT_UNUSED(addr_sizep); - WT_UNUSED(data_cksum); + WT_UNUSED(data_checksum); WT_UNUSED(checkpoint_io); return (__bm_readonly(bm, session)); @@ -607,3 +607,28 @@ __wt_block_manager_open(WT_SESSION_IMPL *session, err: WT_TRET(bm->close(bm, session)); return (ret); } + +/* + * __wt_block_panic -- + * Report an error, then panic the handle and the system. + */ +int +__wt_block_panic(WT_SESSION_IMPL *session, int error, const char *fmt, ...) + WT_GCC_FUNC_ATTRIBUTE((cold)) + WT_GCC_FUNC_ATTRIBUTE((format (printf, 3, 4))) +{ + va_list ap; + + /* + * Ignore error returns from underlying event handlers, we already have + * an error value to return. + */ + va_start(ap, fmt); + WT_IGNORE_RET(__wt_eventv(session, false, error, NULL, 0, fmt, ap)); + va_end(ap); + + /* Switch the handle into read-only mode. */ + __bm_method_set(S2BT(session)->bm, true); + + return (__wt_panic(session)); +} diff --git a/src/third_party/wiredtiger/src/block/block_open.c b/src/third_party/wiredtiger/src/block/block_open.c index b975f1612cc..e369d013437 100644 --- a/src/third_party/wiredtiger/src/block/block_open.c +++ b/src/third_party/wiredtiger/src/block/block_open.c @@ -290,11 +290,11 @@ __wt_desc_write(WT_SESSION_IMPL *session, WT_FH *fh, uint32_t allocsize) desc->magic = WT_BLOCK_MAGIC; desc->majorv = WT_BLOCK_MAJOR_VERSION; desc->minorv = WT_BLOCK_MINOR_VERSION; - desc->cksum = 0; + desc->checksum = 0; __wt_block_desc_byteswap(desc); - desc->cksum = __wt_cksum(desc, allocsize); + desc->checksum = __wt_checksum(desc, allocsize); #ifdef WORDS_BIGENDIAN - desc->cksum = __wt_bswap32(desc->cksum); + desc->checksum = __wt_bswap32(desc->checksum); #endif ret = __wt_write(session, fh, (wt_off_t)0, (size_t)allocsize, desc); @@ -312,7 +312,7 @@ __desc_read(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_BLOCK_DESC *desc; WT_DECL_ITEM(buf); WT_DECL_RET; - uint32_t cksum_calculate, cksum_tmp; + uint32_t checksum_calculate, checksum_tmp; /* If in-memory, we don't read or write the descriptor structure. */ if (F_ISSET(S2C(session), WT_CONN_IN_MEMORY)) @@ -333,10 +333,10 @@ __desc_read(WT_SESSION_IMPL *session, WT_BLOCK *block) * a calculated checksum that should match the checksum in the header. */ desc = buf->mem; - cksum_tmp = desc->cksum; - desc->cksum = 0; - cksum_calculate = __wt_cksum(desc, block->allocsize); - desc->cksum = cksum_tmp; + checksum_tmp = desc->checksum; + desc->checksum = 0; + checksum_calculate = __wt_checksum(desc, block->allocsize); + desc->checksum = checksum_tmp; __wt_block_desc_byteswap(desc); /* @@ -348,7 +348,8 @@ __desc_read(WT_SESSION_IMPL *session, WT_BLOCK *block) * may have entered the wrong file name, and is now frantically pounding * their interrupt key. */ - if (desc->magic != WT_BLOCK_MAGIC || desc->cksum != cksum_calculate) + if (desc->magic != WT_BLOCK_MAGIC || + desc->checksum != checksum_calculate) WT_ERR_MSG(session, WT_ERROR, "%s does not appear to be a WiredTiger file", block->name); @@ -368,7 +369,7 @@ __desc_read(WT_SESSION_IMPL *session, WT_BLOCK *block) ", checksum %#" PRIx32, block->name, desc->magic, desc->majorv, desc->minorv, - desc->cksum); + desc->checksum); err: __wt_scr_free(session, &buf); return (ret); diff --git a/src/third_party/wiredtiger/src/block/block_read.c b/src/third_party/wiredtiger/src/block/block_read.c index 6706800409c..c6005b1f60a 100644 --- a/src/third_party/wiredtiger/src/block/block_read.c +++ b/src/third_party/wiredtiger/src/block/block_read.c @@ -21,7 +21,7 @@ __wt_bm_preload( WT_DECL_RET; WT_FILE_HANDLE *handle; wt_off_t offset; - uint32_t cksum, size; + uint32_t checksum, size; bool mapped; WT_UNUSED(addr_size); @@ -31,7 +31,8 @@ __wt_bm_preload( WT_STAT_FAST_CONN_INCR(session, block_preload); /* Crack the cookie. */ - WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); + WT_RET( + __wt_block_buffer_to_addr(block, addr, &offset, &size, &checksum)); handle = block->fh->handle; mapped = bm->map != NULL && offset + size <= (wt_off_t)bm->maplen; @@ -64,14 +65,15 @@ __wt_bm_read(WT_BM *bm, WT_SESSION_IMPL *session, WT_DECL_RET; WT_FILE_HANDLE *handle; wt_off_t offset; - uint32_t cksum, size; + uint32_t checksum, size; bool mapped; WT_UNUSED(addr_size); block = bm->block; /* Crack the cookie. */ - WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); + WT_RET( + __wt_block_buffer_to_addr(block, addr, &offset, &size, &checksum)); /* * Map the block if it's possible. @@ -98,7 +100,8 @@ __wt_bm_read(WT_BM *bm, WT_SESSION_IMPL *session, session, block, "read", offset, size, bm->is_live)); #endif /* Read the block. */ - WT_RET(__wt_block_read_off(session, block, buf, offset, size, cksum)); + WT_RET( + __wt_block_read_off(session, block, buf, offset, size, checksum)); /* Optionally discard blocks from the system's buffer cache. */ WT_RET(__wt_block_discard(session, block, (size_t)size)); @@ -117,7 +120,7 @@ __wt_block_read_off_blind( WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, wt_off_t offset) { WT_BLOCK_HEADER *blk; - uint32_t cksum, size; + uint32_t checksum, size; /* * Make sure the buffer is large enough for the header and read the @@ -134,13 +137,14 @@ __wt_block_read_off_blind( * and if the size isn't insane, read the rest of the block. */ size = blk->disk_size; - cksum = blk->cksum; + checksum = blk->checksum; if (__wt_block_offset_invalid(block, offset, size)) WT_RET_MSG(session, EINVAL, "block at offset %" PRIuMAX " cannot be a valid block, no " "read attempted", (uintmax_t)offset); - return (__wt_block_read_off(session, block, buf, offset, size, cksum)); + return ( + __wt_block_read_off(session, block, buf, offset, size, checksum)); } #endif @@ -150,15 +154,15 @@ __wt_block_read_off_blind( */ int __wt_block_read_off(WT_SESSION_IMPL *session, WT_BLOCK *block, - WT_ITEM *buf, wt_off_t offset, uint32_t size, uint32_t cksum) + WT_ITEM *buf, wt_off_t offset, uint32_t size, uint32_t checksum) { WT_BLOCK_HEADER *blk, swap; size_t bufsize; - uint32_t page_cksum; + uint32_t page_checksum; __wt_verbose(session, WT_VERB_READ, - "off %" PRIuMAX ", size %" PRIu32 ", cksum %" PRIu32, - (uintmax_t)offset, size, cksum); + "off %" PRIuMAX ", size %" PRIu32 ", checksum %" PRIu32, + (uintmax_t)offset, size, checksum); WT_STAT_FAST_CONN_INCR(session, block_read); WT_STAT_FAST_CONN_INCRV(session, block_byte_read, size); @@ -189,12 +193,12 @@ __wt_block_read_off(WT_SESSION_IMPL *session, WT_BLOCK *block, */ blk = WT_BLOCK_HEADER_REF(buf->mem); __wt_block_header_byteswap_copy(blk, &swap); - if (swap.cksum == cksum) { - blk->cksum = 0; - page_cksum = __wt_cksum(buf->mem, + if (swap.checksum == checksum) { + blk->checksum = 0; + page_checksum = __wt_checksum(buf->mem, F_ISSET(&swap, WT_BLOCK_DATA_CKSUM) ? size : WT_BLOCK_COMPRESS_SKIP); - if (page_cksum == cksum) { + if (page_checksum == checksum) { /* * Swap the page-header as needed; this doesn't belong * here, but it's the best place to catch all callers. @@ -209,7 +213,7 @@ __wt_block_read_off(WT_SESSION_IMPL *session, WT_BLOCK *block, "offset %" PRIuMAX ": calculated block checksum " "of %" PRIu32 " doesn't match expected checksum " "of %" PRIu32, - size, (uintmax_t)offset, page_cksum, cksum); + size, (uintmax_t)offset, page_checksum, checksum); } else if (!F_ISSET(session, WT_SESSION_QUIET_CORRUPT_FILE)) __wt_errx(session, @@ -217,7 +221,7 @@ __wt_block_read_off(WT_SESSION_IMPL *session, WT_BLOCK *block, "offset %" PRIuMAX ": block header checksum " "of %" PRIu32 " doesn't match expected checksum " "of %" PRIu32, - size, (uintmax_t)offset, swap.cksum, cksum); + size, (uintmax_t)offset, swap.checksum, checksum); /* Panic if a checksum fails during an ordinary read. */ return (block->verify || diff --git a/src/third_party/wiredtiger/src/block/block_slvg.c b/src/third_party/wiredtiger/src/block/block_slvg.c index 1bfc67f45e2..5ba95bb598e 100644 --- a/src/third_party/wiredtiger/src/block/block_slvg.c +++ b/src/third_party/wiredtiger/src/block/block_slvg.c @@ -98,7 +98,7 @@ __wt_block_salvage_next(WT_SESSION_IMPL *session, WT_DECL_RET; WT_FH *fh; wt_off_t max, offset; - uint32_t allocsize, cksum, size; + uint32_t allocsize, checksum, size; uint8_t *endp; *eofp = 0; @@ -125,7 +125,7 @@ __wt_block_salvage_next(WT_SESSION_IMPL *session, blk = WT_BLOCK_HEADER_REF(tmp->mem); __wt_block_header_byteswap(blk); size = blk->disk_size; - cksum = blk->cksum; + checksum = blk->checksum; /* * Check the block size: if it's not insane, read the block. @@ -135,7 +135,7 @@ __wt_block_salvage_next(WT_SESSION_IMPL *session, */ if (!__wt_block_offset_invalid(block, offset, size) && __wt_block_read_off( - session, block, tmp, offset, size, cksum) == 0) + session, block, tmp, offset, size, checksum) == 0) break; /* Free the allocation-size block. */ @@ -149,7 +149,7 @@ __wt_block_salvage_next(WT_SESSION_IMPL *session, /* Re-create the address cookie that should reference this block. */ endp = addr; - WT_ERR(__wt_block_addr_to_buffer(block, &endp, offset, size, cksum)); + WT_ERR(__wt_block_addr_to_buffer(block, &endp, offset, size, checksum)); *addr_sizep = WT_PTRDIFF(endp, addr); done: @@ -166,7 +166,7 @@ __wt_block_salvage_valid(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t addr_size, bool valid) { wt_off_t offset; - uint32_t size, cksum; + uint32_t size, checksum; WT_UNUSED(session); WT_UNUSED(addr_size); @@ -176,7 +176,8 @@ __wt_block_salvage_valid(WT_SESSION_IMPL *session, * If the upper layer took the block, move past it; if the upper layer * rejected the block, move past an allocation size chunk and free it. */ - WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); + WT_RET( + __wt_block_buffer_to_addr(block, addr, &offset, &size, &checksum)); if (valid) block->slvg_off = offset + size; else { diff --git a/src/third_party/wiredtiger/src/block/block_vrfy.c b/src/third_party/wiredtiger/src/block/block_vrfy.c index 81b6059ab25..58b62247044 100644 --- a/src/third_party/wiredtiger/src/block/block_vrfy.c +++ b/src/third_party/wiredtiger/src/block/block_vrfy.c @@ -344,12 +344,13 @@ __wt_block_verify_addr(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size) { wt_off_t offset; - uint32_t cksum, size; + uint32_t checksum, size; WT_UNUSED(addr_size); /* Crack the cookie. */ - WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); + WT_RET( + __wt_block_buffer_to_addr(block, addr, &offset, &size, &checksum)); /* Add to the per-file list. */ WT_RET( diff --git a/src/third_party/wiredtiger/src/block/block_write.c b/src/third_party/wiredtiger/src/block/block_write.c index d926a8b7c2d..032f72d551b 100644 --- a/src/third_party/wiredtiger/src/block/block_write.c +++ b/src/third_party/wiredtiger/src/block/block_write.c @@ -15,8 +15,11 @@ int __wt_block_truncate(WT_SESSION_IMPL *session, WT_BLOCK *block, wt_off_t len) { + WT_CONNECTION_IMPL *conn; WT_DECL_RET; + conn = S2C(session); + __wt_verbose(session, WT_VERB_BLOCK, "truncate file to %" PRIuMAX, (uintmax_t)len); @@ -34,13 +37,17 @@ __wt_block_truncate(WT_SESSION_IMPL *session, WT_BLOCK *block, wt_off_t len) * by system utilities. We cannot truncate the file during the backup * window, we might surprise an application. * - * Stop block truncation. This affects files that aren't involved in the - * backup (for example, doing incremental backups, which only copies log - * files, or targeted backups, stops all truncation). We may want a more - * targeted solution at some point. + * This affects files that aren't involved in the backup (for example, + * doing incremental backups, which only copies log files, or targeted + * backups, stops all block truncation unnecessarily). We may want a + * more targeted solution at some point. */ - if (S2C(session)->hot_backup) - return (0); + if (!conn->hot_backup) { + __wt_readlock(session, conn->hot_backup_lock); + if (!conn->hot_backup) + ret = __wt_ftruncate(session, block->fh, len); + __wt_readunlock(session, conn->hot_backup_lock); + } /* * The truncate may fail temporarily or permanently (for example, there @@ -48,7 +55,6 @@ __wt_block_truncate(WT_SESSION_IMPL *session, WT_BLOCK *block, wt_off_t len) * POSIX system, in which case the underlying function returns EBUSY). * It's OK, we don't have to be able to truncate files. */ - ret = __wt_ftruncate(session, block->fh, len); return (ret == EBUSY || ret == ENOTSUP ? 0 : ret); } @@ -196,17 +202,17 @@ __wt_block_write_size(WT_SESSION_IMPL *session, WT_BLOCK *block, size_t *sizep) */ int __wt_block_write(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, - uint8_t *addr, size_t *addr_sizep, bool data_cksum, bool checkpoint_io) + uint8_t *addr, size_t *addr_sizep, bool data_checksum, bool checkpoint_io) { wt_off_t offset; - uint32_t size, cksum; + uint32_t checksum, size; uint8_t *endp; - WT_RET(__wt_block_write_off(session, block, - buf, &offset, &size, &cksum, data_cksum, checkpoint_io, false)); + WT_RET(__wt_block_write_off(session, block, buf, + &offset, &size, &checksum, data_checksum, checkpoint_io, false)); endp = addr; - WT_RET(__wt_block_addr_to_buffer(block, &endp, offset, size, cksum)); + WT_RET(__wt_block_addr_to_buffer(block, &endp, offset, size, checksum)); *addr_sizep = WT_PTRDIFF(endp, addr); return (0); @@ -219,15 +225,15 @@ __wt_block_write(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, */ static int __block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, - WT_ITEM *buf, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump, - bool data_cksum, bool checkpoint_io, bool caller_locked) + WT_ITEM *buf, wt_off_t *offsetp, uint32_t *sizep, uint32_t *checksump, + bool data_checksum, bool checkpoint_io, bool caller_locked) { WT_BLOCK_HEADER *blk; WT_DECL_RET; WT_FH *fh; size_t align_size; wt_off_t offset; - uint32_t cksum; + uint32_t checksum; bool local_locked; fh = block->fh; @@ -292,14 +298,14 @@ __block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, * big-endian format, swap it into place in a separate step. */ blk->flags = 0; - if (data_cksum) + if (data_checksum) F_SET(blk, WT_BLOCK_DATA_CKSUM); - blk->cksum = 0; + blk->checksum = 0; __wt_block_header_byteswap(blk); - blk->cksum = cksum = __wt_cksum( - buf->mem, data_cksum ? align_size : WT_BLOCK_COMPRESS_SKIP); + blk->checksum = checksum = __wt_checksum( + buf->mem, data_checksum ? align_size : WT_BLOCK_COMPRESS_SKIP); #ifdef WORDS_BIGENDIAN - blk->cksum = __wt_bswap32(blk->cksum); + blk->checksum = __wt_bswap32(blk->checksum); #endif /* Pre-allocate some number of extension structures. */ @@ -364,12 +370,12 @@ __block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, session, block_byte_write_checkpoint, align_size); __wt_verbose(session, WT_VERB_WRITE, - "off %" PRIuMAX ", size %" PRIuMAX ", cksum %" PRIu32, - (uintmax_t)offset, (uintmax_t)align_size, cksum); + "off %" PRIuMAX ", size %" PRIuMAX ", checksum %" PRIu32, + (uintmax_t)offset, (uintmax_t)align_size, checksum); *offsetp = offset; *sizep = WT_STORE_SIZE(align_size); - *cksump = cksum; + *checksump = checksum; return (0); } @@ -381,8 +387,8 @@ __block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, */ int __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, - WT_ITEM *buf, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump, - bool data_cksum, bool checkpoint_io, bool caller_locked) + WT_ITEM *buf, wt_off_t *offsetp, uint32_t *sizep, uint32_t *checksump, + bool data_checksum, bool checkpoint_io, bool caller_locked) { WT_DECL_RET; @@ -393,8 +399,8 @@ __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, * than their original content. */ __wt_page_header_byteswap(buf->mem); - ret = __block_write_off(session, block, buf, - offsetp, sizep, cksump, data_cksum, checkpoint_io, caller_locked); + ret = __block_write_off(session, block, buf, offsetp, + sizep, checksump, data_checksum, checkpoint_io, caller_locked); __wt_page_header_byteswap(buf->mem); return (ret); } diff --git a/src/third_party/wiredtiger/src/bloom/bloom.c b/src/third_party/wiredtiger/src/bloom/bloom.c index 76b1b5f68ad..3afada05dda 100644 --- a/src/third_party/wiredtiger/src/bloom/bloom.c +++ b/src/third_party/wiredtiger/src/bloom/bloom.c @@ -174,7 +174,7 @@ err: WT_TRET(__wt_bloom_close(bloom)); * __wt_bloom_insert -- * Adds the given key to the Bloom filter. */ -int +void __wt_bloom_insert(WT_BLOOM *bloom, WT_ITEM *key) { uint64_t h1, h2; @@ -182,10 +182,8 @@ __wt_bloom_insert(WT_BLOOM *bloom, WT_ITEM *key) h1 = __wt_hash_fnv64(key->data, key->size); h2 = __wt_hash_city64(key->data, key->size); - for (i = 0; i < bloom->k; i++, h1 += h2) { + for (i = 0; i < bloom->k; i++, h1 += h2) __bit_set(bloom->bitstring, h1 % bloom->m); - } - return (0); } /* @@ -238,15 +236,13 @@ err: WT_TRET(c->close(c)); * __wt_bloom_hash -- * Calculate the hash values for a given key. */ -int +void __wt_bloom_hash(WT_BLOOM *bloom, WT_ITEM *key, WT_BLOOM_HASH *bhash) { WT_UNUSED(bloom); bhash->h1 = __wt_hash_fnv64(key->data, key->size); bhash->h2 = __wt_hash_city64(key->data, key->size); - - return (0); } /* @@ -309,7 +305,7 @@ __wt_bloom_get(WT_BLOOM *bloom, WT_ITEM *key) { WT_BLOOM_HASH bhash; - WT_RET(__wt_bloom_hash(bloom, key, &bhash)); + __wt_bloom_hash(bloom, key, &bhash); return (__wt_bloom_hash_get(bloom, &bhash)); } diff --git a/src/third_party/wiredtiger/src/btree/bt_cursor.c b/src/third_party/wiredtiger/src/btree/bt_cursor.c index 9a57759570a..982226f589f 100644 --- a/src/third_party/wiredtiger/src/btree/bt_cursor.c +++ b/src/third_party/wiredtiger/src/btree/bt_cursor.c @@ -1212,7 +1212,7 @@ __wt_btcur_range_truncate(WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop) } err: if (FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED)) - WT_TRET(__wt_txn_truncate_end(session)); + __wt_txn_truncate_end(session); return (ret); } diff --git a/src/third_party/wiredtiger/src/btree/bt_debug.c b/src/third_party/wiredtiger/src/btree/bt_debug.c index c1560150435..bcc7d27a569 100644 --- a/src/third_party/wiredtiger/src/btree/bt_debug.c +++ b/src/third_party/wiredtiger/src/btree/bt_debug.c @@ -140,13 +140,14 @@ __dmsg_event(WT_DBG *ds, const char *fmt, ...) static int __dmsg_file(WT_DBG *ds, const char *fmt, ...) { + WT_DECL_RET; va_list ap; va_start(ap, fmt); - (void)vfprintf(ds->fp, fmt, ap); + ret = vfprintf(ds->fp, fmt, ap) < 0 ? EIO : 0; va_end(ap); - return (0); + return (ret); } /* @@ -290,7 +291,7 @@ err: __wt_scr_free(session, &buf); */ int __wt_debug_offset(WT_SESSION_IMPL *session, - wt_off_t offset, uint32_t size, uint32_t cksum, const char *ofile) + wt_off_t offset, uint32_t size, uint32_t checksum, const char *ofile) { WT_DECL_ITEM(buf); WT_DECL_RET; @@ -309,7 +310,7 @@ __wt_debug_offset(WT_SESSION_IMPL *session, */ endp = addr; WT_RET(__wt_block_addr_to_buffer( - S2BT(session)->bm->block, &endp, offset, size, cksum)); + S2BT(session)->bm->block, &endp, offset, size, checksum)); /* * Read the address through the btree I/O functions (so the block is diff --git a/src/third_party/wiredtiger/src/btree/bt_handle.c b/src/third_party/wiredtiger/src/btree/bt_handle.c index 02580bca4a8..9591023e163 100644 --- a/src/third_party/wiredtiger/src/btree/bt_handle.c +++ b/src/third_party/wiredtiger/src/btree/bt_handle.c @@ -688,18 +688,21 @@ __btree_page_sizes(WT_SESSION_IMPL *session) /* * Don't let pages grow large compared to the cache size or we can end - * up in a situation where nothing can be evicted. Take care getting - * the cache size: with a shared cache, it may not have been set. - * Don't forget to update the API documentation if you alter the - * bounds for any of the parameters here. + * up in a situation where nothing can be evicted. Make sure at least + * 10 pages fit in cache when it is at the dirty trigger where threads + * stall. + * + * Take care getting the cache size: with a shared cache, it may not + * have been set. Don't forget to update the API documentation if you + * alter the bounds for any of the parameters here. */ WT_RET(__wt_config_gets(session, cfg, "memory_page_max", &cval)); btree->maxmempage = (uint64_t)cval.val; - if (!F_ISSET(conn, WT_CONN_CACHE_POOL)) { - if ((cache_size = conn->cache_size) > 0) - btree->maxmempage = - WT_MIN(btree->maxmempage, cache_size / 10); - } + if (!F_ISSET(conn, WT_CONN_CACHE_POOL) && + (cache_size = conn->cache_size) > 0) + btree->maxmempage = WT_MIN(btree->maxmempage, + (conn->cache->eviction_dirty_trigger * cache_size) / 1000); + /* Enforce a lower bound of a single disk leaf page */ btree->maxmempage = WT_MAX(btree->maxmempage, btree->maxleafpage); diff --git a/src/third_party/wiredtiger/src/btree/bt_io.c b/src/third_party/wiredtiger/src/btree/bt_io.c index 6c2e2f1b3fb..8053417f838 100644 --- a/src/third_party/wiredtiger/src/btree/bt_io.c +++ b/src/third_party/wiredtiger/src/btree/bt_io.c @@ -182,7 +182,7 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, size_t dst_len, len, result_len, size, src_len; int compression_failed; /* Extension API, so not a bool. */ uint8_t *dst, *src; - bool data_cksum, encrypted; + bool data_checksum, encrypted; btree = S2BT(session); bm = btree->bm; @@ -344,24 +344,24 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, * Checksum the data if the buffer isn't compressed or checksums are * configured. */ - data_cksum = true; /* -Werror=maybe-uninitialized */ + data_checksum = true; /* -Werror=maybe-uninitialized */ switch (btree->checksum) { case CKSUM_ON: - data_cksum = true; + data_checksum = true; break; case CKSUM_OFF: - data_cksum = false; + data_checksum = false; break; case CKSUM_UNCOMPRESSED: - data_cksum = !compressed; + data_checksum = !compressed; break; } /* Call the block manager to write the block. */ WT_ERR(checkpoint ? - bm->checkpoint(bm, session, ip, btree->ckpt, data_cksum) : + bm->checkpoint(bm, session, ip, btree->ckpt, data_checksum) : bm->write( - bm, session, ip, addr, addr_sizep, data_cksum, checkpoint_io)); + bm, session, ip, addr, addr_sizep, data_checksum, checkpoint_io)); WT_STAT_FAST_CONN_INCR(session, cache_write); WT_STAT_FAST_DATA_INCR(session, cache_write); diff --git a/src/third_party/wiredtiger/src/btree/bt_page.c b/src/third_party/wiredtiger/src/btree/bt_page.c index 89e5f428628..7bac7079fe8 100644 --- a/src/third_party/wiredtiger/src/btree/bt_page.c +++ b/src/third_party/wiredtiger/src/btree/bt_page.c @@ -296,7 +296,7 @@ __inmem_col_int(WT_SESSION_IMPL *session, WT_PAGE *page) * __inmem_col_var_repeats -- * Count the number of repeat entries on the page. */ -static int +static void __inmem_col_var_repeats(WT_SESSION_IMPL *session, WT_PAGE *page, uint32_t *np) { WT_BTREE *btree; @@ -316,7 +316,6 @@ __inmem_col_var_repeats(WT_SESSION_IMPL *session, WT_PAGE *page, uint32_t *np) if (__wt_cell_rle(unpack) > 1) ++*np; } - return (0); } /* @@ -367,8 +366,7 @@ __inmem_col_var( rle = __wt_cell_rle(unpack); if (rle > 1) { if (repeats == NULL) { - WT_RET( - __inmem_col_var_repeats(session, page, &n)); + __inmem_col_var_repeats(session, page, &n); WT_RET(__wt_realloc_def(session, &bytes_allocated, n + 1, &repeats)); diff --git a/src/third_party/wiredtiger/src/btree/bt_read.c b/src/third_party/wiredtiger/src/btree/bt_read.c index b096fd432e9..a23ab0f091f 100644 --- a/src/third_party/wiredtiger/src/btree/bt_read.c +++ b/src/third_party/wiredtiger/src/btree/bt_read.c @@ -147,7 +147,7 @@ __las_page_instantiate(WT_SESSION_IMPL *session, WT_ERR(__wt_scr_alloc(session, 0, &las_value)); /* Open a lookaside table cursor. */ - WT_ERR(__wt_las_cursor(session, &cursor, &session_flags)); + __wt_las_cursor(session, &cursor, &session_flags); /* * The lookaside records are in key and update order, that is, there @@ -331,7 +331,7 @@ __evict_force_check(WT_SESSION_IMPL *session, WT_REF *ref) * If we have already tried and the transaction state has not moved on, * eviction is highly likely to fail. */ - if (page->modify->last_oldest_id == __wt_txn_oldest_id(session)) + if (page->modify->last_eviction_id == __wt_txn_oldest_id(session)) return (false); if (page->memory_footprint < btree->maxmempage) @@ -476,8 +476,15 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags btree = S2BT(session); - WT_STAT_FAST_CONN_INCR(session, cache_pages_requested); - WT_STAT_FAST_DATA_INCR(session, cache_pages_requested); + /* + * Ignore reads of pages already known to be in cache, otherwise the + * eviction server can dominate these statistics. + */ + if (!LF_ISSET(WT_READ_CACHE)) { + WT_STAT_FAST_CONN_INCR(session, cache_pages_requested); + WT_STAT_FAST_DATA_INCR(session, cache_pages_requested); + } + for (evict_soon = stalled = false, force_attempts = 0, sleep_cnt = wait_cnt = 0;;) { switch (ref->state) { diff --git a/src/third_party/wiredtiger/src/btree/bt_slvg.c b/src/third_party/wiredtiger/src/btree/bt_slvg.c index 831e58b91bd..f269c2d7f43 100644 --- a/src/third_party/wiredtiger/src/btree/bt_slvg.c +++ b/src/third_party/wiredtiger/src/btree/bt_slvg.c @@ -119,7 +119,7 @@ static int __slvg_col_build_leaf(WT_SESSION_IMPL *, WT_TRACK *, WT_REF *); static int __slvg_col_ovfl(WT_SESSION_IMPL *, WT_TRACK *, WT_PAGE *, uint64_t, uint64_t, uint64_t); static int __slvg_col_range(WT_SESSION_IMPL *, WT_STUFF *); -static int __slvg_col_range_missing(WT_SESSION_IMPL *, WT_STUFF *); +static void __slvg_col_range_missing(WT_SESSION_IMPL *, WT_STUFF *); static int __slvg_col_range_overlap( WT_SESSION_IMPL *, uint32_t, uint32_t, WT_STUFF *); static void __slvg_col_trk_update_start(uint32_t, WT_STUFF *); @@ -281,7 +281,7 @@ __wt_bt_salvage(WT_SESSION_IMPL *session, WT_CKPT *ckptbase, const char *cfg[]) switch (ss->page_type) { case WT_PAGE_COL_FIX: case WT_PAGE_COL_VAR: - WT_ERR(__slvg_col_range_missing(session, ss)); + __slvg_col_range_missing(session, ss); break; case WT_PAGE_ROW_LEAF: break; @@ -1107,7 +1107,7 @@ __slvg_col_trk_update_start(uint32_t slot, WT_STUFF *ss) * __slvg_col_range_missing -- * Detect missing ranges from column-store files. */ -static int +static void __slvg_col_range_missing(WT_SESSION_IMPL *session, WT_STUFF *ss) { WT_TRACK *trk; @@ -1134,7 +1134,6 @@ __slvg_col_range_missing(WT_SESSION_IMPL *session, WT_STUFF *ss) } r = trk->col_stop; } - return (0); } /* @@ -1943,7 +1942,7 @@ __slvg_row_build_leaf( if (cmp >= 0) break; __wt_verbose(session, WT_VERB_SALVAGE, - "%s merge discarding leading key %.*s", + "%s merge discarding leading key %s", __wt_addr_string(session, trk->trk_addr, trk->trk_addr_size, ss->tmp1), __wt_buf_set_printable( @@ -1963,7 +1962,7 @@ __slvg_row_build_leaf( if (cmp < 0) break; __wt_verbose(session, WT_VERB_SALVAGE, - "%s merge discarding trailing key %.*s", + "%s merge discarding trailing key %s", __wt_addr_string(session, trk->trk_addr, trk->trk_addr_size, ss->tmp1), __wt_buf_set_printable( diff --git a/src/third_party/wiredtiger/src/btree/bt_split.c b/src/third_party/wiredtiger/src/btree/bt_split.c index 490e8aae788..e05f3746052 100644 --- a/src/third_party/wiredtiger/src/btree/bt_split.c +++ b/src/third_party/wiredtiger/src/btree/bt_split.c @@ -580,7 +580,7 @@ __split_root(WT_SESSION_IMPL *session, WT_PAGE *root) __wt_verbose(session, WT_VERB_SPLIT, "%p: %" PRIu32 " root page elements, splitting into %" PRIu32 " children", - root, pindex->entries, children); + (void *)root, pindex->entries, children); /* * Allocate a new WT_PAGE_INDEX and set of WT_REF objects to be inserted @@ -891,13 +891,15 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, WT_REF **ref_new, __wt_verbose(session, WT_VERB_SPLIT, "%p: reverse split into parent %p, %" PRIu32 " -> %" PRIu32 " (-%" PRIu32 ")", - ref->page, parent, parent_entries, result_entries, + (void *)ref->page, (void *)parent, + parent_entries, result_entries, parent_entries - result_entries); else __wt_verbose(session, WT_VERB_SPLIT, "%p: split into parent %p, %" PRIu32 " -> %" PRIu32 " (+%" PRIu32 ")", - ref->page, parent, parent_entries, result_entries, + (void *)ref->page, (void *)parent, + parent_entries, result_entries, result_entries - parent_entries); /* @@ -1063,7 +1065,7 @@ __split_internal(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_PAGE *page) __wt_verbose(session, WT_VERB_SPLIT, "%p: %" PRIu32 " internal page elements, splitting %" PRIu32 " children into parent %p", - page, pindex->entries, children, parent); + (void *)page, pindex->entries, children, (void *)parent); /* * Ideally, we'd discard the original page, but that's hard since other @@ -2077,7 +2079,8 @@ __wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref) WT_PAGE *parent; bool hazard; - __wt_verbose(session, WT_VERB_SPLIT, "%p: split-insert", ref->page); + __wt_verbose( + session, WT_VERB_SPLIT, "%p: split-insert", (void *)ref->page); WT_RET(__split_internal_lock(session, ref, true, &parent, &hazard)); if ((ret = __split_insert(session, ref)) != 0) { @@ -2168,7 +2171,8 @@ __wt_split_multi(WT_SESSION_IMPL *session, WT_REF *ref, int closing) WT_PAGE *parent; bool hazard; - __wt_verbose(session, WT_VERB_SPLIT, "%p: split-multi", ref->page); + __wt_verbose( + session, WT_VERB_SPLIT, "%p: split-multi", (void *)ref->page); WT_RET(__split_internal_lock(session, ref, false, &parent, &hazard)); if ((ret = __split_multi(session, ref, closing)) != 0 || closing) { @@ -2196,7 +2200,8 @@ __wt_split_reverse(WT_SESSION_IMPL *session, WT_REF *ref) WT_PAGE *parent; bool hazard; - __wt_verbose(session, WT_VERB_SPLIT, "%p: reverse-split", ref->page); + __wt_verbose( + session, WT_VERB_SPLIT, "%p: reverse-split", (void *)ref->page); WT_RET(__split_internal_lock(session, ref, false, &parent, &hazard)); ret = __split_parent(session, ref, NULL, 0, 0, false, true); @@ -2217,7 +2222,8 @@ __wt_split_rewrite(WT_SESSION_IMPL *session, WT_REF *ref, WT_MULTI *multi) page = ref->page; - __wt_verbose(session, WT_VERB_SPLIT, "%p: split-rewrite", ref->page); + __wt_verbose( + session, WT_VERB_SPLIT, "%p: split-rewrite", (void *)ref->page); /* * This isn't a split: a reconciliation failed because we couldn't write @@ -2243,8 +2249,8 @@ __wt_split_rewrite(WT_SESSION_IMPL *session, WT_REF *ref, WT_MULTI *multi) * to avoid repeatedly attempting eviction on the same page. */ if (new->page->modify != NULL) - new->page->modify->last_oldest_id = - page->modify->last_oldest_id; + new->page->modify->last_eviction_id = + page->modify->last_eviction_id; /* * The rewrite succeeded, we can no longer fail. diff --git a/src/third_party/wiredtiger/src/btree/bt_vrfy.c b/src/third_party/wiredtiger/src/btree/bt_vrfy.c index 76817cef7cd..340f9bb6f0e 100644 --- a/src/third_party/wiredtiger/src/btree/bt_vrfy.c +++ b/src/third_party/wiredtiger/src/btree/bt_vrfy.c @@ -89,7 +89,7 @@ __verify_config_offsets( *quitp = false; WT_RET(__wt_config_gets(session, cfg, "dump_offsets", &cval)); - WT_RET(__wt_config_subinit(session, &list, &cval)); + __wt_config_subinit(session, &list, &cval); while ((ret = __wt_config_next(&list, &k, &v)) == 0) { /* * Quit after dumping the requested blocks. (That's hopefully diff --git a/src/third_party/wiredtiger/src/btree/row_modify.c b/src/third_party/wiredtiger/src/btree/row_modify.c index f37c77d284f..a1c214e5b8b 100644 --- a/src/third_party/wiredtiger/src/btree/row_modify.c +++ b/src/third_party/wiredtiger/src/btree/row_modify.c @@ -267,23 +267,27 @@ int __wt_update_alloc( WT_SESSION_IMPL *session, WT_ITEM *value, WT_UPDATE **updp, size_t *sizep) { + WT_UPDATE *upd; size_t size; + *updp = NULL; + /* * Allocate the WT_UPDATE structure and room for the value, then copy * the value into place. */ size = value == NULL ? 0 : value->size; - WT_RET(__wt_calloc(session, 1, sizeof(WT_UPDATE) + size, updp)); + WT_RET(__wt_calloc(session, 1, sizeof(WT_UPDATE) + size, &upd)); if (value == NULL) - WT_UPDATE_DELETED_SET(*updp); + WT_UPDATE_DELETED_SET(upd); else { - (*updp)->size = WT_STORE_SIZE(size); + upd->size = WT_STORE_SIZE(size); if (size != 0) - memcpy(WT_UPDATE_DATA(*updp), value->data, size); + memcpy(WT_UPDATE_DATA(upd), value->data, size); } - *sizep = WT_UPDATE_MEMSIZE(*updp); + *updp = upd; + *sizep = WT_UPDATE_MEMSIZE(upd); return (0); } diff --git a/src/third_party/wiredtiger/src/cache/cache_las.c b/src/third_party/wiredtiger/src/cache/cache_las.c index 27c2900fa98..4c338bc6ad9 100644 --- a/src/third_party/wiredtiger/src/cache/cache_las.c +++ b/src/third_party/wiredtiger/src/cache/cache_las.c @@ -200,7 +200,7 @@ __wt_las_cursor_open(WT_SESSION_IMPL *session, WT_CURSOR **cursorp) * __wt_las_cursor -- * Return a lookaside cursor. */ -int +void __wt_las_cursor( WT_SESSION_IMPL *session, WT_CURSOR **cursorp, uint32_t *session_flags) { @@ -235,8 +235,6 @@ __wt_las_cursor( /* Turn caching and eviction off. */ F_SET(session, WT_SESSION_NO_CACHE | WT_SESSION_NO_EVICTION); - - return (0); } /* @@ -304,7 +302,7 @@ __wt_las_sweep(WT_SESSION_IMPL *session) WT_ERR(__wt_scr_alloc(session, 0, &las_addr)); WT_ERR(__wt_scr_alloc(session, 0, &las_key)); - WT_ERR(__wt_las_cursor(session, &cursor, &session_flags)); + __wt_las_cursor(session, &cursor, &session_flags); /* * If we're not starting a new sweep, position the cursor using the key diff --git a/src/third_party/wiredtiger/src/checksum/arm64/crc32-arm64.c b/src/third_party/wiredtiger/src/checksum/arm64/crc32-arm64.c new file mode 100644 index 00000000000..5d6c5f69c58 --- /dev/null +++ b/src/third_party/wiredtiger/src/checksum/arm64/crc32-arm64.c @@ -0,0 +1,101 @@ +/*- + * Public Domain 2014-2016 MongoDB, Inc. + * Public Domain 2008-2014 WiredTiger, Inc. + * + * This is free and unencumbered software released into the public domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "wt_internal.h" + +#if defined(HAVE_CRC32_HARDWARE) +#include <asm/hwcap.h> +#include <sys/auxv.h> + +#define CRC32CX(crc,value) \ + asm("crc32cx %w[c], %w[c], %x[v]" : [c]"+r"(*&crc) : [v]"r"(+value)) +#define CRC32CW(crc,value) \ + asm("crc32cw %w[c], %w[c], %w[v]" : [c]"+r"(*&crc) : [v]"r"(+value)) +#define CRC32CH(crc,value) \ + asm("crc32ch %w[c], %w[c], %w[v]" : [c]"+r"(*&crc) : [v]"r"(+value)) +#define CRC32CB(crc,value) \ + asm("crc32cb %w[c], %w[c], %w[v]" : [c]"+r"(*&crc) : [v]"r"(+value)) + +/* + * __wt_checksum_hw -- + * Return a checksum for a chunk of memory, computed in hardware + * using 8 byte steps. + */ +static uint32_t +__wt_checksum_hw(const void *chunk, size_t len) +{ + uint32_t crc; + size_t nqwords; + const uint8_t *p; + const uint64_t *p64; + + crc = 0xffffffff; + + /* Checksum one byte at a time to the first 4B boundary. */ + for (p = chunk; + ((uintptr_t)p & (sizeof(uint32_t) - 1)) != 0 && + len > 0; ++p, --len) { + CRC32CB(crc, *p); + } + + p64 = (const uint64_t *)p; + /* Checksum in 8B chunks. */ + for (nqwords = len / sizeof(uint64_t); nqwords; nqwords--) { + CRC32CX(crc, *p64); + p64++; + } + + /* Checksum trailing bytes one byte at a time. */ + p = (const uint8_t *)p64; + for (len &= 0x7; len > 0; ++p, len--) { + CRC32CB(crc, *p); + } + + return (~crc); +} +#endif /* HAVE_CRC32_HARDWARE */ + +/* + * __wt_checksum_init -- + * WiredTiger: detect CRC hardware and set the checksum function. + */ +void +__wt_checksum_init(void) +{ +#if defined(HAVE_CRC32_HARDWARE) + unsigned long caps = getauxval(AT_HWCAP); + + if (caps & HWCAP_CRC32) + __wt_process.checksum = __wt_checksum_hw; + else + __wt_process.checksum = __wt_checksum_sw; + +#else /* !HAVE_CRC32_HARDWARE */ + __wt_process.checksum = __wt_checksum_sw; +#endif /* HAVE_CRC32_HARDWARE */ +} diff --git a/src/third_party/wiredtiger/src/checksum/power8/crc32_wrapper.c b/src/third_party/wiredtiger/src/checksum/power8/crc32_wrapper.c index cbfe1ab90f5..ddfa2bdaeb8 100644 --- a/src/third_party/wiredtiger/src/checksum/power8/crc32_wrapper.c +++ b/src/third_party/wiredtiger/src/checksum/power8/crc32_wrapper.c @@ -71,21 +71,25 @@ out: #include "wt_internal.h" /* - * __wt_cksum -- + * __wt_checksum_hw -- * WiredTiger: return a checksum for a chunk of memory. */ -uint32_t -__wt_cksum(const void *chunk, size_t len) +static uint32_t +__wt_checksum_hw(const void *chunk, size_t len) { - return crc32_vpmsum(0, chunk, len); + return (crc32_vpmsum(0, chunk, len)); } /* - * __wt_cksum_init -- + * __wt_checksum_init -- * WiredTiger: detect CRC hardware and set the checksum function. */ void -__wt_cksum_init(void) +__wt_checksum_init(void) { - /* None needed. */ +#if defined(HAVE_CRC32_HARDWARE) + __wt_process.checksum = __wt_checksum_hw; +#else + __wt_process.checksum = __wt_checksum_sw; +#endif } diff --git a/src/third_party/wiredtiger/src/checksum/x86/checksum.c b/src/third_party/wiredtiger/src/checksum/software/checksum.c index 8a8c735cfc8..30362584a3e 100644 --- a/src/third_party/wiredtiger/src/checksum/x86/checksum.c +++ b/src/third_party/wiredtiger/src/checksum/software/checksum.c @@ -41,15 +41,7 @@ #include "wt_internal.h" /* - * This file contains two implementations for computing CRC: one that uses - * hardware CRC instructions, available on newer x86_64/amd64, and one that uses - * a fast software algorithm. __wt_cksum() provides a common entry point that - * indirects to one of these two methods. - */ -static uint32_t (*__wt_cksum_func)(const void *chunk, size_t len); - -/* - * The CRC slicing tables are used by __wt_cksum_sw. + * The CRC slicing tables. */ static const uint32_t g_crc_slicing[8][256] = { #ifdef WORDS_BIGENDIAN @@ -1104,11 +1096,11 @@ static const uint32_t g_crc_slicing[8][256] = { }; /* - * __wt_cksum_sw -- + * __wt_checksum_sw -- * Return a checksum for a chunk of memory, computed in software. */ -static uint32_t -__wt_cksum_sw(const void *chunk, size_t len) +uint32_t +__wt_checksum_sw(const void *chunk, size_t len) { uint32_t crc, next; size_t nqwords; @@ -1171,137 +1163,3 @@ __wt_cksum_sw(const void *chunk, size_t len) #endif return (~crc); } - -#if (defined(__amd64) || defined(__x86_64)) -/* - * __wt_cksum_hw -- - * Return a checksum for a chunk of memory, computed in hardware - * using 8 byte steps. - */ -static uint32_t -__wt_cksum_hw(const void *chunk, size_t len) -{ - uint32_t crc; - size_t nqwords; - const uint8_t *p; - const uint64_t *p64; - - crc = 0xffffffff; - - /* Checksum one byte at a time to the first 4B boundary. */ - for (p = chunk; - ((uintptr_t)p & (sizeof(uint32_t) - 1)) != 0 && - len > 0; ++p, --len) { - __asm__ __volatile__( - ".byte 0xF2, 0x0F, 0x38, 0xF0, 0xF1" - : "=S" (crc) - : "0" (crc), "c" (*p)); - } - - p64 = (const uint64_t *)p; - /* Checksum in 8B chunks. */ - for (nqwords = len / sizeof(uint64_t); nqwords; nqwords--) { - __asm__ __volatile__ ( - ".byte 0xF2, 0x48, 0x0F, 0x38, 0xF1, 0xF1" - : "=S"(crc) - : "0"(crc), "c" (*p64)); - p64++; - } - - /* Checksum trailing bytes one byte at a time. */ - p = (const uint8_t *)p64; - for (len &= 0x7; len > 0; ++p, len--) { - __asm__ __volatile__( - ".byte 0xF2, 0x0F, 0x38, 0xF0, 0xF1" - : "=S" (crc) - : "0" (crc), "c" (*p)); - } - return (~crc); -} -#endif - -#if defined(_M_AMD64) -/* - * __wt_cksum_hw -- - * Return a checksum for a chunk of memory, computed in hardware - * using 8 byte steps. - */ -static uint32_t -__wt_cksum_hw(const void *chunk, size_t len) -{ - uint32_t crc; - size_t nqwords; - const uint8_t *p; - const uint64_t *p64; - - crc = 0xffffffff; - - /* Checksum one byte at a time to the first 4B boundary. */ - for (p = chunk; - ((uintptr_t)p & (sizeof(uint32_t) - 1)) != 0 && - len > 0; ++p, --len) { - crc = _mm_crc32_u8(crc, *p); - } - - p64 = (const uint64_t *)p; - /* Checksum in 8B chunks. */ - for (nqwords = len / sizeof(uint64_t); nqwords; nqwords--) { - crc = (uint32_t)_mm_crc32_u64(crc, *p64); - p64++; - } - - /* Checksum trailing bytes one byte at a time. */ - p = (const uint8_t *)p64; - for (len &= 0x7; len > 0; ++p, len--) { - crc = _mm_crc32_u8(crc, *p); - } - - return (~crc); -} -#endif - -/* - * __wt_cksum -- - * WiredTiger: return a checksum for a chunk of memory. - */ -uint32_t -__wt_cksum(const void *chunk, size_t len) -{ - return (*__wt_cksum_func)(chunk, len); -} - -/* - * __wt_cksum_init -- - * WiredTiger: detect CRC hardware and set the checksum function. - */ -void -__wt_cksum_init(void) -{ -#if (defined(__amd64) || defined(__x86_64)) - unsigned int eax, ebx, ecx, edx; - - __asm__ __volatile__ ( - "cpuid" - : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) - : "a" (1)); - -#define CPUID_ECX_HAS_SSE42 (1 << 20) - if (ecx & CPUID_ECX_HAS_SSE42) - __wt_cksum_func = __wt_cksum_hw; - else - __wt_cksum_func = __wt_cksum_sw; - -#elif defined(_M_AMD64) - int cpuInfo[4]; - - __cpuid(cpuInfo, 1); - -#define CPUID_ECX_HAS_SSE42 (1 << 20) - if (cpuInfo[2] & CPUID_ECX_HAS_SSE42) - __wt_cksum_func = __wt_cksum_hw; - else - __wt_cksum_func = __wt_cksum_sw; -#else - __wt_cksum_func = __wt_cksum_sw; -#endif -} diff --git a/src/third_party/wiredtiger/src/checksum/x86/crc32-x86.c b/src/third_party/wiredtiger/src/checksum/x86/crc32-x86.c new file mode 100644 index 00000000000..82814ecc34d --- /dev/null +++ b/src/third_party/wiredtiger/src/checksum/x86/crc32-x86.c @@ -0,0 +1,160 @@ +/*- + * Public Domain 2014-2016 MongoDB, Inc. + * Public Domain 2008-2014 WiredTiger, Inc. + * + * This is free and unencumbered software released into the public domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "wt_internal.h" + +#if defined(HAVE_CRC32_HARDWARE) +#if (defined(__amd64) || defined(__x86_64)) +/* + * __wt_checksum_hw -- + * Return a checksum for a chunk of memory, computed in hardware + * using 8 byte steps. + */ +static uint32_t +__wt_checksum_hw(const void *chunk, size_t len) +{ + uint32_t crc; + size_t nqwords; + const uint8_t *p; + const uint64_t *p64; + + crc = 0xffffffff; + + /* Checksum one byte at a time to the first 4B boundary. */ + for (p = chunk; + ((uintptr_t)p & (sizeof(uint32_t) - 1)) != 0 && + len > 0; ++p, --len) { + __asm__ __volatile__( + ".byte 0xF2, 0x0F, 0x38, 0xF0, 0xF1" + : "=S" (crc) + : "0" (crc), "c" (*p)); + } + + p64 = (const uint64_t *)p; + /* Checksum in 8B chunks. */ + for (nqwords = len / sizeof(uint64_t); nqwords; nqwords--) { + __asm__ __volatile__ ( + ".byte 0xF2, 0x48, 0x0F, 0x38, 0xF1, 0xF1" + : "=S"(crc) + : "0"(crc), "c" (*p64)); + p64++; + } + + /* Checksum trailing bytes one byte at a time. */ + p = (const uint8_t *)p64; + for (len &= 0x7; len > 0; ++p, len--) { + __asm__ __volatile__( + ".byte 0xF2, 0x0F, 0x38, 0xF0, 0xF1" + : "=S" (crc) + : "0" (crc), "c" (*p)); + } + return (~crc); +} +#endif + +#if defined(_M_AMD64) +/* + * __wt_checksum_hw -- + * Return a checksum for a chunk of memory, computed in hardware + * using 8 byte steps. + */ +static uint32_t +__wt_checksum_hw(const void *chunk, size_t len) +{ + uint32_t crc; + size_t nqwords; + const uint8_t *p; + const uint64_t *p64; + + crc = 0xffffffff; + + /* Checksum one byte at a time to the first 4B boundary. */ + for (p = chunk; + ((uintptr_t)p & (sizeof(uint32_t) - 1)) != 0 && + len > 0; ++p, --len) { + crc = _mm_crc32_u8(crc, *p); + } + + p64 = (const uint64_t *)p; + /* Checksum in 8B chunks. */ + for (nqwords = len / sizeof(uint64_t); nqwords; nqwords--) { + crc = (uint32_t)_mm_crc32_u64(crc, *p64); + p64++; + } + + /* Checksum trailing bytes one byte at a time. */ + p = (const uint8_t *)p64; + for (len &= 0x7; len > 0; ++p, len--) { + crc = _mm_crc32_u8(crc, *p); + } + + return (~crc); +} +#endif +#endif /* HAVE_CRC32_HARDWARE */ + +/* + * __wt_checksum_init -- + * WiredTiger: detect CRC hardware and set the checksum function. + */ +void +__wt_checksum_init(void) +{ +#if defined(HAVE_CRC32_HARDWARE) +#if (defined(__amd64) || defined(__x86_64)) + unsigned int eax, ebx, ecx, edx; + + __asm__ __volatile__ ( + "cpuid" + : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) + : "a" (1)); + +#define CPUID_ECX_HAS_SSE42 (1 << 20) + if (ecx & CPUID_ECX_HAS_SSE42) + __wt_process.checksum = __wt_checksum_hw; + else + __wt_process.checksum = __wt_checksum_sw; + +#elif defined(_M_AMD64) + int cpuInfo[4]; + + __cpuid(cpuInfo, 1); + +#define CPUID_ECX_HAS_SSE42 (1 << 20) + if (cpuInfo[2] & CPUID_ECX_HAS_SSE42) + __wt_process.checksum = __wt_checksum_hw; + else + __wt_process.checksum = __wt_checksum_sw; +#else + __wt_process.checksum = __wt_checksum_sw; +#endif + +#else /* !HAVE_CRC32_HARDWARE */ + __wt_process.checksum = __wt_checksum_sw; +#endif /* HAVE_CRC32_HARDWARE */ +} diff --git a/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c b/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c index daf7ce06c53..f77d6768d42 100644 --- a/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c +++ b/src/third_party/wiredtiger/src/checksum/zseries/crc32-s390x.c @@ -72,21 +72,25 @@ DEFINE_CRC32_VX(__wt_crc32c_le_vx, __wt_crc32c_le_vgfm_16, __wt_crc32c_le) #include "wt_internal.h" /* - * __wt_cksum -- + * __wt_checksum_hw -- * WiredTiger: return a checksum for a chunk of memory. */ -unsigned int -__wt_cksum(const void *chunk, size_t len) +static uint32_t +__wt_checksum_hw(const void *chunk, size_t len) { return (~__wt_crc32c_le_vx(0xffffffff, chunk, len)); } /* - * __wt_cksum_init -- + * __wt_checksum_init -- * WiredTiger: detect CRC hardware and set the checksum function. */ void -__wt_cksum_init(void) +__wt_checksum_init(void) { - /* None needed. */ +#if defined(HAVE_CRC32_HARDWARE) + __wt_process.checksum = __wt_checksum_hw; +#else + __wt_process.checksum = __wt_checksum_sw; +#endif } diff --git a/src/third_party/wiredtiger/src/config/config.c b/src/third_party/wiredtiger/src/config/config.c index 96ef7a4e62a..3416153d160 100644 --- a/src/third_party/wiredtiger/src/config/config.c +++ b/src/third_party/wiredtiger/src/config/config.c @@ -26,7 +26,7 @@ __config_err(WT_CONFIG *conf, const char *msg, int err) * Initialize a config handle, used to iterate through a config string of * specified length. */ -int +void __wt_config_initn( WT_SESSION_IMPL *session, WT_CONFIG *conf, const char *str, size_t len) { @@ -36,8 +36,6 @@ __wt_config_initn( conf->depth = 0; conf->top = -1; conf->go = NULL; - - return (0); } /* @@ -45,14 +43,14 @@ __wt_config_initn( * Initialize a config handle, used to iterate through a NUL-terminated * config string. */ -int +void __wt_config_init(WT_SESSION_IMPL *session, WT_CONFIG *conf, const char *str) { size_t len; len = (str == NULL) ? 0 : strlen(str); - return (__wt_config_initn(session, conf, str, len)); + __wt_config_initn(session, conf, str, len); } /* @@ -61,11 +59,11 @@ __wt_config_init(WT_SESSION_IMPL *session, WT_CONFIG *conf, const char *str) * extracted from another config string (used for parsing nested * structures). */ -int +void __wt_config_subinit( WT_SESSION_IMPL *session, WT_CONFIG *conf, WT_CONFIG_ITEM *item) { - return (__wt_config_initn(session, conf, item->str, item->len)); + __wt_config_initn(session, conf, item->str, item->len); } #define PUSH(i, t) do { \ @@ -601,8 +599,8 @@ __config_getraw( strncmp(key->str, k.str, k.len) == 0) { subk.str = key->str + k.len + 1; subk.len = (key->len - k.len) - 1; - WT_RET(__wt_config_initn( - cparser->session, &sparser, v.str, v.len)); + __wt_config_initn( + cparser->session, &sparser, v.str, v.len); if ((ret = __config_getraw( &sparser, &subk, value, false)) == 0) found = true; @@ -641,7 +639,7 @@ __wt_config_get(WT_SESSION_IMPL *session, do { --cfg; - WT_RET(__wt_config_init(session, &cparser, *cfg)); + __wt_config_init(session, &cparser, *cfg); if ((ret = __config_getraw(&cparser, key, value, true)) == 0) return (0); WT_RET_NOTFOUND_OK(ret); @@ -690,7 +688,7 @@ __wt_config_getone(WT_SESSION_IMPL *session, { WT_CONFIG cparser; - WT_RET(__wt_config_init(session, &cparser, config)); + __wt_config_init(session, &cparser, config); return (__config_getraw(&cparser, key, value, true)); } @@ -706,7 +704,7 @@ __wt_config_getones(WT_SESSION_IMPL *session, WT_CONFIG_ITEM key_item = { key, strlen(key), 0, WT_CONFIG_ITEM_STRING }; - WT_RET(__wt_config_init(session, &cparser, config)); + __wt_config_init(session, &cparser, config); return (__config_getraw(&cparser, &key_item, value, true)); } @@ -771,7 +769,7 @@ __wt_config_subgetraw(WT_SESSION_IMPL *session, { WT_CONFIG cparser; - WT_RET(__wt_config_initn(session, &cparser, cfg->str, cfg->len)); + __wt_config_initn(session, &cparser, cfg->str, cfg->len); return (__config_getraw(&cparser, key, value, true)); } diff --git a/src/third_party/wiredtiger/src/config/config_api.c b/src/third_party/wiredtiger/src/config/config_api.c index b5228c4329c..8655057e94d 100644 --- a/src/third_party/wiredtiger/src/config/config_api.c +++ b/src/third_party/wiredtiger/src/config/config_api.c @@ -79,7 +79,6 @@ wiredtiger_config_parser_open(WT_SESSION *wt_session, WT_CONFIG_ITEM config_item = { config, len, 0, WT_CONFIG_ITEM_STRING }; WT_CONFIG_PARSER_IMPL *config_parser; - WT_DECL_RET; WT_SESSION_IMPL *session; *config_parserp = NULL; @@ -94,14 +93,10 @@ wiredtiger_config_parser_open(WT_SESSION *wt_session, * structure for iterations through the configuration string. */ memcpy(&config_parser->config_item, &config_item, sizeof(config_item)); - WT_ERR(__wt_config_initn(session, &config_parser->config, config, len)); - - if (ret == 0) - *config_parserp = (WT_CONFIG_PARSER *)config_parser; - else -err: __wt_free(session, config_parser); + __wt_config_initn(session, &config_parser->config, config, len); - return (ret); + *config_parserp = (WT_CONFIG_PARSER *)config_parser; + return (0); } /* diff --git a/src/third_party/wiredtiger/src/config/config_check.c b/src/third_party/wiredtiger/src/config/config_check.c index c29013483f6..d0aa09a96c1 100644 --- a/src/third_party/wiredtiger/src/config/config_check.c +++ b/src/third_party/wiredtiger/src/config/config_check.c @@ -91,9 +91,9 @@ config_check(WT_SESSION_IMPL *session, * that are not nul-terminated. */ if (config_len == 0) - WT_RET(__wt_config_init(session, &parser, config)); + __wt_config_init(session, &parser, config); else - WT_RET(__wt_config_initn(session, &parser, config, config_len)); + __wt_config_initn(session, &parser, config, config_len); while ((ret = __wt_config_next(&parser, &k, &v)) == 0) { if (k.type != WT_CONFIG_ITEM_STRING && k.type != WT_CONFIG_ITEM_ID) @@ -143,7 +143,7 @@ config_check(WT_SESSION_IMPL *session, continue; /* Setup an iterator for the check string. */ - WT_RET(__wt_config_init(session, &cparser, checks[i].checks)); + __wt_config_init(session, &cparser, checks[i].checks); while ((ret = __wt_config_next(&cparser, &ck, &cv)) == 0) { if (WT_STRING_MATCH("min", ck.str, ck.len)) { if (v.val < cv.val) @@ -169,8 +169,8 @@ config_check(WT_SESSION_IMPL *session, * Handle the 'verbose' case of a list * containing restricted choices. */ - WT_RET(__wt_config_subinit(session, - &sparser, &v)); + __wt_config_subinit( + session, &sparser, &v); found = true; while (found && (ret = __wt_config_next(&sparser, diff --git a/src/third_party/wiredtiger/src/config/config_collapse.c b/src/third_party/wiredtiger/src/config/config_collapse.c index 591d22284f5..ea956ebfff9 100644 --- a/src/third_party/wiredtiger/src/config/config_collapse.c +++ b/src/third_party/wiredtiger/src/config/config_collapse.c @@ -42,7 +42,7 @@ __wt_config_collapse( WT_RET(__wt_scr_alloc(session, 0, &tmp)); - WT_ERR(__wt_config_init(session, &cparser, cfg[0])); + __wt_config_init(session, &cparser, cfg[0]); while ((ret = __wt_config_next(&cparser, &k, &v)) == 0) { if (k.type != WT_CONFIG_ITEM_STRING && k.type != WT_CONFIG_ITEM_ID) @@ -127,7 +127,7 @@ __config_merge_scan(WT_SESSION_IMPL *session, WT_ERR(__wt_scr_alloc(session, 0, &kb)); WT_ERR(__wt_scr_alloc(session, 0, &vb)); - WT_ERR(__wt_config_init(session, &cparser, value)); + __wt_config_init(session, &cparser, value); while ((ret = __wt_config_next(&cparser, &k, &v)) == 0) { if (k.type != WT_CONFIG_ITEM_STRING && k.type != WT_CONFIG_ITEM_ID) diff --git a/src/third_party/wiredtiger/src/config/config_def.c b/src/third_party/wiredtiger/src/config/config_def.c index 1aff2b47cc5..0ff2fd379d2 100644 --- a/src/third_party/wiredtiger/src/config/config_def.c +++ b/src/third_party/wiredtiger/src/config/config_def.c @@ -113,6 +113,9 @@ static const WT_CONFIG_CHECK confchk_WT_CONNECTION_reconfigure[] = { { "eviction", "category", NULL, NULL, confchk_wiredtiger_open_eviction_subconfigs, 2 }, + { "eviction_checkpoint_target", "int", + NULL, "min=0,max=99", + NULL, 0 }, { "eviction_dirty_target", "int", NULL, "min=1,max=99", NULL, 0 }, @@ -657,6 +660,9 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open[] = { { "eviction", "category", NULL, NULL, confchk_wiredtiger_open_eviction_subconfigs, 2 }, + { "eviction_checkpoint_target", "int", + NULL, "min=0,max=99", + NULL, 0 }, { "eviction_dirty_target", "int", NULL, "min=1,max=99", NULL, 0 }, @@ -738,6 +744,9 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open_all[] = { { "eviction", "category", NULL, NULL, confchk_wiredtiger_open_eviction_subconfigs, 2 }, + { "eviction_checkpoint_target", "int", + NULL, "min=0,max=99", + NULL, 0 }, { "eviction_dirty_target", "int", NULL, "min=1,max=99", NULL, 0 }, @@ -818,6 +827,9 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open_basecfg[] = { { "eviction", "category", NULL, NULL, confchk_wiredtiger_open_eviction_subconfigs, 2 }, + { "eviction_checkpoint_target", "int", + NULL, "min=0,max=99", + NULL, 0 }, { "eviction_dirty_target", "int", NULL, "min=1,max=99", NULL, 0 }, @@ -894,6 +906,9 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open_usercfg[] = { { "eviction", "category", NULL, NULL, confchk_wiredtiger_open_eviction_subconfigs, 2 }, + { "eviction_checkpoint_target", "int", + NULL, "min=0,max=99", + NULL, 0 }, { "eviction_dirty_target", "int", NULL, "min=1,max=99", NULL, 0 }, @@ -989,7 +1004,8 @@ static const WT_CONFIG_ENTRY config_entries[] = { { "WT_CONNECTION.reconfigure", "async=(enabled=false,ops_max=1024,threads=2),cache_overhead=8," "cache_size=100MB,checkpoint=(log_size=0,wait=0),error_prefix=," - "eviction=(threads_max=1,threads_min=1),eviction_dirty_target=5," + "eviction=(threads_max=1,threads_min=1)," + "eviction_checkpoint_target=5,eviction_dirty_target=5," "eviction_dirty_trigger=20,eviction_target=80,eviction_trigger=95" ",file_manager=(close_handle_minimum=250,close_idle_time=30," "close_scan_interval=10),log=(archive=true,prealloc=true," @@ -998,7 +1014,7 @@ static const WT_CONFIG_ENTRY config_entries[] = { "size=500MB),statistics=none,statistics_log=(json=false," "on_close=false,sources=,timestamp=\"%b %d %H:%M:%S\",wait=0)," "verbose=", - confchk_WT_CONNECTION_reconfigure, 18 + confchk_WT_CONNECTION_reconfigure, 19 }, { "WT_CONNECTION.set_file_system", "", @@ -1190,7 +1206,8 @@ static const WT_CONFIG_ENTRY config_entries[] = { ",cache_overhead=8,cache_size=100MB,checkpoint=(log_size=0," "wait=0),checkpoint_sync=true,config_base=true,create=false," "direct_io=,encryption=(keyid=,name=,secretkey=),error_prefix=," - "eviction=(threads_max=1,threads_min=1),eviction_dirty_target=5," + "eviction=(threads_max=1,threads_min=1)," + "eviction_checkpoint_target=5,eviction_dirty_target=5," "eviction_dirty_trigger=20,eviction_target=80,eviction_trigger=95" ",exclusive=false,extensions=,file_extend=," "file_manager=(close_handle_minimum=250,close_idle_time=30," @@ -1205,14 +1222,15 @@ static const WT_CONFIG_ENTRY config_entries[] = { ",wait=0),transaction_sync=(enabled=false,method=fsync)," "use_environment=true,use_environment_priv=false,verbose=," "write_through=", - confchk_wiredtiger_open, 38 + confchk_wiredtiger_open, 39 }, { "wiredtiger_open_all", "async=(enabled=false,ops_max=1024,threads=2),buffer_alignment=-1" ",cache_overhead=8,cache_size=100MB,checkpoint=(log_size=0," "wait=0),checkpoint_sync=true,config_base=true,create=false," "direct_io=,encryption=(keyid=,name=,secretkey=),error_prefix=," - "eviction=(threads_max=1,threads_min=1),eviction_dirty_target=5," + "eviction=(threads_max=1,threads_min=1)," + "eviction_checkpoint_target=5,eviction_dirty_target=5," "eviction_dirty_trigger=20,eviction_target=80,eviction_trigger=95" ",exclusive=false,extensions=,file_extend=," "file_manager=(close_handle_minimum=250,close_idle_time=30," @@ -1227,16 +1245,17 @@ static const WT_CONFIG_ENTRY config_entries[] = { ",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, 39 + confchk_wiredtiger_open_all, 40 }, { "wiredtiger_open_basecfg", "async=(enabled=false,ops_max=1024,threads=2),buffer_alignment=-1" ",cache_overhead=8,cache_size=100MB,checkpoint=(log_size=0," "wait=0),checkpoint_sync=true,direct_io=,encryption=(keyid=,name=" ",secretkey=),error_prefix=,eviction=(threads_max=1," - "threads_min=1),eviction_dirty_target=5,eviction_dirty_trigger=20" - ",eviction_target=80,eviction_trigger=95,extensions=,file_extend=" - ",file_manager=(close_handle_minimum=250,close_idle_time=30," + "threads_min=1),eviction_checkpoint_target=5," + "eviction_dirty_target=5,eviction_dirty_trigger=20," + "eviction_target=80,eviction_trigger=95,extensions=,file_extend=," + "file_manager=(close_handle_minimum=250,close_idle_time=30," "close_scan_interval=10),hazard_max=1000,log=(archive=true," "compressor=,enabled=false,file_max=100MB,path=\".\"," "prealloc=true,recover=on,zero_fill=false)," @@ -1247,16 +1266,17 @@ static const WT_CONFIG_ENTRY config_entries[] = { ",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, 33 + confchk_wiredtiger_open_basecfg, 34 }, { "wiredtiger_open_usercfg", "async=(enabled=false,ops_max=1024,threads=2),buffer_alignment=-1" ",cache_overhead=8,cache_size=100MB,checkpoint=(log_size=0," "wait=0),checkpoint_sync=true,direct_io=,encryption=(keyid=,name=" ",secretkey=),error_prefix=,eviction=(threads_max=1," - "threads_min=1),eviction_dirty_target=5,eviction_dirty_trigger=20" - ",eviction_target=80,eviction_trigger=95,extensions=,file_extend=" - ",file_manager=(close_handle_minimum=250,close_idle_time=30," + "threads_min=1),eviction_checkpoint_target=5," + "eviction_dirty_target=5,eviction_dirty_trigger=20," + "eviction_target=80,eviction_trigger=95,extensions=,file_extend=," + "file_manager=(close_handle_minimum=250,close_idle_time=30," "close_scan_interval=10),hazard_max=1000,log=(archive=true," "compressor=,enabled=false,file_max=100MB,path=\".\"," "prealloc=true,recover=on,zero_fill=false)," @@ -1267,7 +1287,7 @@ static const WT_CONFIG_ENTRY config_entries[] = { ",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, 32 + confchk_wiredtiger_open_usercfg, 33 }, { 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 ab7657c3a89..61683f3394e 100644 --- a/src/third_party/wiredtiger/src/conn/conn_api.c +++ b/src/third_party/wiredtiger/src/conn/conn_api.c @@ -919,7 +919,7 @@ __conn_load_extensions( 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)); + __wt_config_subinit(session, &subconfig, &cval); while ((ret = __wt_config_next(&subconfig, &skey, &sval)) == 0) { if (expath == NULL) WT_ERR(__wt_scr_alloc(session, 0, &expath)); @@ -1020,7 +1020,7 @@ err: /* } /* Release all named snapshots. */ - WT_TRET(__wt_txn_named_snapshot_destroy(session)); + __wt_txn_named_snapshot_destroy(session); /* Close open, external sessions. */ for (s = conn->sessions, i = 0; i < conn->session_cnt; ++s, ++i) @@ -1854,7 +1854,7 @@ __conn_write_base_config(WT_SESSION_IMPL *session, const char *cfg[]) "readonly=," "use_environment_priv=," "verbose=,", &base_config)); - WT_ERR(__wt_config_init(session, &parser, base_config)); + __wt_config_init(session, &parser, base_config); while ((ret = __wt_config_next(&parser, &k, &v)) == 0) { /* Fix quoting for non-trivial settings. */ if (v.type == WT_CONFIG_ITEM_STRING) { @@ -2009,7 +2009,7 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler, session->name = "wiredtiger_open"; /* Do standard I/O and error handling first. */ - WT_ERR(__wt_os_stdio(session)); + __wt_os_stdio(session); __wt_event_handler_set(session, event_handler); /* diff --git a/src/third_party/wiredtiger/src/conn/conn_cache.c b/src/third_party/wiredtiger/src/conn/conn_cache.c index ba1e0210334..7e94e9e87dc 100644 --- a/src/third_party/wiredtiger/src/conn/conn_cache.c +++ b/src/third_party/wiredtiger/src/conn/conn_cache.c @@ -42,11 +42,33 @@ __cache_config_local(WT_SESSION_IMPL *session, bool shared, const char *cfg[]) WT_RET(__wt_config_gets(session, cfg, "eviction_trigger", &cval)); cache->eviction_trigger = (u_int)cval.val; - WT_RET(__wt_config_gets(session, cfg, "eviction_dirty_target", &cval)); - cache->eviction_dirty_target = (u_int)cval.val; + if (F_ISSET(conn, WT_CONN_IN_MEMORY)) + cache->eviction_checkpoint_target = + cache->eviction_dirty_target = + cache->eviction_dirty_trigger = 100U; + else { + WT_RET(__wt_config_gets( + session, cfg, "eviction_checkpoint_target", &cval)); + cache->eviction_checkpoint_target = (u_int)cval.val; + + WT_RET(__wt_config_gets( + session, cfg, "eviction_dirty_target", &cval)); + cache->eviction_dirty_target = (u_int)cval.val; - WT_RET(__wt_config_gets(session, cfg, "eviction_dirty_trigger", &cval)); - cache->eviction_dirty_trigger = (u_int)cval.val; + /* + * Sanity check the checkpoint target: don't allow a value + * lower than the dirty target. + */ + if (cache->eviction_checkpoint_target > 0 && + cache->eviction_checkpoint_target < + cache->eviction_dirty_target) + cache->eviction_checkpoint_target = + cache->eviction_dirty_target; + + WT_RET(__wt_config_gets( + session, cfg, "eviction_dirty_trigger", &cval)); + cache->eviction_dirty_trigger = (u_int)cval.val; + } WT_RET(__wt_config_gets(session, cfg, "eviction.threads_max", &cval)); WT_ASSERT(session, cval.val > 0); 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 15517f37b6a..79c2fc23da5 100644 --- a/src/third_party/wiredtiger/src/conn/conn_cache_pool.c +++ b/src/third_party/wiredtiger/src/conn/conn_cache_pool.c @@ -34,10 +34,10 @@ #define WT_CACHE_POOL_APP_WAIT_MULTIPLIER 6 #define WT_CACHE_POOL_READ_MULTIPLIER 1 -static int __cache_pool_adjust( +static void __cache_pool_adjust( WT_SESSION_IMPL *, uint64_t, uint64_t, bool, bool *); -static int __cache_pool_assess(WT_SESSION_IMPL *, uint64_t *); -static int __cache_pool_balance(WT_SESSION_IMPL *, bool); +static void __cache_pool_assess(WT_SESSION_IMPL *, uint64_t *); +static void __cache_pool_balance(WT_SESSION_IMPL *, bool); /* * __wt_cache_pool_config -- @@ -414,11 +414,10 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) * Do a pass over the cache pool members and ensure the pool is being * effectively used. */ -static int +static void __cache_pool_balance(WT_SESSION_IMPL *session, bool forward) { WT_CACHE_POOL *cp; - WT_DECL_RET; bool adjusted; uint64_t bump_threshold, highest; @@ -429,10 +428,12 @@ __cache_pool_balance(WT_SESSION_IMPL *session, bool forward) __wt_spin_lock(NULL, &cp->cache_pool_lock); /* If the queue is empty there is nothing to do. */ - if (TAILQ_FIRST(&cp->cache_pool_qh) == NULL) - goto err; + if (TAILQ_FIRST(&cp->cache_pool_qh) == NULL) { + __wt_spin_unlock(NULL, &cp->cache_pool_lock); + return; + } - WT_ERR(__cache_pool_assess(session, &highest)); + __cache_pool_assess(session, &highest); bump_threshold = WT_CACHE_POOL_BUMP_THRESHOLD; /* @@ -442,8 +443,8 @@ __cache_pool_balance(WT_SESSION_IMPL *session, bool forward) */ while (F_ISSET(cp, WT_CACHE_POOL_ACTIVE) && F_ISSET(S2C(session)->cache, WT_CACHE_POOL_RUN)) { - WT_ERR(__cache_pool_adjust( - session, highest, bump_threshold, forward, &adjusted)); + __cache_pool_adjust( + session, highest, bump_threshold, forward, &adjusted); /* * Stop if the amount of cache being used is stable, and we * aren't over capacity. @@ -454,15 +455,14 @@ __cache_pool_balance(WT_SESSION_IMPL *session, bool forward) --bump_threshold; } -err: __wt_spin_unlock(NULL, &cp->cache_pool_lock); - return (ret); + __wt_spin_unlock(NULL, &cp->cache_pool_lock); } /* * __cache_pool_assess -- * Assess the usage of the cache pool. */ -static int +static void __cache_pool_assess(WT_SESSION_IMPL *session, uint64_t *phighest) { WT_CACHE_POOL *cp; @@ -548,7 +548,6 @@ __cache_pool_assess(WT_SESSION_IMPL *session, uint64_t *phighest) highest, entries); *phighest = highest; - return (0); } /* @@ -557,7 +556,7 @@ __cache_pool_assess(WT_SESSION_IMPL *session, uint64_t *phighest) * ignore cache load information, and reduce the allocation for every * connection allocated more than their reserved size. */ -static int +static void __cache_pool_adjust(WT_SESSION_IMPL *session, uint64_t highest, uint64_t bump_threshold, bool forward, bool *adjustedp) { @@ -600,7 +599,8 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, * assigned. */ pressure = cache->cp_pass_pressure / highest_percentile; - busy = __wt_eviction_needed(entry->default_session, &pct_full); + busy = __wt_eviction_needed( + entry->default_session, false, &pct_full); __wt_verbose(session, WT_VERB_SHARED_CACHE, "\t%5" PRIu64 ", %3" PRIu64 ", %2" PRIu32 ", %d, %2u", @@ -709,7 +709,6 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, */ } } - return (0); } /* @@ -756,7 +755,7 @@ __wt_cache_pool_server(void *arg) * reported in the balance function. */ if (F_ISSET(cache, WT_CACHE_POOL_MANAGER)) { - (void)__cache_pool_balance(session, forward); + __cache_pool_balance(session, forward); forward = !forward; } } diff --git a/src/third_party/wiredtiger/src/conn/conn_ckpt.c b/src/third_party/wiredtiger/src/conn/conn_ckpt.c index 5e9d8f70193..b4913043d63 100644 --- a/src/third_party/wiredtiger/src/conn/conn_ckpt.c +++ b/src/third_party/wiredtiger/src/conn/conn_ckpt.c @@ -93,7 +93,7 @@ __ckpt_server(void *arg) /* Reset. */ if (conn->ckpt_logsize) { __wt_log_written_reset(session); - conn->ckpt_signalled = 0; + conn->ckpt_signalled = false; /* * In case we crossed the log limit during the @@ -226,9 +226,8 @@ __wt_checkpoint_server_destroy(WT_SESSION_IMPL *session) /* * __wt_checkpoint_signal -- * Signal the checkpoint thread if sufficient log has been written. - * Return 1 if this signals the checkpoint thread, 0 otherwise. */ -int +void __wt_checkpoint_signal(WT_SESSION_IMPL *session, wt_off_t logsize) { WT_CONNECTION_IMPL *conn; @@ -237,7 +236,6 @@ __wt_checkpoint_signal(WT_SESSION_IMPL *session, wt_off_t logsize) WT_ASSERT(session, WT_CKPT_LOGSIZE(conn)); if (logsize >= conn->ckpt_logsize && !conn->ckpt_signalled) { __wt_cond_signal(session, conn->ckpt_cond); - conn->ckpt_signalled = 1; + conn->ckpt_signalled = true; } - 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 9eb4d4a7746..ec850c793cc 100644 --- a/src/third_party/wiredtiger/src/conn/conn_dhandle.c +++ b/src/third_party/wiredtiger/src/conn/conn_dhandle.c @@ -488,9 +488,9 @@ __wt_conn_dhandle_close_all( * open at this point. Close the handle, if necessary. */ if (F_ISSET(dhandle, WT_DHANDLE_OPEN)) { - if ((ret = __wt_meta_track_sub_on(session)) == 0) - ret = __wt_conn_btree_sync_and_close( - session, false, force); + __wt_meta_track_sub_on(session); + ret = __wt_conn_btree_sync_and_close( + session, false, force); /* * If the close succeeded, drop any locks it acquired. diff --git a/src/third_party/wiredtiger/src/conn/conn_log.c b/src/third_party/wiredtiger/src/conn/conn_log.c index 6c05376f9ce..a8f0fe4810b 100644 --- a/src/third_party/wiredtiger/src/conn/conn_log.c +++ b/src/third_party/wiredtiger/src/conn/conn_log.c @@ -421,15 +421,27 @@ __log_file_server(void *arg) * later syncs. */ WT_ERR(__wt_fsync(session, close_fh, true)); + /* * 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 + * We can't truncate the file during hot backup, + * or the underlying file system may not support + * truncate: both are OK, it's just more work * during cursor traversal. */ - WT_ERR_ERROR_OK(__wt_ftruncate(session, - close_fh, close_end_lsn.l.offset), ENOTSUP); + if (!conn->hot_backup) { + __wt_readlock( + session, conn->hot_backup_lock); + if (!conn->hot_backup) + WT_ERR_ERROR_OK( + __wt_ftruncate(session, + close_fh, + close_end_lsn.l.offset), + ENOTSUP); + __wt_readunlock( + session, conn->hot_backup_lock); + } WT_SET_LSN(&close_end_lsn, close_end_lsn.l.file + 1, 0); __wt_spin_lock(session, &log->log_sync_lock); diff --git a/src/third_party/wiredtiger/src/conn/conn_stat.c b/src/third_party/wiredtiger/src/conn/conn_stat.c index 0894d1c6058..530bbfcd2db 100644 --- a/src/third_party/wiredtiger/src/conn/conn_stat.c +++ b/src/third_party/wiredtiger/src/conn/conn_stat.c @@ -155,13 +155,13 @@ __statlog_config(WT_SESSION_IMPL *session, const char **cfg, bool *runp) WT_ERR(__wt_filename(session, tmp->data, &conn->stat_path)); WT_ERR(__wt_config_gets(session, cfg, "statistics_log.sources", &cval)); - WT_ERR(__wt_config_subinit(session, &objectconf, &cval)); + __wt_config_subinit(session, &objectconf, &cval); for (cnt = 0; (ret = __wt_config_next(&objectconf, &k, &v)) == 0; ++cnt) ; WT_ERR_NOTFOUND_OK(ret); if (cnt != 0) { WT_ERR(__wt_calloc_def(session, cnt + 1, &sources)); - WT_ERR(__wt_config_subinit(session, &objectconf, &cval)); + __wt_config_subinit(session, &objectconf, &cval); for (cnt = 0; (ret = __wt_config_next(&objectconf, &k, &v)) == 0; ++cnt) { /* diff --git a/src/third_party/wiredtiger/src/conn/conn_sweep.c b/src/third_party/wiredtiger/src/conn/conn_sweep.c index dda296f50f3..25057d73564 100644 --- a/src/third_party/wiredtiger/src/conn/conn_sweep.c +++ b/src/third_party/wiredtiger/src/conn/conn_sweep.c @@ -17,7 +17,7 @@ * Mark idle handles with a time of death, and note if we see dead * handles. */ -static int +static void __sweep_mark(WT_SESSION_IMPL *session, time_t now) { WT_CONNECTION_IMPL *conn; @@ -50,8 +50,6 @@ __sweep_mark(WT_SESSION_IMPL *session, time_t now) dhandle->timeofdeath = now; WT_STAT_FAST_CONN_INCR(session, dh_sweep_tod); } - - return (0); } /* @@ -286,10 +284,10 @@ __sweep_server(void *arg) * 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. + * which will stop the cache from moving into the stuck state. */ if (__wt_las_is_written(session) && - !F_ISSET(conn->cache, WT_CACHE_STUCK)) { + !__wt_cache_stuck(session)) { oldest_id = __wt_txn_oldest_id(session); if (WT_TXNID_LT(last_las_sweep_id, oldest_id)) { WT_ERR(__wt_las_sweep(session)); @@ -303,7 +301,7 @@ __sweep_server(void *arg) * never become idle. */ if (conn->sweep_idle_time != 0) - WT_ERR(__sweep_mark(session, now)); + __sweep_mark(session, now); /* * Close handles if we have reached the configured limit. diff --git a/src/third_party/wiredtiger/src/cursor/cur_backup.c b/src/third_party/wiredtiger/src/cursor/cur_backup.c index 598da3f0ac6..3a3ff7de92b 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_backup.c +++ b/src/third_party/wiredtiger/src/cursor/cur_backup.c @@ -387,7 +387,7 @@ __backup_uri(WT_SESSION_IMPL *session, * otherwise it's not our problem. */ WT_RET(__wt_config_gets(session, cfg, "target", &cval)); - WT_RET(__wt_config_subinit(session, &targetconf, &cval)); + __wt_config_subinit(session, &targetconf, &cval); for (target_list = false; (ret = __wt_config_next(&targetconf, &k, &v)) == 0; target_list = true) { diff --git a/src/third_party/wiredtiger/src/cursor/cur_index.c b/src/third_party/wiredtiger/src/cursor/cur_index.c index 82a27d65ce6..ea742cac435 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_index.c +++ b/src/third_party/wiredtiger/src/cursor/cur_index.c @@ -513,8 +513,8 @@ __wt_curindex_open(WT_SESSION_IMPL *session, WT_ERR(__curindex_open_colgroups(session, cindex, cfg)); if (F_ISSET(cursor, WT_CURSTD_DUMP_JSON)) - WT_ERR(__wt_json_column_init(cursor, table->key_format, - &idx->colconf, &table->colconf)); + __wt_json_column_init( + cursor, table->key_format, &idx->colconf, &table->colconf); if (0) { err: WT_TRET(__curindex_close(cursor)); diff --git a/src/third_party/wiredtiger/src/cursor/cur_join.c b/src/third_party/wiredtiger/src/cursor/cur_join.c index f6cd5d90f62..087411febda 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_join.c +++ b/src/third_party/wiredtiger/src/cursor/cur_join.c @@ -873,7 +873,7 @@ insert: } else WT_ERR(c->get_key(c, &curvalue)); - WT_ERR(__wt_bloom_insert(bloom, &curvalue)); + __wt_bloom_insert(bloom, &curvalue); entry->stats.bloom_insert++; advance: if ((ret = c->next(c)) == WT_NOTFOUND) @@ -916,6 +916,9 @@ __curjoin_init_next(WT_SESSION_IMPL *session, WT_CURSOR_JOIN *cjoin, "join cursor has not yet been joined with any other " "cursors"); + /* Get a consistent view of our subordinate cursors if appropriate. */ + WT_RET(__wt_txn_cursor_op(session)); + if (F_ISSET((WT_CURSOR *)cjoin, WT_CURSTD_RAW)) config = &raw_cfg[0]; else diff --git a/src/third_party/wiredtiger/src/cursor/cur_json.c b/src/third_party/wiredtiger/src/cursor/cur_json.c index f0fa0d8aec2..bb24e88cba5 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_json.c +++ b/src/third_party/wiredtiger/src/cursor/cur_json.c @@ -186,7 +186,7 @@ __json_struct_size(WT_SESSION_IMPL *session, const void *buffer, result = 0; needcr = false; - WT_RET(__pack_name_init(session, names, iskey, &packname)); + __pack_name_init(session, names, iskey, &packname); WT_RET(__pack_init(session, &pack, fmt)); while ((ret = __pack_next(&pack, &pv)) == 0) { if (needcr) @@ -231,7 +231,7 @@ __json_struct_unpackv(WT_SESSION_IMPL *session, /* Unpacking a cursor marked as json implies a single arg. */ *va_arg(ap, const char **) = (char *)jbuf; - WT_RET(__pack_name_init(session, names, iskey, &packname)); + __pack_name_init(session, names, iskey, &packname); WT_RET(__pack_init(session, &pack, fmt)); while ((ret = __pack_next(&pack, &pv)) == 0) { if (needcr) { @@ -365,10 +365,10 @@ __wt_json_unpack_char(u_char ch, u_char *buf, size_t bufsz, bool force_unicode) /* * __wt_json_column_init -- - * set json_key_names, json_value_names to comma separated lists + * Set json_key_names, json_value_names to comma separated lists * of column names. */ -int +void __wt_json_column_init(WT_CURSOR *cursor, const char *keyformat, const WT_CONFIG_ITEM *idxconf, const WT_CONFIG_ITEM *colconf) { @@ -408,7 +408,6 @@ __wt_json_column_init(WT_CURSOR *cursor, const char *keyformat, json->key_names.str = beginkey; json->key_names.len = WT_PTRDIFF(p, beginkey); } - return (0); } #define MATCH_KEYWORD(session, in, result, keyword, matchval) do { \ @@ -774,7 +773,7 @@ __json_pack_size( bool multi; const char *tokstart; - WT_RET(__pack_name_init(session, names, iskey, &packname)); + __pack_name_init(session, names, iskey, &packname); multi = false; WT_RET(__pack_init(session, &pack, fmt)); for (total = 0; __pack_next(&pack, &pv) == 0;) { diff --git a/src/third_party/wiredtiger/src/cursor/cur_std.c b/src/third_party/wiredtiger/src/cursor/cur_std.c index 86594179907..bf7280f796b 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_std.c +++ b/src/third_party/wiredtiger/src/cursor/cur_std.c @@ -539,7 +539,6 @@ err: cursor->saved_err = ret; int __wt_cursor_close(WT_CURSOR *cursor) { - WT_DECL_RET; WT_SESSION_IMPL *session; session = (WT_SESSION_IMPL *)cursor->session; @@ -557,7 +556,7 @@ __wt_cursor_close(WT_CURSOR *cursor) __wt_free(session, cursor->internal_uri); __wt_free(session, cursor->uri); __wt_overwrite_and_free(session, cursor); - return (ret); + return (0); } /* diff --git a/src/third_party/wiredtiger/src/cursor/cur_table.c b/src/third_party/wiredtiger/src/cursor/cur_table.c index a14b40a1150..0498c89fcbe 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_table.c +++ b/src/third_party/wiredtiger/src/cursor/cur_table.c @@ -938,8 +938,8 @@ __wt_curtable_open(WT_SESSION_IMPL *session, cursor, cursor->internal_uri, owner, cfg, cursorp)); if (F_ISSET(cursor, WT_CURSTD_DUMP_JSON)) - WT_ERR(__wt_json_column_init(cursor, table->key_format, - NULL, &table->colconf)); + __wt_json_column_init( + cursor, table->key_format, NULL, &table->colconf); /* * Open the colgroup cursors immediately: we're going to need them for diff --git a/src/third_party/wiredtiger/src/docs/upgrading.dox b/src/third_party/wiredtiger/src/docs/upgrading.dox index 9d3d2239bb4..3a448818230 100644 --- a/src/third_party/wiredtiger/src/docs/upgrading.dox +++ b/src/third_party/wiredtiger/src/docs/upgrading.dox @@ -12,8 +12,9 @@ the volume of dirty data in cache under 20%. For write-heavy workloads, the new defaults may result in lower throughput and more threads writing to data files concurrently. -These settings also now determine how much work is done at the beginning of a -checkpoint to make the critical section of checkpoints complete more quickly. +There is also a new \c eviction_checkpoint_target setting that determines +how much work is done at the beginning of a checkpoint to make the critical +section of checkpoints complete more quickly. </dd> <dt>Checkpoint server created checkpoint names</dt> diff --git a/src/third_party/wiredtiger/src/docs/wtperf.dox b/src/third_party/wiredtiger/src/docs/wtperf.dox index c794ee2f2d7..a49d0d9f871 100644 --- a/src/third_party/wiredtiger/src/docs/wtperf.dox +++ b/src/third_party/wiredtiger/src/docs/wtperf.dox @@ -185,6 +185,8 @@ execute a read prior to each insert in workload phase key size @par log_partial (boolean, default=false) perform partial logging on first table only. +@par log_like_table (boolean, default=false) +Append all modification operations to another shared table. @par min_throughput (unsigned int, default=0) notify if any throughput measured is less than this amount. Aborts or prints warning based on min_throughput_fatal setting. Requires diff --git a/src/third_party/wiredtiger/src/evict/evict_lru.c b/src/third_party/wiredtiger/src/evict/evict_lru.c index 5a9f4dabb08..69fff96fef5 100644 --- a/src/third_party/wiredtiger/src/evict/evict_lru.c +++ b/src/third_party/wiredtiger/src/evict/evict_lru.c @@ -305,7 +305,7 @@ __evict_server(WT_SESSION_IMPL *session, bool *did_work) * Clear the walks so we don't pin pages while asleep, * otherwise we can block applications evicting large pages. */ - if (!F_ISSET(cache, WT_CACHE_STUCK)) { + if (!__wt_cache_stuck(session)) { for (spins = 0; (ret = __wt_spin_trylock( session, &conn->dhandle_lock)) == EBUSY && cache->pass_intr == 0; spins++) { @@ -426,20 +426,20 @@ __evict_update_work(WT_SESSION_IMPL *session) { WT_CACHE *cache; WT_CONNECTION_IMPL *conn; + double dirty_trigger; uint64_t bytes_inuse, bytes_max, dirty_inuse; conn = S2C(session); cache = conn->cache; - WT_STAT_FAST_CONN_SET(session, cache_eviction_aggressive_set, 0); /* Clear previous state. */ - cache->state = 0; + F_CLR(cache, WT_CACHE_EVICT_MASK); if (!F_ISSET(conn, WT_CONN_EVICTION_RUN)) return (false); if (!__evict_queue_empty(cache->evict_urgent_queue)) - FLD_SET(cache->state, WT_EVICT_STATE_URGENT); + F_SET(cache, WT_CACHE_EVICT_URGENT); /* * If we need space in the cache, try to find clean pages to evict. @@ -450,45 +450,32 @@ __evict_update_work(WT_SESSION_IMPL *session) bytes_max = conn->cache_size + 1; bytes_inuse = __wt_cache_bytes_inuse(cache); if (bytes_inuse > (cache->eviction_target * bytes_max) / 100) - FLD_SET(cache->state, WT_EVICT_STATE_CLEAN); + F_SET(cache, WT_CACHE_EVICT_CLEAN); if (bytes_inuse > (cache->eviction_trigger * bytes_max) / 100) - FLD_SET(cache->state, WT_EVICT_STATE_CLEAN_HARD); + F_SET(cache, WT_CACHE_EVICT_CLEAN_HARD); dirty_inuse = __wt_cache_dirty_leaf_inuse(cache); if (dirty_inuse > (cache->eviction_dirty_target * bytes_max) / 100) - FLD_SET(cache->state, WT_EVICT_STATE_DIRTY); - if (dirty_inuse > (cache->eviction_dirty_trigger * bytes_max) / 100) - FLD_SET(cache->state, WT_EVICT_STATE_DIRTY_HARD); + F_SET(cache, WT_CACHE_EVICT_DIRTY); + if ((dirty_trigger = cache->eviction_scrub_limit) < 1.0) + dirty_trigger = (double)cache->eviction_dirty_trigger; + if (dirty_inuse > (uint64_t)(dirty_trigger * bytes_max) / 100) + F_SET(cache, WT_CACHE_EVICT_DIRTY_HARD); /* * Scrub dirty pages and keep them in cache if we are less than half * way to the clean or dirty trigger. */ if (bytes_inuse < ((cache->eviction_target + cache->eviction_trigger) * - bytes_max) / 200 && dirty_inuse < + bytes_max) / 200 && dirty_inuse < (uint64_t) ((cache->eviction_dirty_target + cache->eviction_dirty_trigger) * bytes_max) / 200) - FLD_SET(cache->state, WT_EVICT_STATE_SCRUB); + F_SET(cache, WT_CACHE_EVICT_SCRUB); - /* - * If the cache has been stuck and is now under control, clear the - * stuck flag. - */ - if (bytes_inuse < bytes_max && - dirty_inuse < (cache->eviction_dirty_trigger * bytes_max) / 100) - F_CLR(cache, WT_CACHE_STUCK); - - if (F_ISSET(cache, WT_CACHE_STUCK)) { - WT_ASSERT(session, cache->state != 0); - WT_STAT_FAST_CONN_SET(session, - cache_eviction_aggressive_set, 1); - FLD_SET(cache->state, WT_EVICT_STATE_AGGRESSIVE); - } - - WT_STAT_FAST_CONN_SET(session, cache_eviction_state, cache->state); + WT_STAT_FAST_CONN_SET(session, cache_eviction_state, + F_MASK(cache, WT_CACHE_EVICT_MASK)); - return (FLD_ISSET(cache->state, - WT_EVICT_STATE_ALL | WT_EVICT_STATE_URGENT)); + return (F_ISSET(cache, WT_CACHE_EVICT_ALL | WT_CACHE_EVICT_URGENT)); } /* @@ -500,23 +487,25 @@ __evict_pass(WT_SESSION_IMPL *session) { WT_CACHE *cache; WT_CONNECTION_IMPL *conn; - uint64_t pages_evicted; + WT_TXN_GLOBAL *txn_global; + struct timespec now, prev; + uint64_t oldest_id, pages_evicted, prev_oldest_id; u_int loop; conn = S2C(session); cache = conn->cache; + txn_global = &conn->txn_global; /* Track whether pages are being evicted and progress is made. */ pages_evicted = cache->pages_evict; + prev_oldest_id = txn_global->oldest_id; + WT_CLEAR(prev); /* Evict pages from the cache. */ - for (loop = 0;; loop++) { - /* - * If there is a request to clear eviction walks, do that now, - * before checking if the cache is full. - */ - if (cache->pass_intr != 0) - break; + for (loop = 0; cache->pass_intr == 0; loop++) { + WT_RET(__wt_epoch(session, &now)); + if (loop == 0) + prev = now; /* * Increment the shared read generation. Do this occasionally @@ -542,17 +531,11 @@ __evict_pass(WT_SESSION_IMPL *session) if (!__evict_update_work(session)) break; - if (loop > 10) { - WT_STAT_FAST_CONN_SET(session, - cache_eviction_aggressive_set, 1); - FLD_SET(cache->state, WT_EVICT_STATE_AGGRESSIVE); - } - /* * Try to start a new thread if we have capacity and haven't * reached the eviction targets. */ - if (FLD_ISSET(cache->state, WT_EVICT_STATE_ALL)) + if (F_ISSET(cache, WT_CACHE_EVICT_ALL)) WT_RET(__wt_thread_group_start_one( session, &conn->evict_threads, false)); @@ -562,52 +545,90 @@ __evict_pass(WT_SESSION_IMPL *session) conn->cache_size, cache->bytes_inmem, cache->bytes_dirty_intl + cache->bytes_dirty_leaf); - WT_RET(__evict_lru_walk(session)); + if (F_ISSET(cache, WT_CACHE_EVICT_ALL)) + WT_RET(__evict_lru_walk(session)); /* * If the queue has been empty recently, keep queuing more * pages to evict. If the rate of queuing pages is high * enough, this score will go to zero, in which case the * eviction server might as well help out with eviction. + * + * Also, if there is a single eviction server thread with no + * workers, it must service the urgent queue in case all + * application threads are busy. */ - if (cache->evict_empty_score < WT_EVICT_EMPTY_SCORE_CUTOFF || + if (cache->evict_empty_score < WT_EVICT_SCORE_CUTOFF || (!WT_EVICT_HAS_WORKERS(session) && !__evict_queue_empty(cache->evict_urgent_queue))) WT_RET(__evict_lru_pages(session, true)); + if (cache->pass_intr != 0) + break; + /* * If we're making progress, keep going; if we're not making * any progress at all, mark the cache "stuck" and go back to * sleep, it's not something we can fix. + * + * We check for progress every 20ms, the idea being that the + * aggressive score will reach 10 after 200ms if we aren't + * making progress and eviction will start considering more + * pages. If there is still no progress after 2s, we will + * treat the cache as stuck and start rolling back + * transactions and writing updates to the lookaside table. */ if (pages_evicted == cache->pages_evict) { + if (WT_TIMEDIFF_MS(now, prev) >= 20 && + F_ISSET(cache, WT_CACHE_EVICT_CLEAN_HARD | + WT_CACHE_EVICT_DIRTY_HARD)) { + if (cache->evict_aggressive_score < 100) + ++cache->evict_aggressive_score; + oldest_id = txn_global->oldest_id; + if (prev_oldest_id == oldest_id && + txn_global->current != oldest_id && + cache->evict_aggressive_score < 100) + ++cache->evict_aggressive_score; + WT_STAT_FAST_CONN_SET(session, + cache_eviction_aggressive_set, + cache->evict_aggressive_score); + prev = now; + prev_oldest_id = oldest_id; + } + /* - * Back off if we aren't making progress: walks hold - * the handle list lock, blocking other operations that - * can free space in cache, such as LSM discarding - * handles. - * - * Allow this wait to be interrupted (e.g. if a - * checkpoint completes): make sure we wait for a - * non-zero number of microseconds). + * Keep trying for long enough that we should be able + * to evict a page if the server isn't interfering. */ - WT_STAT_FAST_CONN_INCR(session, - cache_eviction_server_slept); - __wt_cond_wait(session, cache->evict_cond, WT_THOUSAND); - - if (loop == 100) { + if (loop < 100 || cache->evict_aggressive_score < 100) { /* - * Mark the cache as stuck if we need space - * and aren't evicting any pages. + * Back off if we aren't making progress: walks + * hold the handle list lock, blocking other + * operations that can free space in cache, + * such as LSM discarding handles. + * + * Allow this wait to be interrupted (e.g. if a + * checkpoint completes): make sure we wait for + * a non-zero number of microseconds). */ - F_SET(cache, WT_CACHE_STUCK); - WT_STAT_FAST_CONN_INCR( - session, cache_eviction_slow); - __wt_verbose(session, WT_VERB_EVICTSERVER, - "unable to reach eviction goal"); - break; + WT_STAT_FAST_CONN_INCR(session, + cache_eviction_server_slept); + __wt_cond_wait( + session, cache->evict_cond, WT_THOUSAND); + continue; } + + WT_STAT_FAST_CONN_INCR(session, cache_eviction_slow); + __wt_verbose(session, WT_VERB_EVICTSERVER, + "unable to reach eviction goal"); + break; } else { + if (cache->evict_aggressive_score > 0) { + --cache->evict_aggressive_score; + WT_STAT_FAST_CONN_SET(session, + cache_eviction_aggressive_set, + cache->evict_aggressive_score); + } loop = 0; pages_evicted = cache->pages_evict; } @@ -706,7 +727,6 @@ __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session) */ F_SET(btree, WT_BTREE_NO_EVICTION); (void)__wt_atomic_addv32(&cache->pass_intr, 1); - WT_FULL_BARRIER(); /* Clear any existing LRU eviction walk for the file. */ WT_WITH_PASS_LOCK(session, ret, @@ -823,7 +843,8 @@ __evict_lru_walk(WT_SESSION_IMPL *session) cache = S2C(session)->cache; /* Age out the score of how much the queue has been empty recently. */ - cache->evict_empty_score = (99 * cache->evict_empty_score) / 100; + if (cache->evict_empty_score > 0) + --cache->evict_empty_score; /* Fill the next queue (that isn't the urgent queue). */ queue = cache->evict_fill_queue; @@ -832,7 +853,7 @@ __evict_lru_walk(WT_SESSION_IMPL *session) /* If this queue is full, try the other one. */ if (__evict_queue_full(queue) && !__evict_queue_full(other_queue)) queue = other_queue; - other_queue = cache->evict_fill_queue = + cache->evict_fill_queue = &cache->evict_queues[1 - (queue - cache->evict_queues)]; /* @@ -840,24 +861,58 @@ __evict_lru_walk(WT_SESSION_IMPL *session) * we're done. */ if (__evict_queue_full(queue) && - cache->evict_empty_score < WT_EVICT_EMPTY_SCORE_CUTOFF) + cache->evict_empty_score < WT_EVICT_SCORE_CUTOFF) return (0); /* Get some more pages to consider for eviction. */ - if ((ret = __evict_walk(cache->walk_session, queue)) != 0) - return (ret == EBUSY ? 0 : ret); - - /* Make sure the other queue is current before locking. */ - if (cache->evict_current_queue != other_queue) { - __wt_spin_lock(session, &cache->evict_queue_lock); - cache->evict_other_queue = queue; - cache->evict_current_queue = other_queue; - __wt_spin_unlock(session, &cache->evict_queue_lock); + switch (ret = __evict_walk(cache->walk_session, queue)) { + case 0: + break; + case EBUSY: + return (0); + case WT_NOTFOUND: + /* + * If we found no pages at all during the walk, something is + * wrong. Be more aggressive next time. + */ + if (F_ISSET(cache, + WT_CACHE_EVICT_CLEAN_HARD | WT_CACHE_EVICT_DIRTY_HARD)) + cache->evict_aggressive_score = WT_MIN( + cache->evict_aggressive_score + WT_EVICT_SCORE_BUMP, + WT_EVICT_SCORE_MAX); + WT_STAT_FAST_CONN_SET(session, + cache_eviction_aggressive_set, + cache->evict_aggressive_score); + return (0); + default: + return (ret); } + /* + * If the queue we are filling is empty, pages are being requested + * faster than they are being queued. + */ + if (__evict_queue_empty(queue)) { + if (F_ISSET(cache, + WT_CACHE_EVICT_CLEAN_HARD | WT_CACHE_EVICT_DIRTY_HARD)) + cache->evict_empty_score = WT_MIN( + cache->evict_empty_score + WT_EVICT_SCORE_BUMP, + WT_EVICT_SCORE_MAX); + WT_STAT_FAST_CONN_INCR(session, cache_eviction_queue_empty); + } else + WT_STAT_FAST_CONN_INCR(session, cache_eviction_queue_not_empty); + /* Sort the list into LRU order and restart. */ __wt_spin_lock(session, &queue->evict_lock); + /* + * We have locked the queue: in the (unusual) case where we are filling + * the current queue, mark it empty so that subsequent requests switch + * to the other queue. + */ + if (queue == cache->evict_current_queue) + queue->evict_current = NULL; + entries = queue->evict_entries; qsort(queue->evict_queue, entries, sizeof(WT_EVICT_ENTRY), __evict_lru_cmp); @@ -889,13 +944,9 @@ __evict_lru_walk(WT_SESSION_IMPL *session) } /* Decide how many of the candidates we're going to try and evict. */ - if (FLD_ISSET(cache->state, WT_EVICT_STATE_AGGRESSIVE)) { - /* - * Take all candidates if we only gathered pages with an oldest - * read generation set. - */ + if (__wt_cache_aggressive(session)) queue->evict_candidates = entries; - } else { + else { /* * Find the oldest read generation we have in the queue, used * to set the initial value for pages read into the system. @@ -939,18 +990,6 @@ __evict_lru_walk(WT_SESSION_IMPL *session) } } - if (__evict_queue_empty(queue)) { - /* - * This score varies between 0 (if the queue hasn't been empty - * for a long time) and 100 (if the queue has been empty the - * last 10 times we filled up. - */ - cache->evict_empty_score = WT_MIN(100, - cache->evict_empty_score + WT_EVICT_EMPTY_SCORE_BUMP); - WT_STAT_FAST_CONN_INCR(session, cache_eviction_queue_empty); - } else - WT_STAT_FAST_CONN_INCR(session, cache_eviction_queue_not_empty); - queue->evict_current = queue->evict_queue; __wt_spin_unlock(session, &queue->evict_lock); @@ -992,13 +1031,13 @@ __evict_walk(WT_SESSION_IMPL *session, WT_EVICT_QUEUE *queue) start_slot = slot = queue->evict_entries; max_entries = WT_MIN(slot + WT_EVICT_WALK_INCR, cache->evict_slots); -retry: while (slot < max_entries && ret == 0) { +retry: while (slot < max_entries) { /* * If another thread is waiting on the eviction server to clear * the walk point in a tree, give up. */ if (cache->pass_intr != 0) - break; + WT_ERR(EBUSY); /* * Lock the dhandle list to find the next handle and bump its @@ -1014,8 +1053,7 @@ retry: while (slot < max_entries && ret == 0) { else __wt_sleep(0, WT_THOUSAND); } - if (ret != 0) - break; + WT_ERR(ret); dhandle_locked = true; } @@ -1059,7 +1097,7 @@ retry: while (slot < max_entries && ret == 0) { * dirty pages. */ if (btree->checkpointing != WT_CKPT_OFF && - !FLD_ISSET(cache->state, WT_EVICT_STATE_CLEAN)) + !F_ISSET(cache, WT_CACHE_EVICT_CLEAN)) continue; /* @@ -1067,7 +1105,7 @@ retry: while (slot < max_entries && ret == 0) { * become aggressive. */ if (btree->evict_priority != 0 && - !FLD_ISSET(cache->state, WT_EVICT_STATE_AGGRESSIVE)) + !__wt_cache_aggressive(session)) continue; /* Skip files if we have used all available hazard pointers. */ @@ -1111,6 +1149,7 @@ retry: while (slot < max_entries && ret == 0) { WT_ASSERT(session, session->split_gen == 0); } __wt_spin_unlock(session, &cache->evict_walk_lock); + WT_ERR(ret); } /* @@ -1130,18 +1169,12 @@ retry: while (slot < max_entries && ret == 0) { incr = false; } - if (dhandle_locked) { - __wt_spin_unlock(session, &conn->dhandle_lock); - dhandle_locked = false; - } - /* * Walk the list of files a few times if we don't find enough pages. * Try two passes through all the files, give up when we have some * candidates and we aren't finding more. */ - if (cache->pass_intr == 0 && ret == 0 && - slot < max_entries && (retries < 2 || + if (slot < max_entries && (retries < 2 || (retries < 10 && (slot == queue->evict_entries || slot > start_slot)))) { start_slot = slot; @@ -1149,6 +1182,18 @@ retry: while (slot < max_entries && ret == 0) { goto retry; } +err: if (dhandle_locked) { + __wt_spin_unlock(session, &conn->dhandle_lock); + dhandle_locked = false; + } + + /* + * If we didn't find any entries on a walk when we weren't interrupted, + * let our caller know. + */ + if (queue->evict_entries == slot && cache->pass_intr == 0) + return (WT_NOTFOUND); + queue->evict_entries = slot; return (ret); } @@ -1166,7 +1211,7 @@ __evict_push_candidate(WT_SESSION_IMPL *session, /* * Threads can race to queue a page (e.g., an ordinary LRU walk can - * race with a page being queued for urgent eviction. + * race with a page being queued for urgent eviction). */ orig_flags = new_flags = ref->page->flags_atomic; FLD_SET(new_flags, WT_PAGE_EVICT_LRU); @@ -1187,7 +1232,7 @@ __evict_push_candidate(WT_SESSION_IMPL *session, evict->score = __evict_read_gen(evict); /* Adjust for size when doing dirty eviction. */ - if (FLD_ISSET(S2C(session)->cache->state, WT_EVICT_STATE_DIRTY) && + if (F_ISSET(S2C(session)->cache, WT_CACHE_EVICT_DIRTY) && evict->score != WT_READGEN_OLDEST && evict->score != UINT64_MAX && !__wt_page_is_modified(ref->page)) evict->score += WT_MEGABYTE - @@ -1212,6 +1257,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, WT_PAGE *page; WT_PAGE_MODIFY *mod; WT_REF *ref; + WT_TXN_GLOBAL *txn_global; uint64_t btree_inuse, bytes_per_slot, cache_inuse; uint64_t pages_seen, refs_walked; uint32_t remaining_slots, total_slots, walk_flags; @@ -1223,6 +1269,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, btree = S2BT(session); cache = conn->cache; internal_pages = restarts = 0; + txn_global = &conn->txn_global; /* * Figure out how many slots to fill from this tree. @@ -1238,7 +1285,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, * slots so we assign all of the slots to a tree filling 99+% of the * cache (and only have to walk it once). */ - if (FLD_ISSET(cache->state, WT_EVICT_STATE_CLEAN)) { + if (F_ISSET(cache, WT_CACHE_EVICT_CLEAN)) { btree_inuse = __wt_btree_bytes_inuse(session); cache_inuse = __wt_cache_bytes_inuse(cache); bytes_per_slot = 1 + cache_inuse / total_slots; @@ -1247,7 +1294,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, } else target_pages_clean = 0; - if (FLD_ISSET(cache->state, WT_EVICT_STATE_DIRTY)) { + if (F_ISSET(cache, WT_CACHE_EVICT_DIRTY)) { btree_inuse = __wt_btree_dirty_leaf_inuse(session); cache_inuse = __wt_cache_dirty_leaf_inuse(cache); bytes_per_slot = 1 + cache_inuse / total_slots; @@ -1341,16 +1388,16 @@ __evict_walk_file(WT_SESSION_IMPL *session, if (__wt_page_is_empty(page) || F_ISSET(session->dhandle, WT_DHANDLE_DEAD) || - FLD_ISSET(cache->state, WT_EVICT_STATE_AGGRESSIVE)) + __wt_cache_aggressive(session)) goto fast; /* Skip clean pages if appropriate. */ if (!modified && (F_ISSET(conn, WT_CONN_IN_MEMORY) || - !FLD_ISSET(cache->state, WT_EVICT_STATE_CLEAN))) + !F_ISSET(cache, WT_CACHE_EVICT_CLEAN))) continue; /* Skip dirty pages if appropriate. */ - if (modified && !FLD_ISSET(cache->state, WT_EVICT_STATE_DIRTY)) + if (modified && !F_ISSET(cache, WT_CACHE_EVICT_DIRTY)) continue; /* Limit internal pages to 50% of the total. */ @@ -1366,8 +1413,8 @@ __evict_walk_file(WT_SESSION_IMPL *session, * attempt to avoid repeated attempts to evict the same page. */ mod = page->modify; - if (modified && - (mod->last_oldest_id == __wt_txn_oldest_id(session) || + if (modified && txn_global->current != txn_global->oldest_id && + (mod->last_eviction_id == __wt_txn_oldest_id(session) || !__wt_txn_visible_all(session, mod->update_txn))) continue; @@ -1384,7 +1431,8 @@ fast: /* If the page can't be evicted, give up. */ ++internal_pages; __wt_verbose(session, WT_VERB_EVICTSERVER, - "select: %p, size %" PRIu64, page, page->memory_footprint); + "select: %p, size %" WT_SIZET_FMT, + (void *)page, page->memory_footprint); } WT_RET_NOTFOUND_OK(ret); @@ -1419,45 +1467,6 @@ fast: /* If the page can't be evicted, give up. */ } /* - * __evict_check_entry_size -- - * Check if the size of an entry is too large for this thread to evict. - * We use this so that the server thread doesn't get stalled evicting - * a very large page. - */ -static bool -__evict_check_entry_size(WT_SESSION_IMPL *session, WT_EVICT_ENTRY *entry) -{ - WT_CACHE *cache; - WT_PAGE *page; - WT_REF *ref; - uint64_t max; - - cache = S2C(session)->cache; - - if (cache->pages_evict == 0 || cache->bytes_evict < WT_MEGABYTE) - return (true); - - max = (cache->bytes_evict / cache->pages_evict) * 4; - if ((ref = entry->ref) != NULL) { - if ((page = ref->page) == NULL) - return (true); - - /* - * If this page is dirty and more than four times the average - * evicted page size then return false. Return true in all - * other cases. - */ - if (__wt_page_is_modified(page) && - page->memory_footprint > max) { - WT_STAT_FAST_CONN_INCR( - session, cache_eviction_server_toobig); - return (false); - } - } - return (true); -} - -/* * __evict_get_ref -- * Get a page for eviction. */ @@ -1476,7 +1485,7 @@ __evict_get_ref( is_app = !F_ISSET(session, WT_SESSION_INTERNAL); urgent_ok = (!is_app && !is_server) || !WT_EVICT_HAS_WORKERS(session) || - FLD_ISSET(cache->state, WT_EVICT_STATE_AGGRESSIVE); + __wt_cache_aggressive(session); urgent_queue = cache->evict_urgent_queue; *btreep = NULL; *refp = NULL; @@ -1500,7 +1509,7 @@ __evict_get_ref( * Such cases are extremely rare in real applications. */ if (is_server && - (cache->evict_empty_score > WT_EVICT_EMPTY_SCORE_CUTOFF || + (cache->evict_empty_score > WT_EVICT_SCORE_CUTOFF || __evict_queue_empty(cache->evict_fill_queue))) { do { if ((!urgent_ok || @@ -1569,26 +1578,17 @@ __evict_get_ref( WT_ASSERT(session, evict->btree != NULL); /* - * If the server is helping out and encounters an entry that is - * too large, it stops helping. Evicting a very large page in - * the server thread could stall eviction from finding new - * work. + * Evicting a dirty page in the server thread could stall + * during a write and prevent eviction from finding new work. * * However, we can't skip entries in the urgent queue or they * may never be found again. - */ - if (is_server && !urgent_ok && - !__evict_check_entry_size(session, evict)) { - --evict; - break; - } - - /* + * * Don't force application threads to evict dirty pages if they * aren't stalled by the amount of dirty data in cache. */ - if (is_app && !urgent_ok && - !FLD_ISSET(cache->state, WT_EVICT_STATE_DIRTY_HARD) && + if (!urgent_ok && (is_server || (is_app && + !F_ISSET(cache, WT_CACHE_EVICT_DIRTY_HARD))) && __wt_page_is_modified(evict->ref->page)) { --evict; break; @@ -1702,10 +1702,11 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full) WT_TXN_GLOBAL *txn_global; WT_TXN_STATE *txn_state; uint64_t init_evict_count, max_pages_evicted; - bool txn_busy; conn = S2C(session); cache = conn->cache; + txn_global = &conn->txn_global; + txn_state = WT_SESSION_TXN_STATE(session); /* * It is not safe to proceed if the eviction server threads aren't @@ -1714,26 +1715,9 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full) if (!conn->evict_server_running) return (0); - /* - * If the current transaction is keeping the oldest ID pinned, it is in - * the middle of an operation. This may prevent the oldest ID from - * moving forward, leading to deadlock, so only evict what we can. - * Otherwise, we are at a transaction boundary and we can work harder - * to make sure there is free space in the cache. - */ - txn_global = &conn->txn_global; - txn_state = WT_SESSION_TXN_STATE(session); - txn_busy = txn_state->id != WT_TXN_NONE || - session->nhazard > 0 || - (txn_state->snap_min != WT_TXN_NONE && - txn_global->current != txn_global->oldest_id); - - if (txn_busy && pct_full < 100) + if (busy && pct_full < 100) return (0); - if (busy) - txn_busy = true; - /* Wake the eviction server if we need to do work. */ __wt_evict_server_wake(session); @@ -1746,7 +1730,12 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full) init_evict_count = cache->pages_evict; for (;;) { - max_pages_evicted = txn_busy ? 5 : 20; + /* Check if we have become busy. */ + if (!busy && txn_state->snap_min != WT_TXN_NONE && + txn_global->current != txn_global->oldest_id) + busy = true; + + max_pages_evicted = busy ? 5 : 20; /* * A pathological case: if we're the oldest transaction in the @@ -1754,23 +1743,33 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full) * abort the transaction to give up all hazard pointers before * trying again. */ - if (F_ISSET(cache, WT_CACHE_STUCK) && - __wt_txn_am_oldest(session)) { - F_CLR(cache, WT_CACHE_STUCK); + if (__wt_cache_stuck(session) && __wt_txn_am_oldest(session)) { + --cache->evict_aggressive_score; WT_STAT_FAST_CONN_INCR(session, txn_fail_cache); return (WT_ROLLBACK); } /* See if eviction is still needed. */ - if (!__wt_eviction_needed(session, &pct_full) || + if (!__wt_eviction_needed(session, busy, &pct_full) || (pct_full < 100 && cache->pages_evict > init_evict_count + max_pages_evicted)) return (0); + /* + * Don't make application threads participate in scrubbing for + * checkpoints. Just throttle updates instead. + */ + if (busy && WT_EVICT_HAS_WORKERS(session) && + cache->eviction_scrub_limit > 0.0 && + !F_ISSET(cache, WT_CACHE_EVICT_CLEAN_HARD)) { + __wt_yield(); + continue; + } + /* Evict a page. */ switch (ret = __evict_page(session, false)) { case 0: - if (txn_busy) + if (busy) return (0); /* FALLTHROUGH */ case EBUSY: @@ -1778,17 +1777,12 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full) case WT_NOTFOUND: /* Allow the queue to re-populate before retrying. */ __wt_cond_wait( - session, conn->evict_threads.wait_cond, 100000); + session, conn->evict_threads.wait_cond, 10000); cache->app_waits++; break; default: return (ret); } - - /* Check if we have become busy. */ - if (!txn_busy && txn_state->snap_min != WT_TXN_NONE && - txn_global->current != txn_global->oldest_id) - txn_busy = true; } /* NOTREACHED */ } diff --git a/src/third_party/wiredtiger/src/evict/evict_page.c b/src/third_party/wiredtiger/src/evict/evict_page.c index 972c72bbfb0..5ddf787c1f5 100644 --- a/src/third_party/wiredtiger/src/evict/evict_page.c +++ b/src/third_party/wiredtiger/src/evict/evict_page.c @@ -31,14 +31,23 @@ __evict_exclusive_clear(WT_SESSION_IMPL *session, WT_REF *ref) static inline int __evict_exclusive(WT_SESSION_IMPL *session, WT_REF *ref) { + int loops; + WT_ASSERT(session, ref->state == WT_REF_LOCKED); /* * Check for a hazard pointer indicating another thread is using the * page, meaning the page cannot be evicted. */ - if (__wt_page_hazard_check(session, ref->page) == NULL) - return (0); + for (loops = 0; loops < 10; loops++) { + if (__wt_page_hazard_check(session, ref->page) == NULL) + return (0); + if (ref->page->read_gen != WT_READGEN_OLDEST && + ref->page->memory_footprint < + S2BT(session)->split_deepen_min_child) + break; + __wt_sleep(0, WT_THOUSAND); + } WT_STAT_FAST_DATA_INCR(session, cache_eviction_hazard); WT_STAT_FAST_CONN_INCR(session, cache_eviction_hazard); @@ -117,7 +126,7 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) tree_dead = F_ISSET(session->dhandle, WT_DHANDLE_DEAD); __wt_verbose(session, WT_VERB_EVICT, - "page %p (%s)", page, __wt_page_type_string(page->type)); + "page %p (%s)", (void *)page, __wt_page_type_string(page->type)); /* * Get exclusive access to the page and review it for conditions that @@ -524,7 +533,7 @@ __evict_review( if (F_ISSET(S2C(session), WT_CONN_IN_MEMORY)) LF_SET(WT_EVICT_IN_MEMORY | WT_EVICT_SCRUB | WT_EVICT_UPDATE_RESTORE); - else if (F_ISSET(cache, WT_CACHE_STUCK)) + else if (__wt_cache_stuck(session)) LF_SET(WT_EVICT_LOOKASIDE); else if (!__wt_txn_visible_all( session, page->modify->update_txn) || @@ -537,7 +546,7 @@ __evict_review( * page and keep it around. */ if (!LF_ISSET(WT_EVICT_LOOKASIDE) && - FLD_ISSET(cache->state, WT_EVICT_STATE_SCRUB)) + F_ISSET(cache, WT_CACHE_EVICT_SCRUB)) LF_SET(WT_EVICT_SCRUB); } *flagsp = flags; diff --git a/src/third_party/wiredtiger/src/include/block.h b/src/third_party/wiredtiger/src/include/block.h index 3342f9b1e5e..0cf76e34367 100644 --- a/src/third_party/wiredtiger/src/include/block.h +++ b/src/third_party/wiredtiger/src/include/block.h @@ -52,7 +52,8 @@ struct __wt_extlist { uint32_t entries; /* Entry count */ wt_off_t offset; /* Written extent offset */ - uint32_t cksum, size; /* Written extent cksum, size */ + uint32_t checksum; /* Written extent checksum */ + uint32_t size; /* Written extent size */ bool track_size; /* Maintain per-size skiplist */ @@ -128,7 +129,7 @@ struct __wt_block_ckpt { uint8_t version; /* Version */ wt_off_t root_offset; /* The root */ - uint32_t root_cksum, root_size; + uint32_t root_checksum, root_size; WT_EXTLIST alloc; /* Extents allocated */ WT_EXTLIST avail; /* Extents available */ @@ -282,7 +283,7 @@ struct __wt_block_desc { #define WT_BLOCK_MINOR_VERSION 0 uint16_t minorv; /* 06-07: Minor version */ - uint32_t cksum; /* 08-11: Description block checksum */ + uint32_t checksum; /* 08-11: Description block checksum */ uint32_t unused; /* 12-15: Padding */ }; @@ -305,7 +306,7 @@ __wt_block_desc_byteswap(WT_BLOCK_DESC *desc) desc->magic = __wt_bswap32(desc->magic); desc->majorv = __wt_bswap16(desc->majorv); desc->minorv = __wt_bswap16(desc->minorv); - desc->cksum = __wt_bswap32(desc->cksum); + desc->checksum = __wt_bswap32(desc->checksum); #else WT_UNUSED(desc); #endif @@ -335,7 +336,7 @@ struct __wt_block_header { * stored in the disk header. This is for salvage, so salvage knows it * has found a page that may be useful. */ - uint32_t cksum; /* 04-07: checksum */ + uint32_t checksum; /* 04-07: checksum */ #define WT_BLOCK_DATA_CKSUM 0x01 /* Block data is part of the checksum */ uint8_t flags; /* 08: flags */ @@ -364,7 +365,7 @@ __wt_block_header_byteswap_copy(WT_BLOCK_HEADER *from, WT_BLOCK_HEADER *to) *to = *from; #ifdef WORDS_BIGENDIAN to->disk_size = __wt_bswap32(from->disk_size); - to->cksum = __wt_bswap32(from->cksum); + to->checksum = __wt_bswap32(from->checksum); #endif } diff --git a/src/third_party/wiredtiger/src/include/btmem.h b/src/third_party/wiredtiger/src/include/btmem.h index a9d190c3b09..b4ca937e7ed 100644 --- a/src/third_party/wiredtiger/src/include/btmem.h +++ b/src/third_party/wiredtiger/src/include/btmem.h @@ -218,6 +218,14 @@ struct __wt_page_modify { /* The first unwritten transaction ID (approximate). */ uint64_t first_dirty_txn; + /* The transaction state last time eviction was attempted. */ + uint64_t last_eviction_id; + +#ifdef HAVE_DIAGNOSTIC + /* Check that transaction time moves forward. */ + uint64_t last_oldest_id; +#endif + /* Avoid checking for obsolete updates during checkpoints. */ uint64_t obsolete_check_txn; @@ -227,9 +235,6 @@ struct __wt_page_modify { /* The largest update transaction ID (approximate). */ uint64_t update_txn; - /* Check that transaction time moves forward. */ - uint64_t last_oldest_id; - /* Dirty bytes added to the cache. */ size_t bytes_dirty; @@ -306,7 +311,7 @@ struct __wt_page_modify { */ WT_ADDR addr; uint32_t size; - uint32_t cksum; + uint32_t checksum; } *multi; uint32_t multi_entries; /* Multiple blocks element count */ } m; diff --git a/src/third_party/wiredtiger/src/include/btree.i b/src/third_party/wiredtiger/src/include/btree.i index 1ca6426eef6..c07966a4453 100644 --- a/src/third_party/wiredtiger/src/include/btree.i +++ b/src/third_party/wiredtiger/src/include/btree.i @@ -1260,11 +1260,10 @@ __wt_page_can_evict( return (false); /* - * If the page is clean but has modifications that - * appear too new to evict, skip it. + * If the page is clean but has modifications that appear too new to + * evict, skip it. */ - if (!modified && mod != NULL && - !__wt_txn_visible_all(session, mod->rec_max_txn)) + if (!modified && !__wt_txn_visible_all(session, mod->rec_max_txn)) return (false); return (true); diff --git a/src/third_party/wiredtiger/src/include/cache.h b/src/third_party/wiredtiger/src/include/cache.h index c7e817fd391..0cb61f01435 100644 --- a/src/third_party/wiredtiger/src/include/cache.h +++ b/src/third_party/wiredtiger/src/include/cache.h @@ -57,7 +57,7 @@ struct __wt_cache { /* * Different threads read/write pages to/from the cache and create pages * in the cache, so we cannot know precisely how much memory is in use - * at any specific time. However, even though the values don't have to + * at any specific time. However, even though the values don't have to * be exact, they can't be garbage, we track what comes in and what goes * out and calculate the difference as needed. */ @@ -98,31 +98,61 @@ struct __wt_cache { WT_CONDVAR *evict_cond; /* Eviction server condition */ WT_SPINLOCK evict_walk_lock; /* Eviction walk location */ - u_int eviction_trigger; /* Percent to trigger eviction */ - u_int eviction_target; /* Percent to end eviction */ u_int eviction_dirty_target; /* Percent to allow dirty */ u_int eviction_dirty_trigger; /* Percent to trigger dirty eviction */ + u_int eviction_trigger; /* Percent to trigger eviction */ + u_int eviction_target; /* Percent to end eviction */ + + u_int eviction_checkpoint_target;/* Percent to reduce dirty + to during checkpoint scrubs */ + double eviction_scrub_limit; /* Percent of cache to trigger + dirty eviction during checkpoint + scrubs */ u_int overhead_pct; /* Cache percent adjustment */ /* + * Pass interrupt counter. + */ + volatile uint32_t pass_intr; /* Interrupt eviction pass. */ + + /* * LRU eviction list information. */ WT_SPINLOCK evict_pass_lock; /* Eviction pass lock */ WT_SESSION_IMPL *walk_session; /* Eviction pass session */ - WT_DATA_HANDLE - *evict_file_next; /* LRU next file to search */ + WT_DATA_HANDLE *evict_file_next;/* LRU next file to search */ + WT_SPINLOCK evict_queue_lock; /* Eviction current queue lock */ WT_EVICT_QUEUE evict_queues[WT_EVICT_QUEUE_MAX]; WT_EVICT_QUEUE *evict_current_queue; /* LRU current queue in use */ - WT_EVICT_QUEUE *evict_fill_queue; /* LRU next queue to fill */ + WT_EVICT_QUEUE *evict_fill_queue; /* LRU next queue to fill. + This is usually the same as the + "other" queue but under heavy + load the eviction server will + start filling the current queue + before it switches. */ WT_EVICT_QUEUE *evict_other_queue; /* LRU queue not in use */ WT_EVICT_QUEUE *evict_urgent_queue; /* LRU urgent queue */ uint32_t evict_slots; /* LRU list eviction slots */ -#define WT_EVICT_EMPTY_SCORE_BUMP 10 -#define WT_EVICT_EMPTY_SCORE_CUTOFF 10 - uint32_t evict_empty_score; /* LRU score of how often queues are - empty on refill. */ + +#define WT_EVICT_SCORE_BUMP 10 +#define WT_EVICT_SCORE_CUTOFF 10 +#define WT_EVICT_SCORE_MAX 100 + uint32_t evict_aggressive_score;/* Score of how aggressive eviction + should be about selecting eviction + candidates. If eviction is + struggling to make progress, this + score rises (up to a maximum of + 100), at which point the cache is + "stuck" and transaction will be + rolled back. */ + uint32_t evict_empty_score; /* Score of how often LRU queues are + empty on refill. This score varies + between 0 (if the queue hasn't been + empty for a long time) and 100 (if + the queue has been empty the last 10 + times we filled up. */ /* * Cache pool information. @@ -139,30 +169,19 @@ struct __wt_cache { uint64_t cp_saved_read; /* Read count at last review */ /* - * Work state. - */ -#define WT_EVICT_STATE_AGGRESSIVE 0x01 /* Eviction isn't making progress: - try harder */ -#define WT_EVICT_STATE_CLEAN 0x02 /* Evict clean pages */ -#define WT_EVICT_STATE_CLEAN_HARD 0x04 /* Clean % blocking app threads */ -#define WT_EVICT_STATE_DIRTY 0x08 /* Evict dirty pages */ -#define WT_EVICT_STATE_DIRTY_HARD 0x10 /* Dirty % blocking app threads */ -#define WT_EVICT_STATE_SCRUB 0x20 /* Scrub dirty pages pages */ -#define WT_EVICT_STATE_URGENT 0x40 /* Pages are in the urgent queue */ -#define WT_EVICT_STATE_ALL (WT_EVICT_STATE_CLEAN | WT_EVICT_STATE_DIRTY) - uint32_t state; - /* - * Pass interrupt counter. - */ - volatile uint32_t pass_intr; /* Interrupt eviction pass. */ - - /* * Flags. */ -#define WT_CACHE_POOL_MANAGER 0x01 /* The active cache pool manager */ -#define WT_CACHE_POOL_RUN 0x02 /* Cache pool thread running */ -#define WT_CACHE_STUCK 0x04 /* Eviction server is stuck */ -#define WT_CACHE_WALK_REVERSE 0x08 /* Scan backwards for candidates */ +#define WT_CACHE_EVICT_CLEAN 0x001 /* Evict clean pages */ +#define WT_CACHE_EVICT_CLEAN_HARD 0x002 /* Clean % blocking app threads */ +#define WT_CACHE_EVICT_DIRTY 0x004 /* Evict dirty pages */ +#define WT_CACHE_EVICT_DIRTY_HARD 0x008 /* Dirty % blocking app threads */ +#define WT_CACHE_EVICT_SCRUB 0x010 /* Scrub dirty pages pages */ +#define WT_CACHE_EVICT_URGENT 0x020 /* Pages are in the urgent queue */ +#define WT_CACHE_EVICT_ALL (WT_CACHE_EVICT_CLEAN | WT_CACHE_EVICT_DIRTY) +#define WT_CACHE_EVICT_MASK 0x0FF +#define WT_CACHE_POOL_MANAGER 0x100 /* The active cache pool manager */ +#define WT_CACHE_POOL_RUN 0x200 /* Cache pool thread running */ +#define WT_CACHE_WALK_REVERSE 0x400 /* Scan backwards for candidates */ uint32_t flags; }; diff --git a/src/third_party/wiredtiger/src/include/cache.i b/src/third_party/wiredtiger/src/include/cache.i index 155b1a7ab3d..b5605769f1a 100644 --- a/src/third_party/wiredtiger/src/include/cache.i +++ b/src/third_party/wiredtiger/src/include/cache.i @@ -7,6 +7,17 @@ */ /* + * __wt_cache_aggressive -- + * Indicate if the cache is operating in aggressive mode. + */ +static inline bool +__wt_cache_aggressive(WT_SESSION_IMPL *session) +{ + return (S2C(session)->cache->evict_aggressive_score >= + WT_EVICT_SCORE_CUTOFF); +} + +/* * __wt_cache_read_gen -- * Get the current read generation number. */ @@ -68,6 +79,21 @@ __wt_cache_read_gen_new(WT_SESSION_IMPL *session, WT_PAGE *page) } /* + * __wt_cache_stuck -- + * Indicate if the cache is stuck (i.e., not making progress). + */ +static inline bool +__wt_cache_stuck(WT_SESSION_IMPL *session) +{ + WT_CACHE *cache; + + cache = S2C(session)->cache; + return (cache->evict_aggressive_score == WT_EVICT_SCORE_MAX && + F_ISSET(cache, + WT_CACHE_EVICT_CLEAN_HARD | WT_CACHE_EVICT_DIRTY_HARD)); +} + +/* * __wt_page_evict_soon -- * Set a page to be evicted as soon as possible. */ @@ -195,11 +221,12 @@ __wt_session_can_wait(WT_SESSION_IMPL *session) * percentage as a side-effect. */ static inline bool -__wt_eviction_needed(WT_SESSION_IMPL *session, u_int *pct_fullp) +__wt_eviction_needed(WT_SESSION_IMPL *session, bool busy, u_int *pct_fullp) { WT_CONNECTION_IMPL *conn; WT_CACHE *cache; - uint64_t bytes_inuse, bytes_max; + double dirty_trigger; + uint64_t bytes_inuse, bytes_max, dirty_inuse; u_int pct_dirty, pct_full; conn = S2C(session); @@ -216,24 +243,36 @@ __wt_eviction_needed(WT_SESSION_IMPL *session, u_int *pct_fullp) * Avoid division by zero if the cache size has not yet been set in a * shared cache. */ - bytes_inuse = __wt_cache_bytes_inuse(cache); bytes_max = conn->cache_size + 1; + bytes_inuse = __wt_cache_bytes_inuse(cache); + dirty_inuse = __wt_cache_dirty_leaf_inuse(cache); /* * Calculate the cache full percentage; anything over the trigger means * we involve the application thread. */ - pct_full = (u_int)((100 * bytes_inuse) / bytes_max); - pct_dirty = - (u_int)((100 * __wt_cache_dirty_leaf_inuse(cache)) / bytes_max); + if (pct_fullp != NULL) { + pct_full = (u_int)((100 * bytes_inuse) / bytes_max); + pct_dirty = (u_int)((100 * dirty_inuse) / bytes_max); - if (pct_fullp != NULL) *pct_fullp = (u_int)WT_MAX(0, 100 - WT_MIN( (int)cache->eviction_trigger - (int)pct_full, (int)cache->eviction_dirty_trigger - (int)pct_dirty)); + } - return (pct_full >= cache->eviction_trigger || - pct_dirty >= cache->eviction_dirty_trigger); + /* + * Only check the dirty trigger when the session is not busy. + * + * In other words, once we are pinning resources, try to finish the + * operation as quickly as possible without exceeding the cache size. + * The next transaction in this session will not be able to start until + * the cache is under the limit. + */ + if ((dirty_trigger = cache->eviction_scrub_limit) < 1.0) + dirty_trigger = (double)cache->eviction_dirty_trigger; + return (bytes_inuse > (cache->eviction_trigger * bytes_max) / 100 || + (!busy && + dirty_inuse > (uint64_t)(dirty_trigger * bytes_max) / 100)); } /* @@ -260,12 +299,28 @@ static inline int __wt_cache_eviction_check(WT_SESSION_IMPL *session, bool busy, bool *didworkp) { WT_BTREE *btree; + WT_TXN_GLOBAL *txn_global; + WT_TXN_STATE *txn_state; u_int pct_full; if (didworkp != NULL) *didworkp = false; /* + * If the current transaction is keeping the oldest ID pinned, it is in + * the middle of an operation. This may prevent the oldest ID from + * moving forward, leading to deadlock, so only evict what we can. + * Otherwise, we are at a transaction boundary and we can work harder + * to make sure there is free space in the cache. + */ + txn_global = &S2C(session)->txn_global; + txn_state = WT_SESSION_TXN_STATE(session); + busy = busy || txn_state->id != WT_TXN_NONE || + session->nhazard > 0 || + (txn_state->snap_min != WT_TXN_NONE && + txn_global->current != txn_global->oldest_id); + + /* * LSM sets the no-cache-check flag when holding the LSM tree lock, in * that case, or when holding the schema or handle list locks (which * block eviction), we don't want to highjack the thread for eviction. @@ -287,7 +342,7 @@ __wt_cache_eviction_check(WT_SESSION_IMPL *session, bool busy, bool *didworkp) return (0); /* Check if eviction is needed. */ - if (!__wt_eviction_needed(session, &pct_full)) + if (!__wt_eviction_needed(session, busy, &pct_full)) return (0); /* diff --git a/src/third_party/wiredtiger/src/include/connection.h b/src/third_party/wiredtiger/src/include/connection.h index bd5726a06c3..77dbc87b114 100644 --- a/src/third_party/wiredtiger/src/include/connection.h +++ b/src/third_party/wiredtiger/src/include/connection.h @@ -25,6 +25,10 @@ struct __wt_process { /* Locked: connection queue */ TAILQ_HEAD(__wt_connection_impl_qh, __wt_connection_impl) connqh; WT_CACHE_POOL *cache_pool; + + /* Checksum function */ +#define __wt_checksum(chunk, len) __wt_process.checksum(chunk, len) + uint32_t (*checksum)(const void *, size_t); }; extern WT_PROCESS __wt_process; @@ -273,7 +277,7 @@ struct __wt_connection_impl { WT_CONDVAR *ckpt_cond; /* Checkpoint wait mutex */ #define WT_CKPT_LOGSIZE(conn) ((conn)->ckpt_logsize != 0) wt_off_t ckpt_logsize; /* Checkpoint log size period */ - uint32_t ckpt_signalled;/* Checkpoint signalled */ + bool ckpt_signalled;/* Checkpoint signalled */ uint64_t ckpt_usecs; /* Checkpoint timer */ uint64_t ckpt_time_max; /* Checkpoint time min/max */ diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h index 2992a97b727..5444b2e9f14 100644 --- a/src/third_party/wiredtiger/src/include/extern.h +++ b/src/third_party/wiredtiger/src/include/extern.h @@ -9,8 +9,8 @@ extern int __wt_async_new_op(WT_SESSION_IMPL *session, const char *uri, const ch extern int __wt_async_op_enqueue(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_async_op_init(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern WT_THREAD_RET __wt_async_worker(void *arg); -extern int __wt_block_addr_to_buffer(WT_BLOCK *block, uint8_t **pp, wt_off_t offset, uint32_t size, uint32_t cksum) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_block_buffer_to_addr(WT_BLOCK *block, const uint8_t *p, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_block_addr_to_buffer(WT_BLOCK *block, uint8_t **pp, wt_off_t offset, uint32_t size, uint32_t checksum) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_block_buffer_to_addr(WT_BLOCK *block, const uint8_t *p, wt_off_t *offsetp, uint32_t *sizep, uint32_t *checksump) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_addr_invalid(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool live) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_addr_string(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, const uint8_t *addr, size_t addr_size) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_buffer_to_ckpt(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *p, WT_BLOCK_CKPT *ci) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -20,7 +20,7 @@ extern int __wt_block_ckpt_init( WT_SESSION_IMPL *session, WT_BLOCK_CKPT *ci, co extern int __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, uint8_t *root_addr, size_t *root_addr_sizep, bool checkpoint) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_checkpoint_unload( WT_SESSION_IMPL *session, WT_BLOCK *block, bool checkpoint) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_block_ckpt_destroy(WT_SESSION_IMPL *session, WT_BLOCK_CKPT *ci); -extern int __wt_block_checkpoint(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_cksum) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_block_checkpoint(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_checksum) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_checkpoint_resolve(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_compact_start(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -44,6 +44,7 @@ extern void __wt_block_extlist_free(WT_SESSION_IMPL *session, WT_EXTLIST *el); extern int __wt_block_map(WT_SESSION_IMPL *session, WT_BLOCK *block, void *mapped_regionp, size_t *lengthp, void *mapped_cookiep) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_unmap(WT_SESSION_IMPL *session, WT_BLOCK *block, void *mapped_region, size_t length, void *mapped_cookie) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_manager_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], bool forced_salvage, bool readonly, uint32_t allocsize, WT_BM **bmp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_block_panic(WT_SESSION_IMPL *session, int error, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_manager_drop( WT_SESSION_IMPL *session, const char *filename, bool durable) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_manager_create( WT_SESSION_IMPL *session, const char *filename, uint32_t allocsize) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_block_configure_first_fit(WT_BLOCK *block, bool on); @@ -56,7 +57,7 @@ extern int __wt_block_manager_named_size( WT_SESSION_IMPL *session, const char * extern int __wt_bm_preload( WT_BM *bm, WT_SESSION_IMPL *session, const uint8_t *addr, size_t addr_size) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_bm_read(WT_BM *bm, WT_SESSION_IMPL *session, WT_ITEM *buf, const uint8_t *addr, size_t addr_size) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_read_off_blind( WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, wt_off_t offset) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_block_read_off(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, wt_off_t offset, uint32_t size, uint32_t cksum) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_block_read_off(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, wt_off_t offset, uint32_t size, uint32_t checksum) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_ext_alloc(WT_SESSION_IMPL *session, WT_EXT **extp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_block_ext_free(WT_SESSION_IMPL *session, WT_EXT *ext); extern int __wt_block_size_alloc(WT_SESSION_IMPL *session, WT_SIZE **szp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -76,13 +77,13 @@ extern int __wt_block_verify_addr(WT_SESSION_IMPL *session, WT_BLOCK *block, con extern int __wt_block_truncate(WT_SESSION_IMPL *session, WT_BLOCK *block, wt_off_t len) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_discard(WT_SESSION_IMPL *session, WT_BLOCK *block, size_t added_size) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_block_write_size(WT_SESSION_IMPL *session, WT_BLOCK *block, size_t *sizep) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_block_write(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, bool data_cksum, bool checkpoint_io) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump, bool data_cksum, bool checkpoint_io, bool caller_locked) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_block_write(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, bool data_checksum, bool checkpoint_io) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, wt_off_t *offsetp, uint32_t *sizep, uint32_t *checksump, bool data_checksum, bool checkpoint_io, bool caller_locked) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_bloom_create( WT_SESSION_IMPL *session, const char *uri, const char *config, uint64_t count, uint32_t factor, uint32_t k, WT_BLOOM **bloomp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_bloom_open(WT_SESSION_IMPL *session, const char *uri, uint32_t factor, uint32_t k, WT_CURSOR *owner, WT_BLOOM **bloomp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_bloom_insert(WT_BLOOM *bloom, WT_ITEM *key) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_bloom_insert(WT_BLOOM *bloom, WT_ITEM *key); extern int __wt_bloom_finalize(WT_BLOOM *bloom) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_bloom_hash(WT_BLOOM *bloom, WT_ITEM *key, WT_BLOOM_HASH *bhash) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_bloom_hash(WT_BLOOM *bloom, WT_ITEM *key, WT_BLOOM_HASH *bhash); extern int __wt_bloom_hash_get(WT_BLOOM *bloom, WT_BLOOM_HASH *bhash) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_bloom_get(WT_BLOOM *bloom, WT_ITEM *key) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_bloom_inmem_get(WT_BLOOM *bloom, WT_ITEM *key) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -115,7 +116,7 @@ extern int __wt_debug_set_verbose(WT_SESSION_IMPL *session, const char *v) WT_GC extern int __wt_debug_addr_print( WT_SESSION_IMPL *session, const uint8_t *addr, size_t addr_size) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_debug_addr(WT_SESSION_IMPL *session, const uint8_t *addr, size_t addr_size, const char *ofile) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_debug_offset_blind( WT_SESSION_IMPL *session, wt_off_t offset, const char *ofile) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_debug_offset(WT_SESSION_IMPL *session, wt_off_t offset, uint32_t size, uint32_t cksum, const char *ofile) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_debug_offset(WT_SESSION_IMPL *session, wt_off_t offset, uint32_t size, uint32_t checksum, const char *ofile) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_debug_disk( WT_SESSION_IMPL *session, const WT_PAGE_HEADER *dsk, const char *ofile) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_debug_tree_shape( WT_SESSION_IMPL *session, WT_PAGE *page, const char *ofile) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_debug_tree_all( WT_SESSION_IMPL *session, WT_BTREE *btree, WT_REF *ref, const char *ofile) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -199,14 +200,14 @@ extern int __wt_las_destroy(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE extern void __wt_las_set_written(WT_SESSION_IMPL *session); extern bool __wt_las_is_written(WT_SESSION_IMPL *session); extern int __wt_las_cursor_open(WT_SESSION_IMPL *session, WT_CURSOR **cursorp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_las_cursor( WT_SESSION_IMPL *session, WT_CURSOR **cursorp, uint32_t *session_flags) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_las_cursor( WT_SESSION_IMPL *session, WT_CURSOR **cursorp, uint32_t *session_flags); extern int __wt_las_cursor_close( WT_SESSION_IMPL *session, WT_CURSOR **cursorp, uint32_t session_flags) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_las_sweep(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern uint32_t __wt_cksum(const void *chunk, size_t len); -extern void __wt_cksum_init(void); -extern int __wt_config_initn( WT_SESSION_IMPL *session, WT_CONFIG *conf, const char *str, size_t len) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_config_init(WT_SESSION_IMPL *session, WT_CONFIG *conf, const char *str) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_config_subinit( WT_SESSION_IMPL *session, WT_CONFIG *conf, WT_CONFIG_ITEM *item) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern uint32_t __wt_checksum_sw(const void *chunk, size_t len); +extern void __wt_checksum_init(void); +extern void __wt_config_initn( WT_SESSION_IMPL *session, WT_CONFIG *conf, const char *str, size_t len); +extern void __wt_config_init(WT_SESSION_IMPL *session, WT_CONFIG *conf, const char *str); +extern void __wt_config_subinit( WT_SESSION_IMPL *session, WT_CONFIG *conf, WT_CONFIG_ITEM *item); extern int __wt_config_next(WT_CONFIG *conf, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_config_get(WT_SESSION_IMPL *session, const char **cfg_arg, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_config_gets(WT_SESSION_IMPL *session, const char **cfg, const char *key, WT_CONFIG_ITEM *value) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -249,7 +250,7 @@ extern int __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) WT_GCC_FUNC_DE extern WT_THREAD_RET __wt_cache_pool_server(void *arg); extern int __wt_checkpoint_server_create(WT_SESSION_IMPL *session, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_checkpoint_server_destroy(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_checkpoint_signal(WT_SESSION_IMPL *session, wt_off_t logsize) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_checkpoint_signal(WT_SESSION_IMPL *session, wt_off_t logsize); extern int __wt_conn_dhandle_find( WT_SESSION_IMPL *session, const char *uri, const char *checkpoint) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, bool final, bool force) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_conn_btree_open( WT_SESSION_IMPL *session, const char *cfg[], uint32_t flags) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -290,7 +291,7 @@ extern int __wt_curjoin_join(WT_SESSION_IMPL *session, WT_CURSOR_JOIN *cjoin, WT extern int __wt_json_alloc_unpack(WT_SESSION_IMPL *session, const void *buffer, size_t size, const char *fmt, WT_CURSOR_JSON *json, bool iskey, va_list ap) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_json_close(WT_SESSION_IMPL *session, WT_CURSOR *cursor); extern size_t __wt_json_unpack_char(u_char ch, u_char *buf, size_t bufsz, bool force_unicode); -extern int __wt_json_column_init(WT_CURSOR *cursor, const char *keyformat, const WT_CONFIG_ITEM *idxconf, const WT_CONFIG_ITEM *colconf) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_json_column_init(WT_CURSOR *cursor, const char *keyformat, const WT_CONFIG_ITEM *idxconf, const WT_CONFIG_ITEM *colconf); extern int __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, const char **tokstart, size_t *toklen) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern const char *__wt_json_tokname(int toktype); extern int __wt_json_to_item(WT_SESSION_IMPL *session, const char *jstr, const char *format, WT_CURSOR_JSON *json, bool iskey, WT_ITEM *item) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -412,7 +413,7 @@ extern int __wt_lsm_manager_reconfig(WT_SESSION_IMPL *session, const char **cfg) extern int __wt_lsm_manager_start(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_lsm_manager_free_work_unit( WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT *entry); extern int __wt_lsm_manager_destroy(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_lsm_manager_clear_tree( WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_lsm_manager_clear_tree(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree); extern int __wt_lsm_manager_pop_entry( WT_SESSION_IMPL *session, uint32_t type, WT_LSM_WORK_UNIT **entryp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_lsm_manager_push_entry(WT_SESSION_IMPL *session, uint32_t type, uint32_t flags, WT_LSM_TREE *lsm_tree) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_lsm_merge_update_tree(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int start_chunk, u_int nchunks, WT_LSM_CHUNK *chunk) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -471,7 +472,7 @@ extern int __wt_metadata_search(WT_SESSION_IMPL *session, const char *key, char extern void __wt_meta_track_discard(WT_SESSION_IMPL *session); extern int __wt_meta_track_on(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_meta_track_off(WT_SESSION_IMPL *session, bool need_sync, bool unroll) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_meta_track_sub_on(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_meta_track_sub_on(WT_SESSION_IMPL *session); extern int __wt_meta_track_sub_off(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_meta_track_checkpoint(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_meta_track_insert(WT_SESSION_IMPL *session, const char *key) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -505,7 +506,7 @@ extern int __wt_close(WT_SESSION_IMPL *session, WT_FH **fhp) WT_GCC_FUNC_DECL_AT extern int __wt_close_connection_close(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_os_inmemory(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_fopen(WT_SESSION_IMPL *session, const char *name, uint32_t open_flags, uint32_t flags, WT_FSTREAM **fstrp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_os_stdio(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_os_stdio(WT_SESSION_IMPL *session); extern int __wt_getopt( const char *progname, int nargc, char *const *nargv, const char *ostr) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern uint64_t __wt_strtouq(const char *nptr, char **endptr, int base); extern int __wt_ext_struct_pack(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, void *buffer, size_t size, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -614,7 +615,7 @@ extern int __wt_decrypt(WT_SESSION_IMPL *session, WT_ENCRYPTOR *encryptor, size_ extern int __wt_encrypt(WT_SESSION_IMPL *session, WT_KEYED_ENCRYPTOR *kencryptor, size_t skip, WT_ITEM *in, WT_ITEM *out) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_encrypt_size(WT_SESSION_IMPL *session, WT_KEYED_ENCRYPTOR *kencryptor, size_t incoming_size, size_t *sizep); extern void __wt_event_handler_set(WT_SESSION_IMPL *session, WT_EVENT_HANDLER *handler); -extern int __wt_eventv(WT_SESSION_IMPL *session, bool msg_event, int error, const char *file_name, int line_number, const char *fmt, va_list ap) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_eventv(WT_SESSION_IMPL *session, bool msg_event, int error, const char *file_name, int line_number, const char *fmt, va_list ap) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_err(WT_SESSION_IMPL *session, int error, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))); extern void __wt_errx(WT_SESSION_IMPL *session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 2, 3))); extern int __wt_ext_err_printf( WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -658,7 +659,7 @@ extern int __wt_nhex_to_raw( WT_SESSION_IMPL *session, const char *from, size_t extern int __wt_esc_hex_to_raw(WT_SESSION_IMPL *session, const char *from, WT_ITEM *to) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_huffman_open(WT_SESSION_IMPL *session, void *symbol_frequency_array, u_int symcnt, u_int numbytes, void *retp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_huffman_close(WT_SESSION_IMPL *session, void *huffman_arg); -extern int __wt_print_huffman_code(void *huffman_arg, uint16_t symbol) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_print_huffman_code(void *huffman_arg, uint16_t symbol); extern int __wt_huffman_encode(WT_SESSION_IMPL *session, void *huffman_arg, const uint8_t *from_arg, size_t from_len, WT_ITEM *to_buf) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_huffman_decode(WT_SESSION_IMPL *session, void *huffman_arg, const uint8_t *from_arg, size_t from_len, WT_ITEM *to_buf) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_rwlock_alloc( WT_SESSION_IMPL *session, WT_RWLOCK **rwlockp, const char *name) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -713,7 +714,7 @@ extern void __wt_stat_join_aggregate( WT_JOIN_STATS **from, WT_JOIN_STATS *to); extern WT_THREAD_RET __wt_thread_run(void *arg); extern int __wt_thread_group_resize( WT_SESSION_IMPL *session, WT_THREAD_GROUP *group, uint32_t new_min, uint32_t new_max, uint32_t flags) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_thread_group_create( WT_SESSION_IMPL *session, WT_THREAD_GROUP *group, const char *name, uint32_t min, uint32_t max, uint32_t flags, int (*run_func)(WT_SESSION_IMPL *session, WT_THREAD *context)) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_thread_group_destroy( WT_SESSION_IMPL *session, WT_THREAD_GROUP *group) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern int __wt_thread_group_destroy(WT_SESSION_IMPL *session, WT_THREAD_GROUP *group) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_thread_group_start_one( WT_SESSION_IMPL *session, WT_THREAD_GROUP *group, bool wait) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern void __wt_txn_release_snapshot(WT_SESSION_IMPL *session); extern int __wt_txn_get_snapshot(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); @@ -743,11 +744,11 @@ extern int __wt_txn_log_commit(WT_SESSION_IMPL *session, const char *cfg[]) WT_G extern int __wt_txn_checkpoint_logread( WT_SESSION_IMPL *session, const uint8_t **pp, const uint8_t *end, WT_LSN *ckpt_lsn) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_checkpoint_log( WT_SESSION_IMPL *session, bool full, uint32_t flags, WT_LSN *lsnp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_truncate_log( WT_SESSION_IMPL *session, WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_txn_truncate_end(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_txn_truncate_end(WT_SESSION_IMPL *session); extern int __wt_txn_printlog(WT_SESSION *wt_session, uint32_t flags) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_named_snapshot_begin(WT_SESSION_IMPL *session, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_named_snapshot_drop(WT_SESSION_IMPL *session, const char *cfg[]) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_named_snapshot_get(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *nameval) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, const char *cfg[], bool *has_create, bool *has_drops) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern int __wt_txn_named_snapshot_destroy(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); +extern void __wt_txn_named_snapshot_destroy(WT_SESSION_IMPL *session); extern int __wt_txn_recover(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); diff --git a/src/third_party/wiredtiger/src/include/misc.i b/src/third_party/wiredtiger/src/include/misc.i index e1b882388e7..f267c7afc91 100644 --- a/src/third_party/wiredtiger/src/include/misc.i +++ b/src/third_party/wiredtiger/src/include/misc.i @@ -48,11 +48,20 @@ __wt_seconds(WT_SESSION_IMPL *session, time_t *timep) /* * __wt_verbose -- * Verbose message. + * + * Inline functions are not parsed for external prototypes, so in cases where we + * want GCC attributes attached to the functions, we have to do so explicitly. + */ +static inline void +__wt_verbose(WT_SESSION_IMPL *session, int flag, const char *fmt, ...) +WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))); + +/* + * __wt_verbose -- + * Verbose message. */ static inline void __wt_verbose(WT_SESSION_IMPL *session, int flag, const char *fmt, ...) - WT_GCC_FUNC_ATTRIBUTE((format (printf, 2, 3))) - WT_GCC_FUNC_ATTRIBUTE((cold)) { #ifdef HAVE_VERBOSE va_list ap; diff --git a/src/third_party/wiredtiger/src/include/os_fhandle.i b/src/third_party/wiredtiger/src/include/os_fhandle.i index 78d25969508..a9150279a85 100644 --- a/src/third_party/wiredtiger/src/include/os_fhandle.i +++ b/src/third_party/wiredtiger/src/include/os_fhandle.i @@ -51,7 +51,7 @@ __wt_fextend(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset) WT_ASSERT(session, !F_ISSET(S2C(session), WT_CONN_IN_MEMORY)); __wt_verbose(session, WT_VERB_HANDLEOPS, - "%s: handle-extend: %" PRIuMAX " at %" PRIuMAX, + "%s: handle-extend: to %" PRIuMAX, fh->handle->name, (uintmax_t)offset); /* @@ -134,7 +134,7 @@ __wt_ftruncate(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset) WT_ASSERT(session, !F_ISSET(S2C(session), WT_CONN_READONLY)); __wt_verbose(session, WT_VERB_HANDLEOPS, - "%s: handle-truncate: %" PRIuMAX " at %" PRIuMAX, + "%s: handle-truncate: to %" PRIuMAX, fh->handle->name, (uintmax_t)offset); /* diff --git a/src/third_party/wiredtiger/src/include/os_fs.i b/src/third_party/wiredtiger/src/include/os_fs.i index 3012422f33a..4cf1128280e 100644 --- a/src/third_party/wiredtiger/src/include/os_fs.i +++ b/src/third_party/wiredtiger/src/include/os_fs.i @@ -23,7 +23,7 @@ __wt_fs_directory_list(WT_SESSION_IMPL *session, *countp = 0; __wt_verbose(session, WT_VERB_FILEOPS, - "%s: directory-list: %s prefix %s", + "%s: directory-list: prefix %s", dir, prefix == NULL ? "all" : prefix); WT_RET(__wt_filename(session, dir, &path)); diff --git a/src/third_party/wiredtiger/src/include/os_fstream.i b/src/third_party/wiredtiger/src/include/os_fstream.i index a0ac4ef8b6a..98d0622f346 100644 --- a/src/third_party/wiredtiger/src/include/os_fstream.i +++ b/src/third_party/wiredtiger/src/include/os_fstream.i @@ -49,19 +49,26 @@ static inline int __wt_vfprintf( WT_SESSION_IMPL *session, WT_FSTREAM *fstr, const char *fmt, va_list ap) { - __wt_verbose( - session, WT_VERB_HANDLEOPS, "%s: handle-printf", fstr->name); - return (fstr->fstr_printf(session, fstr, fmt, ap)); } /* * __wt_fprintf -- * ANSI C fprintf. + * + * Inline functions are not parsed for external prototypes, so in cases where we + * want GCC attributes attached to the functions, we have to do so explicitly. + */ +static inline int +__wt_fprintf(WT_SESSION_IMPL *session, WT_FSTREAM *fstr, const char *fmt, ...) + WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))); + +/* + * __wt_fprintf -- + * ANSI C fprintf. */ static inline int __wt_fprintf(WT_SESSION_IMPL *session, WT_FSTREAM *fstr, const char *fmt, ...) - WT_GCC_FUNC_ATTRIBUTE((format (printf, 3, 4))) { WT_DECL_RET; va_list ap; diff --git a/src/third_party/wiredtiger/src/include/packing.i b/src/third_party/wiredtiger/src/include/packing.i index d662c60d221..17ca261bcfc 100644 --- a/src/third_party/wiredtiger/src/include/packing.i +++ b/src/third_party/wiredtiger/src/include/packing.i @@ -81,7 +81,7 @@ __pack_init(WT_SESSION_IMPL *session, WT_PACK *pack, const char *fmt) * __pack_name_init -- * Initialize the name of a pack iterator. */ -static inline int +static inline void __pack_name_init(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *names, bool iskey, WT_PACK_NAME *pn) { @@ -89,11 +89,9 @@ __pack_name_init(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *names, pn->iskey = iskey; if (names->str != NULL) - WT_RET(__wt_config_subinit(session, &pn->config, names)); + __wt_config_subinit(session, &pn->config, names); else pn->genname = 1; - - return (0); } /* diff --git a/src/third_party/wiredtiger/src/include/stat.h b/src/third_party/wiredtiger/src/include/stat.h index e0d0a6eb780..b61c568783b 100644 --- a/src/third_party/wiredtiger/src/include/stat.h +++ b/src/third_party/wiredtiger/src/include/stat.h @@ -289,7 +289,6 @@ struct __wt_connection_stats { int64_t cache_eviction_queue_empty; int64_t cache_eviction_queue_not_empty; int64_t cache_eviction_server_evicting; - int64_t cache_eviction_server_toobig; int64_t cache_eviction_server_slept; int64_t cache_eviction_slow; int64_t cache_eviction_state; diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in index 10141cd34c1..d4d52545bfc 100644 --- a/src/third_party/wiredtiger/src/include/wiredtiger.in +++ b/src/third_party/wiredtiger/src/include/wiredtiger.in @@ -1808,15 +1808,21 @@ struct __wt_connection { * number of threads currently running will vary depending on the * current eviction load., an integer between 1 and 20; default \c 1.} * @config{ ),,} + * @config{eviction_checkpoint_target, perform eviction at the beginning + * of checkpoints to bring the dirty content in cache to this level\, + * expressed as a percentage of the total cache size. Ignored if set to + * zero or \c in_memory is \c true., an integer between 0 and 99; + * default \c 5.} * @config{eviction_dirty_target, perform eviction in worker threads * when the cache contains at least this much dirty content\, expressed - * as a percentage of the total cache size., an integer between 1 and - * 99; default \c 5.} + * as a percentage of the total cache size. Ignored if \c in_memory is + * \c true., an integer between 1 and 99; default \c 5.} * @config{eviction_dirty_trigger, trigger application threads to * perform eviction when the cache contains at least this much dirty * content\, expressed as a percentage of the total cache size. This - * setting only alters behavior if it is lower than eviction_trigger., - * an integer between 1 and 99; default \c 20.} + * setting only alters behavior if it is lower than eviction_trigger. + * Ignored if \c in_memory is \c true., an integer between 1 and 99; + * default \c 20.} * @config{eviction_target, perform eviction in worker threads when the * cache contains at least this much content\, expressed as a percentage * of the total cache size. Must be less than \c eviction_trigger., an @@ -2269,14 +2275,19 @@ struct __wt_connection { * current eviction load., an integer between 1 and 20; default \c 1.} * @config{ * ),,} + * @config{eviction_checkpoint_target, perform eviction at the beginning of + * checkpoints to bring the dirty content in cache to this level\, expressed as + * a percentage of the total cache size. Ignored if set to zero or \c in_memory + * is \c true., an integer between 0 and 99; default \c 5.} * @config{eviction_dirty_target, perform eviction in worker threads when the * cache contains at least this much dirty content\, expressed as a percentage - * of the total cache size., an integer between 1 and 99; default \c 5.} + * of the total cache size. Ignored if \c in_memory is \c true., an integer + * between 1 and 99; default \c 5.} * @config{eviction_dirty_trigger, trigger application threads to perform * eviction when the cache contains at least this much dirty content\, expressed * as a percentage of the total cache size. This setting only alters behavior - * if it is lower than eviction_trigger., an integer between 1 and 99; default - * \c 20.} + * if it is lower than eviction_trigger. Ignored if \c in_memory is \c true., + * an integer between 1 and 99; default \c 20.} * @config{eviction_target, perform eviction in worker threads when the cache * contains at least this much content\, expressed as a percentage of the total * cache size. Must be less than \c eviction_trigger., an integer between 10 @@ -4289,348 +4300,354 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); #define WT_STAT_CONN_CACHE_EVICTION_QUEUE_NOT_EMPTY 1042 /*! cache: eviction server evicting pages */ #define WT_STAT_CONN_CACHE_EVICTION_SERVER_EVICTING 1043 -/*! cache: eviction server skipped very large page */ -#define WT_STAT_CONN_CACHE_EVICTION_SERVER_TOOBIG 1044 -/*! cache: eviction server slept, because we did not make progress with - * eviction */ -#define WT_STAT_CONN_CACHE_EVICTION_SERVER_SLEPT 1045 +/*! + * cache: eviction server slept, because we did not make progress with + * eviction + */ +#define WT_STAT_CONN_CACHE_EVICTION_SERVER_SLEPT 1044 /*! cache: eviction server unable to reach eviction goal */ -#define WT_STAT_CONN_CACHE_EVICTION_SLOW 1046 +#define WT_STAT_CONN_CACHE_EVICTION_SLOW 1045 /*! cache: eviction state */ -#define WT_STAT_CONN_CACHE_EVICTION_STATE 1047 +#define WT_STAT_CONN_CACHE_EVICTION_STATE 1046 /*! cache: eviction worker thread evicting pages */ -#define WT_STAT_CONN_CACHE_EVICTION_WORKER_EVICTING 1048 +#define WT_STAT_CONN_CACHE_EVICTION_WORKER_EVICTING 1047 /*! cache: failed eviction of pages that exceeded the in-memory maximum */ -#define WT_STAT_CONN_CACHE_EVICTION_FORCE_FAIL 1049 +#define WT_STAT_CONN_CACHE_EVICTION_FORCE_FAIL 1048 /*! cache: files with active eviction walks */ -#define WT_STAT_CONN_CACHE_EVICTION_WALKS_ACTIVE 1050 +#define WT_STAT_CONN_CACHE_EVICTION_WALKS_ACTIVE 1049 /*! cache: files with new eviction walks started */ -#define WT_STAT_CONN_CACHE_EVICTION_WALKS_STARTED 1051 +#define WT_STAT_CONN_CACHE_EVICTION_WALKS_STARTED 1050 /*! cache: hazard pointer blocked page eviction */ -#define WT_STAT_CONN_CACHE_EVICTION_HAZARD 1052 +#define WT_STAT_CONN_CACHE_EVICTION_HAZARD 1051 /*! cache: hazard pointer check calls */ -#define WT_STAT_CONN_CACHE_HAZARD_CHECKS 1053 +#define WT_STAT_CONN_CACHE_HAZARD_CHECKS 1052 /*! cache: hazard pointer check entries walked */ -#define WT_STAT_CONN_CACHE_HAZARD_WALKS 1054 +#define WT_STAT_CONN_CACHE_HAZARD_WALKS 1053 /*! cache: hazard pointer maximum array length */ -#define WT_STAT_CONN_CACHE_HAZARD_MAX 1055 +#define WT_STAT_CONN_CACHE_HAZARD_MAX 1054 /*! cache: in-memory page passed criteria to be split */ -#define WT_STAT_CONN_CACHE_INMEM_SPLITTABLE 1056 +#define WT_STAT_CONN_CACHE_INMEM_SPLITTABLE 1055 /*! cache: in-memory page splits */ -#define WT_STAT_CONN_CACHE_INMEM_SPLIT 1057 +#define WT_STAT_CONN_CACHE_INMEM_SPLIT 1056 /*! cache: internal pages evicted */ -#define WT_STAT_CONN_CACHE_EVICTION_INTERNAL 1058 +#define WT_STAT_CONN_CACHE_EVICTION_INTERNAL 1057 /*! cache: internal pages split during eviction */ -#define WT_STAT_CONN_CACHE_EVICTION_SPLIT_INTERNAL 1059 +#define WT_STAT_CONN_CACHE_EVICTION_SPLIT_INTERNAL 1058 /*! cache: leaf pages split during eviction */ -#define WT_STAT_CONN_CACHE_EVICTION_SPLIT_LEAF 1060 +#define WT_STAT_CONN_CACHE_EVICTION_SPLIT_LEAF 1059 /*! cache: lookaside table insert calls */ -#define WT_STAT_CONN_CACHE_LOOKASIDE_INSERT 1061 +#define WT_STAT_CONN_CACHE_LOOKASIDE_INSERT 1060 /*! cache: lookaside table remove calls */ -#define WT_STAT_CONN_CACHE_LOOKASIDE_REMOVE 1062 +#define WT_STAT_CONN_CACHE_LOOKASIDE_REMOVE 1061 /*! cache: maximum bytes configured */ -#define WT_STAT_CONN_CACHE_BYTES_MAX 1063 +#define WT_STAT_CONN_CACHE_BYTES_MAX 1062 /*! cache: maximum page size at eviction */ -#define WT_STAT_CONN_CACHE_EVICTION_MAXIMUM_PAGE_SIZE 1064 +#define WT_STAT_CONN_CACHE_EVICTION_MAXIMUM_PAGE_SIZE 1063 /*! cache: modified pages evicted */ -#define WT_STAT_CONN_CACHE_EVICTION_DIRTY 1065 +#define WT_STAT_CONN_CACHE_EVICTION_DIRTY 1064 /*! cache: modified pages evicted by application threads */ -#define WT_STAT_CONN_CACHE_EVICTION_APP_DIRTY 1066 +#define WT_STAT_CONN_CACHE_EVICTION_APP_DIRTY 1065 /*! cache: overflow pages read into cache */ -#define WT_STAT_CONN_CACHE_READ_OVERFLOW 1067 +#define WT_STAT_CONN_CACHE_READ_OVERFLOW 1066 /*! cache: overflow values cached in memory */ -#define WT_STAT_CONN_CACHE_OVERFLOW_VALUE 1068 +#define WT_STAT_CONN_CACHE_OVERFLOW_VALUE 1067 /*! cache: page split during eviction deepened the tree */ -#define WT_STAT_CONN_CACHE_EVICTION_DEEPEN 1069 +#define WT_STAT_CONN_CACHE_EVICTION_DEEPEN 1068 /*! cache: page written requiring lookaside records */ -#define WT_STAT_CONN_CACHE_WRITE_LOOKASIDE 1070 +#define WT_STAT_CONN_CACHE_WRITE_LOOKASIDE 1069 /*! cache: pages currently held in the cache */ -#define WT_STAT_CONN_CACHE_PAGES_INUSE 1071 +#define WT_STAT_CONN_CACHE_PAGES_INUSE 1070 /*! cache: pages evicted because they exceeded the in-memory maximum */ -#define WT_STAT_CONN_CACHE_EVICTION_FORCE 1072 +#define WT_STAT_CONN_CACHE_EVICTION_FORCE 1071 /*! cache: pages evicted because they had chains of deleted items */ -#define WT_STAT_CONN_CACHE_EVICTION_FORCE_DELETE 1073 +#define WT_STAT_CONN_CACHE_EVICTION_FORCE_DELETE 1072 /*! cache: pages evicted by application threads */ -#define WT_STAT_CONN_CACHE_EVICTION_APP 1074 +#define WT_STAT_CONN_CACHE_EVICTION_APP 1073 /*! cache: pages queued for eviction */ -#define WT_STAT_CONN_CACHE_EVICTION_PAGES_QUEUED 1075 +#define WT_STAT_CONN_CACHE_EVICTION_PAGES_QUEUED 1074 /*! cache: pages queued for urgent eviction */ -#define WT_STAT_CONN_CACHE_EVICTION_PAGES_QUEUED_URGENT 1076 +#define WT_STAT_CONN_CACHE_EVICTION_PAGES_QUEUED_URGENT 1075 /*! cache: pages queued for urgent eviction during walk */ -#define WT_STAT_CONN_CACHE_EVICTION_PAGES_QUEUED_OLDEST 1077 +#define WT_STAT_CONN_CACHE_EVICTION_PAGES_QUEUED_OLDEST 1076 /*! cache: pages read into cache */ -#define WT_STAT_CONN_CACHE_READ 1078 +#define WT_STAT_CONN_CACHE_READ 1077 /*! cache: pages read into cache requiring lookaside entries */ -#define WT_STAT_CONN_CACHE_READ_LOOKASIDE 1079 +#define WT_STAT_CONN_CACHE_READ_LOOKASIDE 1078 /*! cache: pages requested from the cache */ -#define WT_STAT_CONN_CACHE_PAGES_REQUESTED 1080 +#define WT_STAT_CONN_CACHE_PAGES_REQUESTED 1079 /*! cache: pages seen by eviction walk */ -#define WT_STAT_CONN_CACHE_EVICTION_PAGES_SEEN 1081 +#define WT_STAT_CONN_CACHE_EVICTION_PAGES_SEEN 1080 /*! cache: pages selected for eviction unable to be evicted */ -#define WT_STAT_CONN_CACHE_EVICTION_FAIL 1082 +#define WT_STAT_CONN_CACHE_EVICTION_FAIL 1081 /*! cache: pages walked for eviction */ -#define WT_STAT_CONN_CACHE_EVICTION_WALK 1083 +#define WT_STAT_CONN_CACHE_EVICTION_WALK 1082 /*! cache: pages written from cache */ -#define WT_STAT_CONN_CACHE_WRITE 1084 +#define WT_STAT_CONN_CACHE_WRITE 1083 /*! cache: pages written requiring in-memory restoration */ -#define WT_STAT_CONN_CACHE_WRITE_RESTORE 1085 +#define WT_STAT_CONN_CACHE_WRITE_RESTORE 1084 /*! cache: percentage overhead */ -#define WT_STAT_CONN_CACHE_OVERHEAD 1086 +#define WT_STAT_CONN_CACHE_OVERHEAD 1085 /*! cache: tracked bytes belonging to internal pages in the cache */ -#define WT_STAT_CONN_CACHE_BYTES_INTERNAL 1087 +#define WT_STAT_CONN_CACHE_BYTES_INTERNAL 1086 /*! cache: tracked bytes belonging to leaf pages in the cache */ -#define WT_STAT_CONN_CACHE_BYTES_LEAF 1088 +#define WT_STAT_CONN_CACHE_BYTES_LEAF 1087 /*! cache: tracked dirty bytes in the cache */ -#define WT_STAT_CONN_CACHE_BYTES_DIRTY 1089 +#define WT_STAT_CONN_CACHE_BYTES_DIRTY 1088 /*! cache: tracked dirty pages in the cache */ -#define WT_STAT_CONN_CACHE_PAGES_DIRTY 1090 +#define WT_STAT_CONN_CACHE_PAGES_DIRTY 1089 /*! cache: unmodified pages evicted */ -#define WT_STAT_CONN_CACHE_EVICTION_CLEAN 1091 +#define WT_STAT_CONN_CACHE_EVICTION_CLEAN 1090 /*! connection: auto adjusting condition resets */ -#define WT_STAT_CONN_COND_AUTO_WAIT_RESET 1092 +#define WT_STAT_CONN_COND_AUTO_WAIT_RESET 1091 /*! connection: auto adjusting condition wait calls */ -#define WT_STAT_CONN_COND_AUTO_WAIT 1093 +#define WT_STAT_CONN_COND_AUTO_WAIT 1092 /*! connection: files currently open */ -#define WT_STAT_CONN_FILE_OPEN 1094 +#define WT_STAT_CONN_FILE_OPEN 1093 /*! connection: memory allocations */ -#define WT_STAT_CONN_MEMORY_ALLOCATION 1095 +#define WT_STAT_CONN_MEMORY_ALLOCATION 1094 /*! connection: memory frees */ -#define WT_STAT_CONN_MEMORY_FREE 1096 +#define WT_STAT_CONN_MEMORY_FREE 1095 /*! connection: memory re-allocations */ -#define WT_STAT_CONN_MEMORY_GROW 1097 +#define WT_STAT_CONN_MEMORY_GROW 1096 /*! connection: pthread mutex condition wait calls */ -#define WT_STAT_CONN_COND_WAIT 1098 +#define WT_STAT_CONN_COND_WAIT 1097 /*! connection: pthread mutex shared lock read-lock calls */ -#define WT_STAT_CONN_RWLOCK_READ 1099 +#define WT_STAT_CONN_RWLOCK_READ 1098 /*! connection: pthread mutex shared lock write-lock calls */ -#define WT_STAT_CONN_RWLOCK_WRITE 1100 +#define WT_STAT_CONN_RWLOCK_WRITE 1099 /*! connection: total fsync I/Os */ -#define WT_STAT_CONN_FSYNC_IO 1101 +#define WT_STAT_CONN_FSYNC_IO 1100 /*! connection: total read I/Os */ -#define WT_STAT_CONN_READ_IO 1102 +#define WT_STAT_CONN_READ_IO 1101 /*! connection: total write I/Os */ -#define WT_STAT_CONN_WRITE_IO 1103 +#define WT_STAT_CONN_WRITE_IO 1102 /*! cursor: cursor create calls */ -#define WT_STAT_CONN_CURSOR_CREATE 1104 +#define WT_STAT_CONN_CURSOR_CREATE 1103 /*! cursor: cursor insert calls */ -#define WT_STAT_CONN_CURSOR_INSERT 1105 +#define WT_STAT_CONN_CURSOR_INSERT 1104 /*! cursor: cursor next calls */ -#define WT_STAT_CONN_CURSOR_NEXT 1106 +#define WT_STAT_CONN_CURSOR_NEXT 1105 /*! cursor: cursor prev calls */ -#define WT_STAT_CONN_CURSOR_PREV 1107 +#define WT_STAT_CONN_CURSOR_PREV 1106 /*! cursor: cursor remove calls */ -#define WT_STAT_CONN_CURSOR_REMOVE 1108 +#define WT_STAT_CONN_CURSOR_REMOVE 1107 /*! cursor: cursor reset calls */ -#define WT_STAT_CONN_CURSOR_RESET 1109 +#define WT_STAT_CONN_CURSOR_RESET 1108 /*! cursor: cursor restarted searches */ -#define WT_STAT_CONN_CURSOR_RESTART 1110 +#define WT_STAT_CONN_CURSOR_RESTART 1109 /*! cursor: cursor search calls */ -#define WT_STAT_CONN_CURSOR_SEARCH 1111 +#define WT_STAT_CONN_CURSOR_SEARCH 1110 /*! cursor: cursor search near calls */ -#define WT_STAT_CONN_CURSOR_SEARCH_NEAR 1112 +#define WT_STAT_CONN_CURSOR_SEARCH_NEAR 1111 /*! cursor: cursor update calls */ -#define WT_STAT_CONN_CURSOR_UPDATE 1113 +#define WT_STAT_CONN_CURSOR_UPDATE 1112 /*! cursor: truncate calls */ -#define WT_STAT_CONN_CURSOR_TRUNCATE 1114 +#define WT_STAT_CONN_CURSOR_TRUNCATE 1113 /*! data-handle: connection data handles currently active */ -#define WT_STAT_CONN_DH_CONN_HANDLE_COUNT 1115 +#define WT_STAT_CONN_DH_CONN_HANDLE_COUNT 1114 /*! data-handle: connection sweep candidate became referenced */ -#define WT_STAT_CONN_DH_SWEEP_REF 1116 +#define WT_STAT_CONN_DH_SWEEP_REF 1115 /*! data-handle: connection sweep dhandles closed */ -#define WT_STAT_CONN_DH_SWEEP_CLOSE 1117 +#define WT_STAT_CONN_DH_SWEEP_CLOSE 1116 /*! data-handle: connection sweep dhandles removed from hash list */ -#define WT_STAT_CONN_DH_SWEEP_REMOVE 1118 +#define WT_STAT_CONN_DH_SWEEP_REMOVE 1117 /*! data-handle: connection sweep time-of-death sets */ -#define WT_STAT_CONN_DH_SWEEP_TOD 1119 +#define WT_STAT_CONN_DH_SWEEP_TOD 1118 /*! data-handle: connection sweeps */ -#define WT_STAT_CONN_DH_SWEEPS 1120 +#define WT_STAT_CONN_DH_SWEEPS 1119 /*! data-handle: session dhandles swept */ -#define WT_STAT_CONN_DH_SESSION_HANDLES 1121 +#define WT_STAT_CONN_DH_SESSION_HANDLES 1120 /*! data-handle: session sweep attempts */ -#define WT_STAT_CONN_DH_SESSION_SWEEPS 1122 +#define WT_STAT_CONN_DH_SESSION_SWEEPS 1121 /*! log: busy returns attempting to switch slots */ -#define WT_STAT_CONN_LOG_SLOT_SWITCH_BUSY 1123 +#define WT_STAT_CONN_LOG_SLOT_SWITCH_BUSY 1122 /*! log: consolidated slot closures */ -#define WT_STAT_CONN_LOG_SLOT_CLOSES 1124 +#define WT_STAT_CONN_LOG_SLOT_CLOSES 1123 /*! log: consolidated slot join races */ -#define WT_STAT_CONN_LOG_SLOT_RACES 1125 +#define WT_STAT_CONN_LOG_SLOT_RACES 1124 /*! log: consolidated slot join transitions */ -#define WT_STAT_CONN_LOG_SLOT_TRANSITIONS 1126 +#define WT_STAT_CONN_LOG_SLOT_TRANSITIONS 1125 /*! log: consolidated slot joins */ -#define WT_STAT_CONN_LOG_SLOT_JOINS 1127 +#define WT_STAT_CONN_LOG_SLOT_JOINS 1126 /*! log: consolidated slot unbuffered writes */ -#define WT_STAT_CONN_LOG_SLOT_UNBUFFERED 1128 +#define WT_STAT_CONN_LOG_SLOT_UNBUFFERED 1127 /*! log: log bytes of payload data */ -#define WT_STAT_CONN_LOG_BYTES_PAYLOAD 1129 +#define WT_STAT_CONN_LOG_BYTES_PAYLOAD 1128 /*! log: log bytes written */ -#define WT_STAT_CONN_LOG_BYTES_WRITTEN 1130 +#define WT_STAT_CONN_LOG_BYTES_WRITTEN 1129 /*! log: log files manually zero-filled */ -#define WT_STAT_CONN_LOG_ZERO_FILLS 1131 +#define WT_STAT_CONN_LOG_ZERO_FILLS 1130 /*! log: log flush operations */ -#define WT_STAT_CONN_LOG_FLUSH 1132 +#define WT_STAT_CONN_LOG_FLUSH 1131 /*! log: log force write operations */ -#define WT_STAT_CONN_LOG_FORCE_WRITE 1133 +#define WT_STAT_CONN_LOG_FORCE_WRITE 1132 /*! log: log force write operations skipped */ -#define WT_STAT_CONN_LOG_FORCE_WRITE_SKIP 1134 +#define WT_STAT_CONN_LOG_FORCE_WRITE_SKIP 1133 /*! log: log records compressed */ -#define WT_STAT_CONN_LOG_COMPRESS_WRITES 1135 +#define WT_STAT_CONN_LOG_COMPRESS_WRITES 1134 /*! log: log records not compressed */ -#define WT_STAT_CONN_LOG_COMPRESS_WRITE_FAILS 1136 +#define WT_STAT_CONN_LOG_COMPRESS_WRITE_FAILS 1135 /*! log: log records too small to compress */ -#define WT_STAT_CONN_LOG_COMPRESS_SMALL 1137 +#define WT_STAT_CONN_LOG_COMPRESS_SMALL 1136 /*! log: log release advances write LSN */ -#define WT_STAT_CONN_LOG_RELEASE_WRITE_LSN 1138 +#define WT_STAT_CONN_LOG_RELEASE_WRITE_LSN 1137 /*! log: log scan operations */ -#define WT_STAT_CONN_LOG_SCANS 1139 +#define WT_STAT_CONN_LOG_SCANS 1138 /*! log: log scan records requiring two reads */ -#define WT_STAT_CONN_LOG_SCAN_REREADS 1140 +#define WT_STAT_CONN_LOG_SCAN_REREADS 1139 /*! log: log server thread advances write LSN */ -#define WT_STAT_CONN_LOG_WRITE_LSN 1141 +#define WT_STAT_CONN_LOG_WRITE_LSN 1140 /*! log: log server thread write LSN walk skipped */ -#define WT_STAT_CONN_LOG_WRITE_LSN_SKIP 1142 +#define WT_STAT_CONN_LOG_WRITE_LSN_SKIP 1141 /*! log: log sync operations */ -#define WT_STAT_CONN_LOG_SYNC 1143 +#define WT_STAT_CONN_LOG_SYNC 1142 /*! log: log sync time duration (usecs) */ -#define WT_STAT_CONN_LOG_SYNC_DURATION 1144 +#define WT_STAT_CONN_LOG_SYNC_DURATION 1143 /*! log: log sync_dir operations */ -#define WT_STAT_CONN_LOG_SYNC_DIR 1145 +#define WT_STAT_CONN_LOG_SYNC_DIR 1144 /*! log: log sync_dir time duration (usecs) */ -#define WT_STAT_CONN_LOG_SYNC_DIR_DURATION 1146 +#define WT_STAT_CONN_LOG_SYNC_DIR_DURATION 1145 /*! log: log write operations */ -#define WT_STAT_CONN_LOG_WRITES 1147 +#define WT_STAT_CONN_LOG_WRITES 1146 /*! log: logging bytes consolidated */ -#define WT_STAT_CONN_LOG_SLOT_CONSOLIDATED 1148 +#define WT_STAT_CONN_LOG_SLOT_CONSOLIDATED 1147 /*! log: maximum log file size */ -#define WT_STAT_CONN_LOG_MAX_FILESIZE 1149 +#define WT_STAT_CONN_LOG_MAX_FILESIZE 1148 /*! log: number of pre-allocated log files to create */ -#define WT_STAT_CONN_LOG_PREALLOC_MAX 1150 +#define WT_STAT_CONN_LOG_PREALLOC_MAX 1149 /*! log: pre-allocated log files not ready and missed */ -#define WT_STAT_CONN_LOG_PREALLOC_MISSED 1151 +#define WT_STAT_CONN_LOG_PREALLOC_MISSED 1150 /*! log: pre-allocated log files prepared */ -#define WT_STAT_CONN_LOG_PREALLOC_FILES 1152 +#define WT_STAT_CONN_LOG_PREALLOC_FILES 1151 /*! log: pre-allocated log files used */ -#define WT_STAT_CONN_LOG_PREALLOC_USED 1153 +#define WT_STAT_CONN_LOG_PREALLOC_USED 1152 /*! log: records processed by log scan */ -#define WT_STAT_CONN_LOG_SCAN_RECORDS 1154 +#define WT_STAT_CONN_LOG_SCAN_RECORDS 1153 /*! log: total in-memory size of compressed records */ -#define WT_STAT_CONN_LOG_COMPRESS_MEM 1155 +#define WT_STAT_CONN_LOG_COMPRESS_MEM 1154 /*! log: total log buffer size */ -#define WT_STAT_CONN_LOG_BUFFER_SIZE 1156 +#define WT_STAT_CONN_LOG_BUFFER_SIZE 1155 /*! log: total size of compressed records */ -#define WT_STAT_CONN_LOG_COMPRESS_LEN 1157 +#define WT_STAT_CONN_LOG_COMPRESS_LEN 1156 /*! log: written slots coalesced */ -#define WT_STAT_CONN_LOG_SLOT_COALESCED 1158 +#define WT_STAT_CONN_LOG_SLOT_COALESCED 1157 /*! log: yields waiting for previous log file close */ -#define WT_STAT_CONN_LOG_CLOSE_YIELDS 1159 +#define WT_STAT_CONN_LOG_CLOSE_YIELDS 1158 /*! reconciliation: fast-path pages deleted */ -#define WT_STAT_CONN_REC_PAGE_DELETE_FAST 1160 +#define WT_STAT_CONN_REC_PAGE_DELETE_FAST 1159 /*! reconciliation: page reconciliation calls */ -#define WT_STAT_CONN_REC_PAGES 1161 +#define WT_STAT_CONN_REC_PAGES 1160 /*! reconciliation: page reconciliation calls for eviction */ -#define WT_STAT_CONN_REC_PAGES_EVICTION 1162 +#define WT_STAT_CONN_REC_PAGES_EVICTION 1161 /*! reconciliation: pages deleted */ -#define WT_STAT_CONN_REC_PAGE_DELETE 1163 +#define WT_STAT_CONN_REC_PAGE_DELETE 1162 /*! reconciliation: split bytes currently awaiting free */ -#define WT_STAT_CONN_REC_SPLIT_STASHED_BYTES 1164 +#define WT_STAT_CONN_REC_SPLIT_STASHED_BYTES 1163 /*! reconciliation: split objects currently awaiting free */ -#define WT_STAT_CONN_REC_SPLIT_STASHED_OBJECTS 1165 +#define WT_STAT_CONN_REC_SPLIT_STASHED_OBJECTS 1164 /*! session: open cursor count */ -#define WT_STAT_CONN_SESSION_CURSOR_OPEN 1166 +#define WT_STAT_CONN_SESSION_CURSOR_OPEN 1165 /*! session: open session count */ -#define WT_STAT_CONN_SESSION_OPEN 1167 +#define WT_STAT_CONN_SESSION_OPEN 1166 /*! session: table compact failed calls */ -#define WT_STAT_CONN_SESSION_TABLE_COMPACT_FAIL 1168 +#define WT_STAT_CONN_SESSION_TABLE_COMPACT_FAIL 1167 /*! session: table compact successful calls */ -#define WT_STAT_CONN_SESSION_TABLE_COMPACT_SUCCESS 1169 +#define WT_STAT_CONN_SESSION_TABLE_COMPACT_SUCCESS 1168 /*! session: table create failed calls */ -#define WT_STAT_CONN_SESSION_TABLE_CREATE_FAIL 1170 +#define WT_STAT_CONN_SESSION_TABLE_CREATE_FAIL 1169 /*! session: table create successful calls */ -#define WT_STAT_CONN_SESSION_TABLE_CREATE_SUCCESS 1171 +#define WT_STAT_CONN_SESSION_TABLE_CREATE_SUCCESS 1170 /*! session: table drop failed calls */ -#define WT_STAT_CONN_SESSION_TABLE_DROP_FAIL 1172 +#define WT_STAT_CONN_SESSION_TABLE_DROP_FAIL 1171 /*! session: table drop successful calls */ -#define WT_STAT_CONN_SESSION_TABLE_DROP_SUCCESS 1173 +#define WT_STAT_CONN_SESSION_TABLE_DROP_SUCCESS 1172 /*! session: table rebalance failed calls */ -#define WT_STAT_CONN_SESSION_TABLE_REBALANCE_FAIL 1174 +#define WT_STAT_CONN_SESSION_TABLE_REBALANCE_FAIL 1173 /*! session: table rebalance successful calls */ -#define WT_STAT_CONN_SESSION_TABLE_REBALANCE_SUCCESS 1175 +#define WT_STAT_CONN_SESSION_TABLE_REBALANCE_SUCCESS 1174 /*! session: table rename failed calls */ -#define WT_STAT_CONN_SESSION_TABLE_RENAME_FAIL 1176 +#define WT_STAT_CONN_SESSION_TABLE_RENAME_FAIL 1175 /*! session: table rename successful calls */ -#define WT_STAT_CONN_SESSION_TABLE_RENAME_SUCCESS 1177 +#define WT_STAT_CONN_SESSION_TABLE_RENAME_SUCCESS 1176 /*! session: table salvage failed calls */ -#define WT_STAT_CONN_SESSION_TABLE_SALVAGE_FAIL 1178 +#define WT_STAT_CONN_SESSION_TABLE_SALVAGE_FAIL 1177 /*! session: table salvage successful calls */ -#define WT_STAT_CONN_SESSION_TABLE_SALVAGE_SUCCESS 1179 +#define WT_STAT_CONN_SESSION_TABLE_SALVAGE_SUCCESS 1178 /*! session: table truncate failed calls */ -#define WT_STAT_CONN_SESSION_TABLE_TRUNCATE_FAIL 1180 +#define WT_STAT_CONN_SESSION_TABLE_TRUNCATE_FAIL 1179 /*! session: table truncate successful calls */ -#define WT_STAT_CONN_SESSION_TABLE_TRUNCATE_SUCCESS 1181 +#define WT_STAT_CONN_SESSION_TABLE_TRUNCATE_SUCCESS 1180 /*! session: table verify failed calls */ -#define WT_STAT_CONN_SESSION_TABLE_VERIFY_FAIL 1182 +#define WT_STAT_CONN_SESSION_TABLE_VERIFY_FAIL 1181 /*! session: table verify successful calls */ -#define WT_STAT_CONN_SESSION_TABLE_VERIFY_SUCCESS 1183 +#define WT_STAT_CONN_SESSION_TABLE_VERIFY_SUCCESS 1182 /*! thread-state: active filesystem fsync calls */ -#define WT_STAT_CONN_THREAD_FSYNC_ACTIVE 1184 +#define WT_STAT_CONN_THREAD_FSYNC_ACTIVE 1183 /*! thread-state: active filesystem read calls */ -#define WT_STAT_CONN_THREAD_READ_ACTIVE 1185 +#define WT_STAT_CONN_THREAD_READ_ACTIVE 1184 /*! thread-state: active filesystem write calls */ -#define WT_STAT_CONN_THREAD_WRITE_ACTIVE 1186 +#define WT_STAT_CONN_THREAD_WRITE_ACTIVE 1185 /*! thread-yield: page acquire busy blocked */ -#define WT_STAT_CONN_PAGE_BUSY_BLOCKED 1187 +#define WT_STAT_CONN_PAGE_BUSY_BLOCKED 1186 /*! thread-yield: page acquire eviction blocked */ -#define WT_STAT_CONN_PAGE_FORCIBLE_EVICT_BLOCKED 1188 +#define WT_STAT_CONN_PAGE_FORCIBLE_EVICT_BLOCKED 1187 /*! thread-yield: page acquire locked blocked */ -#define WT_STAT_CONN_PAGE_LOCKED_BLOCKED 1189 +#define WT_STAT_CONN_PAGE_LOCKED_BLOCKED 1188 /*! thread-yield: page acquire read blocked */ -#define WT_STAT_CONN_PAGE_READ_BLOCKED 1190 +#define WT_STAT_CONN_PAGE_READ_BLOCKED 1189 /*! thread-yield: page acquire time sleeping (usecs) */ -#define WT_STAT_CONN_PAGE_SLEEP 1191 +#define WT_STAT_CONN_PAGE_SLEEP 1190 /*! transaction: number of named snapshots created */ -#define WT_STAT_CONN_TXN_SNAPSHOTS_CREATED 1192 +#define WT_STAT_CONN_TXN_SNAPSHOTS_CREATED 1191 /*! transaction: number of named snapshots dropped */ -#define WT_STAT_CONN_TXN_SNAPSHOTS_DROPPED 1193 +#define WT_STAT_CONN_TXN_SNAPSHOTS_DROPPED 1192 /*! transaction: transaction begins */ -#define WT_STAT_CONN_TXN_BEGIN 1194 +#define WT_STAT_CONN_TXN_BEGIN 1193 /*! transaction: transaction checkpoint currently running */ -#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1195 +#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1194 /*! transaction: transaction checkpoint generation */ -#define WT_STAT_CONN_TXN_CHECKPOINT_GENERATION 1196 +#define WT_STAT_CONN_TXN_CHECKPOINT_GENERATION 1195 /*! transaction: transaction checkpoint max time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1197 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1196 /*! transaction: transaction checkpoint min time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1198 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1197 /*! transaction: transaction checkpoint most recent time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1199 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1198 /*! transaction: transaction checkpoint scrub dirty target */ -#define WT_STAT_CONN_TXN_CHECKPOINT_SCRUB_TARGET 1200 +#define WT_STAT_CONN_TXN_CHECKPOINT_SCRUB_TARGET 1199 /*! transaction: transaction checkpoint scrub time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_SCRUB_TIME 1201 +#define WT_STAT_CONN_TXN_CHECKPOINT_SCRUB_TIME 1200 /*! transaction: transaction checkpoint total time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1202 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1201 /*! transaction: transaction checkpoints */ -#define WT_STAT_CONN_TXN_CHECKPOINT 1203 +#define WT_STAT_CONN_TXN_CHECKPOINT 1202 /*! transaction: transaction failures due to cache overflow */ -#define WT_STAT_CONN_TXN_FAIL_CACHE 1204 -/*! transaction: transaction fsync calls for checkpoint after allocating - * the transaction ID */ -#define WT_STAT_CONN_TXN_CHECKPOINT_FSYNC_POST 1205 -/*! transaction: transaction fsync duration for checkpoint after - * allocating the transaction ID (usecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_FSYNC_POST_DURATION 1206 +#define WT_STAT_CONN_TXN_FAIL_CACHE 1203 +/*! + * transaction: transaction fsync calls for checkpoint after allocating + * the transaction ID + */ +#define WT_STAT_CONN_TXN_CHECKPOINT_FSYNC_POST 1204 +/*! + * transaction: transaction fsync duration for checkpoint after + * allocating the transaction ID (usecs) + */ +#define WT_STAT_CONN_TXN_CHECKPOINT_FSYNC_POST_DURATION 1205 /*! transaction: transaction range of IDs currently pinned */ -#define WT_STAT_CONN_TXN_PINNED_RANGE 1207 +#define WT_STAT_CONN_TXN_PINNED_RANGE 1206 /*! transaction: transaction range of IDs currently pinned by a checkpoint */ -#define WT_STAT_CONN_TXN_PINNED_CHECKPOINT_RANGE 1208 -/*! transaction: transaction range of IDs currently pinned by named - * snapshots */ -#define WT_STAT_CONN_TXN_PINNED_SNAPSHOT_RANGE 1209 +#define WT_STAT_CONN_TXN_PINNED_CHECKPOINT_RANGE 1207 +/*! + * transaction: transaction range of IDs currently pinned by named + * snapshots + */ +#define WT_STAT_CONN_TXN_PINNED_SNAPSHOT_RANGE 1208 /*! transaction: transaction sync calls */ -#define WT_STAT_CONN_TXN_SYNC 1210 +#define WT_STAT_CONN_TXN_SYNC 1209 /*! transaction: transactions committed */ -#define WT_STAT_CONN_TXN_COMMIT 1211 +#define WT_STAT_CONN_TXN_COMMIT 1210 /*! transaction: transactions rolled back */ -#define WT_STAT_CONN_TXN_ROLLBACK 1212 +#define WT_STAT_CONN_TXN_ROLLBACK 1211 /*! * @} @@ -4654,8 +4671,10 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); #define WT_STAT_DSRC_LSM_CHUNK_COUNT 2006 /*! LSM: highest merge generation in the LSM tree */ #define WT_STAT_DSRC_LSM_GENERATION_MAX 2007 -/*! LSM: queries that could have benefited from a Bloom filter that did - * not exist */ +/*! + * LSM: queries that could have benefited from a Bloom filter that did + * not exist + */ #define WT_STAT_DSRC_LSM_LOOKUP_NO_BLOOM 2008 /*! LSM: sleep for LSM checkpoint throttle */ #define WT_STAT_DSRC_LSM_CHECKPOINT_THROTTLE 2009 @@ -4685,15 +4704,30 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); #define WT_STAT_DSRC_BLOCK_MINOR 2021 /*! btree: btree checkpoint generation */ #define WT_STAT_DSRC_BTREE_CHECKPOINT_GENERATION 2022 -/*! btree: column-store fixed-size leaf pages */ +/*! + * btree: column-store fixed-size leaf pages, only reported if + * statistics=all is set + */ #define WT_STAT_DSRC_BTREE_COLUMN_FIX 2023 -/*! btree: column-store internal pages */ +/*! + * btree: column-store internal pages, only reported if statistics=all is + * set + */ #define WT_STAT_DSRC_BTREE_COLUMN_INTERNAL 2024 -/*! btree: column-store variable-size RLE encoded values */ +/*! + * btree: column-store variable-size RLE encoded values, only reported if + * statistics=all is set + */ #define WT_STAT_DSRC_BTREE_COLUMN_RLE 2025 -/*! btree: column-store variable-size deleted values */ +/*! + * btree: column-store variable-size deleted values, only reported if + * statistics=all is set + */ #define WT_STAT_DSRC_BTREE_COLUMN_DELETED 2026 -/*! btree: column-store variable-size leaf pages */ +/*! + * btree: column-store variable-size leaf pages, only reported if + * statistics=all is set + */ #define WT_STAT_DSRC_BTREE_COLUMN_VARIABLE 2027 /*! btree: fixed-record size */ #define WT_STAT_DSRC_BTREE_FIXED_LEN 2028 @@ -4709,15 +4743,21 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); #define WT_STAT_DSRC_BTREE_MAXLEAFVALUE 2033 /*! btree: maximum tree depth */ #define WT_STAT_DSRC_BTREE_MAXIMUM_DEPTH 2034 -/*! btree: number of key/value pairs */ +/*! + * btree: number of key/value pairs, only reported if statistics=all is + * set + */ #define WT_STAT_DSRC_BTREE_ENTRIES 2035 -/*! btree: overflow pages */ +/*! btree: overflow pages, only reported if statistics=all is set */ #define WT_STAT_DSRC_BTREE_OVERFLOW 2036 /*! btree: pages rewritten by compaction */ #define WT_STAT_DSRC_BTREE_COMPACT_REWRITE 2037 -/*! btree: row-store internal pages */ +/*! + * btree: row-store internal pages, only reported if statistics=all is + * set + */ #define WT_STAT_DSRC_BTREE_ROW_INTERNAL 2038 -/*! btree: row-store leaf pages */ +/*! btree: row-store leaf pages, only reported if statistics=all is set */ #define WT_STAT_DSRC_BTREE_ROW_LEAF 2039 /*! cache: bytes currently in the cache */ #define WT_STAT_DSRC_CACHE_BYTES_INUSE 2040 @@ -4811,8 +4851,10 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); #define WT_STAT_DSRC_REC_DICTIONARY 2084 /*! reconciliation: fast-path pages deleted */ #define WT_STAT_DSRC_REC_PAGE_DELETE_FAST 2085 -/*! reconciliation: internal page key bytes discarded using suffix - * compression */ +/*! + * reconciliation: internal page key bytes discarded using suffix + * compression + */ #define WT_STAT_DSRC_REC_SUFFIX_COMPRESSION 2086 /*! reconciliation: internal page multi-block writes */ #define WT_STAT_DSRC_REC_MULTIBLOCK_INTERNAL 2087 diff --git a/src/third_party/wiredtiger/src/include/wt_internal.h b/src/third_party/wiredtiger/src/include/wt_internal.h index 99180896611..4e6699ab9d1 100644 --- a/src/third_party/wiredtiger/src/include/wt_internal.h +++ b/src/third_party/wiredtiger/src/include/wt_internal.h @@ -24,7 +24,9 @@ extern "C" { *******************************************/ #ifndef _WIN32 #include <sys/mman.h> +#endif #include <sys/stat.h> +#ifndef _WIN32 #include <sys/time.h> #include <sys/uio.h> #endif diff --git a/src/third_party/wiredtiger/src/log/log.c b/src/third_party/wiredtiger/src/log/log.c index 14cb2b8c064..b17f31d5d16 100644 --- a/src/third_party/wiredtiger/src/log/log.c +++ b/src/third_party/wiredtiger/src/log/log.c @@ -640,7 +640,7 @@ __log_file_header( logrec->len = log->allocsize; logrec->checksum = 0; __wt_log_record_byteswap(logrec); - logrec->checksum = __wt_cksum(logrec, log->allocsize); + logrec->checksum = __wt_checksum(logrec, log->allocsize); #ifdef WORDS_BIGENDIAN logrec->checksum = __wt_bswap32(logrec->checksum); #endif @@ -799,14 +799,12 @@ __log_newfile(WT_SESSION_IMPL *session, bool conn_open, bool *created) WT_FH *log_fh; WT_LOG *log; WT_LSN end_lsn; - int yield_cnt; + u_int yield_cnt; bool create_log; conn = S2C(session); log = conn->log; - create_log = true; - yield_cnt = 0; /* * Set aside the log file handle to be closed later. Other threads * may still be using it to write to the log. If the log file size @@ -814,7 +812,7 @@ __log_newfile(WT_SESSION_IMPL *session, bool conn_open, bool *created) * Wait for that to close. */ WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_SLOT)); - while (log->log_close_fh != NULL) { + for (yield_cnt = 0; log->log_close_fh != NULL;) { WT_STAT_FAST_CONN_INCR(session, log_close_yields); __wt_log_wrlsn(session, NULL); if (++yield_cnt > 10000) @@ -834,30 +832,39 @@ __log_newfile(WT_SESSION_IMPL *session, bool conn_open, bool *created) * Make sure everything we set above is visible. */ WT_FULL_BARRIER(); + /* - * If we're pre-allocating log files, look for one. If there aren't any - * or we're not pre-allocating, or a backup cursor is open, then - * create one. + * If pre-allocating log files look for one; otherwise, or if we don't + * find one create a log file. We can't use pre-allocated log files in + * while a hot backup is in progress: applications can copy the files + * in any way they choose, and a log file rename might confuse things. */ + create_log = true; if (conn->log_prealloc > 0 && !conn->hot_backup) { - ret = __log_alloc_prealloc(session, log->fileid); - /* - * If ret is 0 it means we found a pre-allocated file. - * If ret is non-zero but not WT_NOTFOUND, we return the error. - * If ret is WT_NOTFOUND, we leave create_log set and create - * the new log file. - */ - if (ret == 0) - create_log = false; - /* - * If we get any error other than WT_NOTFOUND, return it. - */ - WT_RET_NOTFOUND_OK(ret); + __wt_readlock(session, conn->hot_backup_lock); + if (conn->hot_backup) + __wt_readunlock(session, conn->hot_backup_lock); + else { + ret = __log_alloc_prealloc(session, log->fileid); + __wt_readunlock(session, conn->hot_backup_lock); - if (create_log) { - WT_STAT_FAST_CONN_INCR(session, log_prealloc_missed); - if (conn->log_cond != NULL) - __wt_cond_auto_signal(session, conn->log_cond); + /* + * If ret is 0 it means we found a pre-allocated file. + * If ret is WT_NOTFOUND, create the new log file and + * signal the server, we missed our pre-allocation. + * If ret is non-zero but not WT_NOTFOUND, return the + * error. + */ + WT_RET_NOTFOUND_OK(ret); + if (ret == 0) + create_log = false; + else { + WT_STAT_FAST_CONN_INCR( + session, log_prealloc_missed); + if (conn->log_cond != NULL) + __wt_cond_auto_signal( + session, conn->log_cond); + } } } /* @@ -968,11 +975,17 @@ __log_truncate_file(WT_SESSION_IMPL *session, WT_FH *log_fh, wt_off_t offset) conn = S2C(session); log = conn->log; - if (!F_ISSET(log, WT_LOG_TRUNCATE_NOTSUP)) { - if ((ret = __wt_ftruncate(session, log_fh, offset)) != ENOTSUP) - return (ret); - - F_SET(log, WT_LOG_TRUNCATE_NOTSUP); + if (!F_ISSET(log, WT_LOG_TRUNCATE_NOTSUP) && !conn->hot_backup) { + __wt_readlock(session, conn->hot_backup_lock); + if (conn->hot_backup) + __wt_readunlock(session, conn->hot_backup_lock); + else { + ret = __wt_ftruncate(session, log_fh, offset); + __wt_readunlock(session, conn->hot_backup_lock); + if (ret != ENOTSUP) + return (ret); + F_SET(log, WT_LOG_TRUNCATE_NOTSUP); + } } return (__log_zero(session, log_fh, offset, conn->log_file_max)); @@ -1349,8 +1362,7 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep) yield_count = 0; if (freep != NULL) *freep = 1; - release_buffered = - WT_LOG_SLOT_RELEASED_BUFFERED(slot->slot_state); + release_buffered = WT_LOG_SLOT_RELEASED_BUFFERED(slot->slot_state); release_bytes = release_buffered + slot->slot_unbuffered; /* @@ -1363,7 +1375,7 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep) */ if (WT_CKPT_LOGSIZE(conn)) { log->log_written += (wt_off_t)release_bytes; - WT_RET(__wt_checkpoint_signal(session, log->log_written)); + __wt_checkpoint_signal(session, log->log_written); } /* Write the buffered records */ @@ -1535,7 +1547,7 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, WT_LSN end_lsn, next_lsn, rd_lsn, start_lsn; wt_off_t log_size; uint32_t allocsize, firstlog, lastlog, lognum, rdup_len, reclen; - uint32_t cksum_calculate, cksum_tmp; + uint32_t checksum_calculate, checksum_tmp; u_int i, logcount; int firstrecord; bool eol, partial_record; @@ -1747,12 +1759,12 @@ advance: */ buf->size = reclen; logrec = (WT_LOG_RECORD *)buf->mem; - cksum_tmp = logrec->checksum; + checksum_tmp = logrec->checksum; logrec->checksum = 0; - cksum_calculate = __wt_cksum(logrec, reclen); - logrec->checksum = cksum_tmp; + checksum_calculate = __wt_checksum(logrec, reclen); + logrec->checksum = checksum_tmp; __wt_log_record_byteswap(logrec); - if (logrec->checksum != cksum_calculate) { + if (logrec->checksum != checksum_calculate) { /* * A checksum mismatch means we have reached the end of * the useful part of the log. This should be found on @@ -2066,7 +2078,7 @@ __log_write_internal(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, logrec->len = (uint32_t)record->size; logrec->checksum = 0; __wt_log_record_byteswap(logrec); - logrec->checksum = __wt_cksum(logrec, record->size); + logrec->checksum = __wt_checksum(logrec, record->size); #ifdef WORDS_BIGENDIAN logrec->checksum = __wt_bswap32(logrec->checksum); #endif diff --git a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c index 78d77884d40..bf591d8dbe6 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c @@ -1074,8 +1074,7 @@ __clsm_lookup(WT_CURSOR_LSM *clsm, WT_ITEM *value) bloom = NULL; if ((bloom = clsm->blooms[i]) != NULL) { if (!have_hash) { - WT_ERR(__wt_bloom_hash( - bloom, &cursor->key, &bhash)); + __wt_bloom_hash(bloom, &cursor->key, &bhash); have_hash = true; } diff --git a/src/third_party/wiredtiger/src/lsm/lsm_manager.c b/src/third_party/wiredtiger/src/lsm/lsm_manager.c index bafab9abaa3..a504acc361c 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_manager.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_manager.c @@ -491,9 +491,8 @@ err: WT_PANIC_MSG(session, ret, "LSM worker manager thread error"); * introduces an inefficiency if LSM trees are being opened and closed * regularly. */ -int -__wt_lsm_manager_clear_tree( - WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) +void +__wt_lsm_manager_clear_tree(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) { WT_LSM_MANAGER *manager; WT_LSM_WORK_UNIT *current, *next; @@ -541,7 +540,6 @@ __wt_lsm_manager_clear_tree( } __wt_spin_unlock(session, &manager->manager_lock); WT_STAT_FAST_CONN_INCRV(session, lsm_work_units_discarded, removed); - return (0); } /* diff --git a/src/third_party/wiredtiger/src/lsm/lsm_merge.c b/src/third_party/wiredtiger/src/lsm/lsm_merge.c index ccad6c90449..2276631af1e 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_merge.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_merge.c @@ -43,12 +43,11 @@ __wt_lsm_merge_update_tree(WT_SESSION_IMPL *session, * __lsm_merge_aggressive_clear -- * We found a merge to do - clear the aggressive timer. */ -static int +static void __lsm_merge_aggressive_clear(WT_LSM_TREE *lsm_tree) { F_CLR(lsm_tree, WT_LSM_TREE_AGGRESSIVE_TIMER); lsm_tree->merge_aggressiveness = 0; - return (0); } /* @@ -80,8 +79,10 @@ __lsm_merge_aggressive_update(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) * Only get aggressive if a reasonable number of flushes have been * completed since opening the tree. */ - if (lsm_tree->chunks_flushed <= lsm_tree->merge_min) - return (__lsm_merge_aggressive_clear(lsm_tree)); + if (lsm_tree->chunks_flushed <= lsm_tree->merge_min) { + __lsm_merge_aggressive_clear(lsm_tree); + return (0); + } /* * Start the timer if it isn't running. Use a flag to define whether @@ -329,7 +330,7 @@ retry_find: return (WT_NOTFOUND); } - WT_RET(__lsm_merge_aggressive_clear(lsm_tree)); + __lsm_merge_aggressive_clear(lsm_tree); *records = record_count; *start = start_chunk; *end = end_chunk; @@ -471,7 +472,7 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id) dest->set_value(dest, &value); WT_ERR(dest->insert(dest)); if (create_bloom) - WT_ERR(__wt_bloom_insert(bloom, &key)); + __wt_bloom_insert(bloom, &key); } WT_ERR_NOTFOUND_OK(ret); diff --git a/src/third_party/wiredtiger/src/lsm/lsm_meta.c b/src/third_party/wiredtiger/src/lsm/lsm_meta.c index 7e100cb855c..ec52af96231 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_meta.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_meta.c @@ -28,15 +28,15 @@ __lsm_meta_read_v0( if (F_ISSET(S2C(session), WT_CONN_LSM_MERGE)) F_SET(lsm_tree, WT_LSM_TREE_MERGES); - WT_ERR(__wt_config_init(session, &cparser, lsmconf)); + __wt_config_init(session, &cparser, lsmconf); while ((ret = __wt_config_next(&cparser, &ck, &cv)) == 0) { if (WT_STRING_MATCH("key_format", ck.str, ck.len)) { __wt_free(session, lsm_tree->key_format); - WT_ERR(__wt_strndup(session, + WT_RET(__wt_strndup(session, cv.str, cv.len, &lsm_tree->key_format)); } else if (WT_STRING_MATCH("value_format", ck.str, ck.len)) { __wt_free(session, lsm_tree->value_format); - WT_ERR(__wt_strndup(session, + WT_RET(__wt_strndup(session, cv.str, cv.len, &lsm_tree->value_format)); } else if (WT_STRING_MATCH("collator", ck.str, ck.len)) { if (cv.len == 0 || @@ -46,25 +46,25 @@ __lsm_meta_read_v0( * Extract the application-supplied metadata (if any) * from the file configuration. */ - WT_ERR(__wt_config_getones( + WT_RET(__wt_config_getones( session, lsmconf, "file_config", &fileconf)); WT_CLEAR(metadata); - WT_ERR_NOTFOUND_OK(__wt_config_subgets( + WT_RET_NOTFOUND_OK(__wt_config_subgets( session, &fileconf, "app_metadata", &metadata)); - WT_ERR(__wt_collator_config(session, lsm_tree->name, + WT_RET(__wt_collator_config(session, lsm_tree->name, &cv, &metadata, &lsm_tree->collator, &lsm_tree->collator_owned)); - WT_ERR(__wt_strndup(session, + WT_RET(__wt_strndup(session, cv.str, cv.len, &lsm_tree->collator_name)); } else if (WT_STRING_MATCH("bloom_config", ck.str, ck.len)) { __wt_free(session, lsm_tree->bloom_config); /* Don't include the brackets. */ - WT_ERR(__wt_strndup(session, + WT_RET(__wt_strndup(session, cv.str + 1, cv.len - 2, &lsm_tree->bloom_config)); } else if (WT_STRING_MATCH("file_config", ck.str, ck.len)) { __wt_free(session, lsm_tree->file_config); /* Don't include the brackets. */ - WT_ERR(__wt_strndup(session, + WT_RET(__wt_strndup(session, cv.str + 1, cv.len - 2, &lsm_tree->file_config)); } else if (WT_STRING_MATCH("auto_throttle", ck.str, ck.len)) { if (cv.val) @@ -92,25 +92,25 @@ __lsm_meta_read_v0( else if (WT_STRING_MATCH("last", ck.str, ck.len)) lsm_tree->last = (u_int)cv.val; else if (WT_STRING_MATCH("chunks", ck.str, ck.len)) { - WT_ERR(__wt_config_subinit(session, &lparser, &cv)); + __wt_config_subinit(session, &lparser, &cv); for (nchunks = 0; (ret = __wt_config_next(&lparser, &lk, &lv)) == 0; ) { if (WT_STRING_MATCH("id", lk.str, lk.len)) { - WT_ERR(__wt_realloc_def(session, + WT_RET(__wt_realloc_def(session, &lsm_tree->chunk_alloc, nchunks + 1, &lsm_tree->chunk)); - WT_ERR( + WT_RET( __wt_calloc_one(session, &chunk)); lsm_tree->chunk[nchunks++] = chunk; chunk->id = (uint32_t)lv.val; - WT_ERR(__wt_lsm_tree_chunk_name(session, + WT_RET(__wt_lsm_tree_chunk_name(session, lsm_tree, chunk->id, &chunk->uri)); F_SET(chunk, WT_LSM_CHUNK_ONDISK | WT_LSM_CHUNK_STABLE); } else if (WT_STRING_MATCH( "bloom", lk.str, lk.len)) { - WT_ERR(__wt_lsm_tree_bloom_name( + WT_RET(__wt_lsm_tree_bloom_name( session, lsm_tree, chunk->id, &chunk->bloom_uri)); F_SET(chunk, WT_LSM_CHUNK_BLOOM); @@ -129,28 +129,28 @@ __lsm_meta_read_v0( continue; } } - WT_ERR_NOTFOUND_OK(ret); + WT_RET_NOTFOUND_OK(ret); lsm_tree->nchunks = nchunks; } else if (WT_STRING_MATCH("old_chunks", ck.str, ck.len)) { - WT_ERR(__wt_config_subinit(session, &lparser, &cv)); + __wt_config_subinit(session, &lparser, &cv); for (nchunks = 0; (ret = __wt_config_next(&lparser, &lk, &lv)) == 0; ) { if (WT_STRING_MATCH("bloom", lk.str, lk.len)) { - WT_ERR(__wt_strndup(session, + WT_RET(__wt_strndup(session, lv.str, lv.len, &chunk->bloom_uri)); F_SET(chunk, WT_LSM_CHUNK_BLOOM); continue; } - WT_ERR(__wt_realloc_def(session, + WT_RET(__wt_realloc_def(session, &lsm_tree->old_alloc, nchunks + 1, &lsm_tree->old_chunks)); - WT_ERR(__wt_calloc_one(session, &chunk)); + WT_RET(__wt_calloc_one(session, &chunk)); lsm_tree->old_chunks[nchunks++] = chunk; - WT_ERR(__wt_strndup(session, + WT_RET(__wt_strndup(session, lk.str, lk.len, &chunk->uri)); F_SET(chunk, WT_LSM_CHUNK_ONDISK); } - WT_ERR_NOTFOUND_OK(ret); + WT_RET_NOTFOUND_OK(ret); lsm_tree->nold_chunks = nchunks; } /* @@ -158,8 +158,8 @@ __lsm_meta_read_v0( * created by a future release, with unknown options. */ } - WT_ERR_NOTFOUND_OK(ret); -err: return (ret); + WT_RET_NOTFOUND_OK(ret); + return (0); } /* @@ -264,7 +264,7 @@ __lsm_meta_read_v1( WT_ERR(__wt_config_getones(session, lsmconf, "last", &cv)); lsm_tree->last = (u_int)cv.val; WT_ERR(__wt_config_getones(session, lsmconf, "chunks", &cv)); - WT_ERR(__wt_config_subinit(session, &lparser, &cv)); + __wt_config_subinit(session, &lparser, &cv); for (nchunks = 0; (ret = __wt_config_next(&lparser, &lk, &lv)) == 0; ) { if (WT_STRING_MATCH("id", lk.str, lk.len)) { @@ -299,7 +299,7 @@ __lsm_meta_read_v1( lsm_tree->nchunks = nchunks; WT_ERR(__wt_config_getones(session, lsmconf, "old_chunks", &cv)); - WT_ERR(__wt_config_subinit(session, &lparser, &cv)); + __wt_config_subinit(session, &lparser, &cv); for (nchunks = 0; (ret = __wt_config_next(&lparser, &lk, &lv)) == 0; ) { if (WT_STRING_MATCH("bloom", lk.str, lk.len)) { @@ -404,6 +404,7 @@ __lsm_meta_upgrade_v1(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) err: __wt_scr_free(session, &buf); return (ret); } + /* * __wt_lsm_meta_read -- * Read the metadata for an LSM tree. diff --git a/src/third_party/wiredtiger/src/lsm/lsm_tree.c b/src/third_party/wiredtiger/src/lsm/lsm_tree.c index c84f5c519cf..db9fd581110 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_tree.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_tree.c @@ -85,10 +85,9 @@ __lsm_tree_discard(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool final) * __lsm_tree_close -- * Close an LSM tree structure. */ -static int +static void __lsm_tree_close(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool final) { - WT_DECL_RET; int i; /* @@ -97,7 +96,7 @@ __lsm_tree_close(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool final) * the tree queue state. */ lsm_tree->active = false; - WT_READ_BARRIER(); + WT_FULL_BARRIER(); /* * Wait for all LSM operations to drain. If WiredTiger is shutting @@ -120,17 +119,11 @@ __lsm_tree_close(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool final) * other schema level operations will return EBUSY, even though * we're dropping the schema lock here. */ - if (i % WT_THOUSAND == 0) { - WT_WITHOUT_LOCKS(session, ret = + if (i % WT_THOUSAND == 0) + WT_WITHOUT_LOCKS(session, __wt_lsm_manager_clear_tree(session, lsm_tree)); - WT_ERR(ret); - } __wt_yield(); } - return (0); - -err: lsm_tree->active = true; - return (ret); } /* @@ -154,7 +147,7 @@ __wt_lsm_tree_close_all(WT_SESSION_IMPL *session) * is unconditional. */ (void)__wt_atomic_add32(&lsm_tree->refcnt, 1); - WT_TRET(__lsm_tree_close(session, lsm_tree, true)); + __lsm_tree_close(session, lsm_tree, true); WT_TRET(__lsm_tree_discard(session, lsm_tree, true)); } @@ -390,9 +383,8 @@ __lsm_tree_find(WT_SESSION_IMPL *session, * spurious busy returns. */ (void)__wt_atomic_add32(&lsm_tree->refcnt, 1); - if (__lsm_tree_close( - session, lsm_tree, false) != 0 || - lsm_tree->refcnt != 1) { + __lsm_tree_close(session, lsm_tree, false); + if (lsm_tree->refcnt != 1) { __wt_lsm_tree_release( session, lsm_tree); return (EBUSY); diff --git a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c index bfca09b3807..72bcf56b3c4 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c @@ -447,7 +447,7 @@ __lsm_bloom_create(WT_SESSION_IMPL *session, F_SET(session, WT_SESSION_NO_CACHE | WT_SESSION_NO_EVICTION); for (insert_count = 0; (ret = src->next(src)) == 0; insert_count++) { WT_ERR(src->get_key(src, &key)); - WT_ERR(__wt_bloom_insert(bloom, &key)); + __wt_bloom_insert(bloom, &key); } WT_ERR_NOTFOUND_OK(ret); WT_TRET(src->close(src)); diff --git a/src/third_party/wiredtiger/src/meta/meta_ckpt.c b/src/third_party/wiredtiger/src/meta/meta_ckpt.c index 0a864432daf..2b7719c3241 100644 --- a/src/third_party/wiredtiger/src/meta/meta_ckpt.c +++ b/src/third_party/wiredtiger/src/meta/meta_ckpt.c @@ -139,7 +139,7 @@ __ckpt_named(WT_SESSION_IMPL *session, WT_CONFIG_ITEM k, v; WT_RET(__wt_config_getones(session, config, "checkpoint", &v)); - WT_RET(__wt_config_subinit(session, &ckptconf, &v)); + __wt_config_subinit(session, &ckptconf, &v); /* * Take the first match: there should never be more than a single @@ -164,7 +164,7 @@ __ckpt_last(WT_SESSION_IMPL *session, const char *config, WT_CKPT *ckpt) int64_t found; WT_RET(__wt_config_getones(session, config, "checkpoint", &v)); - WT_RET(__wt_config_subinit(session, &ckptconf, &v)); + __wt_config_subinit(session, &ckptconf, &v); for (found = 0; __wt_config_next(&ckptconf, &k, &v) == 0;) { /* Ignore checkpoints before the ones we've already seen. */ WT_RET(__wt_config_subgets(session, &v, "order", &a)); @@ -196,7 +196,7 @@ __ckpt_last_name( *namep = NULL; WT_ERR(__wt_config_getones(session, config, "checkpoint", &v)); - WT_ERR(__wt_config_subinit(session, &ckptconf, &v)); + __wt_config_subinit(session, &ckptconf, &v); for (found = 0; __wt_config_next(&ckptconf, &k, &v) == 0;) { /* * We only care about unnamed checkpoints; applications may not @@ -267,8 +267,8 @@ __wt_meta_ckptlist_get( /* Load any existing checkpoints into the array. */ WT_ERR(__wt_scr_alloc(session, 0, &buf)); - if (__wt_config_getones(session, config, "checkpoint", &v) == 0 && - __wt_config_subinit(session, &ckptconf, &v) == 0) + if (__wt_config_getones(session, config, "checkpoint", &v) == 0) { + __wt_config_subinit(session, &ckptconf, &v); for (; __wt_config_next(&ckptconf, &k, &v) == 0; ++slot) { WT_ERR(__wt_realloc_def( session, &allocated, slot + 1, &ckptbase)); @@ -276,6 +276,7 @@ __wt_meta_ckptlist_get( WT_ERR(__ckpt_load(session, &k, &v, ckpt)); } + } /* * Allocate an extra slot for a new value, plus a slot to mark the end. diff --git a/src/third_party/wiredtiger/src/meta/meta_track.c b/src/third_party/wiredtiger/src/meta/meta_track.c index 3d8b7c46500..9655a0b26a7 100644 --- a/src/third_party/wiredtiger/src/meta/meta_track.c +++ b/src/third_party/wiredtiger/src/meta/meta_track.c @@ -310,12 +310,11 @@ done: /* Apply any tracked operations post-commit. */ * Start a group of operations that can be committed independent of the * main transaction. */ -int +void __wt_meta_track_sub_on(WT_SESSION_IMPL *session) { WT_ASSERT(session, session->meta_track_sub == NULL); session->meta_track_sub = session->meta_track_next; - return (0); } /* diff --git a/src/third_party/wiredtiger/src/os_common/os_fstream_stdio.c b/src/third_party/wiredtiger/src/os_common/os_fstream_stdio.c index eea2c80ff0e..0cc75e109a1 100644 --- a/src/third_party/wiredtiger/src/os_common/os_fstream_stdio.c +++ b/src/third_party/wiredtiger/src/os_common/os_fstream_stdio.c @@ -74,11 +74,9 @@ __stdio_init(WT_FSTREAM *fs, const char *name, FILE *fp) * __wt_os_stdio -- * Initialize the stdio configuration. */ -int +void __wt_os_stdio(WT_SESSION_IMPL *session) { __stdio_init(WT_STDERR(session), "stderr", stderr); __stdio_init(WT_STDOUT(session), "stdout", stdout); - - return (0); } diff --git a/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c b/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c index fb5a0f018cf..9f17d9ff381 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c +++ b/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c @@ -19,10 +19,6 @@ __wt_cond_alloc(WT_SESSION_IMPL *session, WT_CONDVAR *cond; WT_DECL_RET; - /* - * !!! - * This function MUST handle a NULL session handle. - */ WT_RET(__wt_calloc_one(session, &cond)); WT_ERR(pthread_mutex_init(&cond->mtx, NULL)); @@ -60,15 +56,8 @@ __wt_cond_wait_signal( if (__wt_atomic_addi32(&cond->waiters, 1) == 0) return; - /* - * !!! - * This function MUST handle a NULL session handle. - */ - if (session != NULL) { - __wt_verbose( - session, WT_VERB_MUTEX, "wait %s", cond->name, cond); - WT_STAT_FAST_CONN_INCR(session, cond_wait); - } + __wt_verbose(session, WT_VERB_MUTEX, "wait %s", cond->name); + WT_STAT_FAST_CONN_INCR(session, cond_wait); WT_ERR(pthread_mutex_lock(&cond->mtx)); locked = true; @@ -118,12 +107,7 @@ __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond) locked = false; - /* - * !!! - * This function MUST handle a NULL session handle. - */ - if (session != NULL) - __wt_verbose(session, WT_VERB_MUTEX, "signal %s", cond->name); + __wt_verbose(session, WT_VERB_MUTEX, "signal %s", cond->name); /* Fast path if already signalled. */ if (cond->waiters == -1) diff --git a/src/third_party/wiredtiger/src/os_win/os_mtx_cond.c b/src/third_party/wiredtiger/src/os_win/os_mtx_cond.c index da61904443f..27207d289a6 100644 --- a/src/third_party/wiredtiger/src/os_win/os_mtx_cond.c +++ b/src/third_party/wiredtiger/src/os_win/os_mtx_cond.c @@ -18,10 +18,6 @@ __wt_cond_alloc(WT_SESSION_IMPL *session, { WT_CONDVAR *cond; - /* - * !!! - * This function MUST handle a NULL session handle. - */ WT_RET(__wt_calloc_one(session, &cond)); InitializeCriticalSection(&cond->mtx); @@ -57,14 +53,8 @@ __wt_cond_wait_signal( if (__wt_atomic_addi32(&cond->waiters, 1) == 0) return; - /* - * !!! - * This function MUST handle a NULL session handle. - */ - if (session != NULL) { - __wt_verbose(session, WT_VERB_MUTEX, "wait %s", cond->name); - WT_STAT_FAST_CONN_INCR(session, cond_wait); - } + __wt_verbose(session, WT_VERB_MUTEX, "wait %s", cond->name); + WT_STAT_FAST_CONN_INCR(session, cond_wait); EnterCriticalSection(&cond->mtx); locked = true; @@ -131,12 +121,7 @@ __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond) locked = false; - /* - * !!! - * This function MUST handle a NULL session handle. - */ - if (session != NULL) - __wt_verbose(session, WT_VERB_MUTEX, "signal %s", cond->name); + __wt_verbose(session, WT_VERB_MUTEX, "signal %s", cond->name); /* Fast path if already signalled. */ if (cond->waiters == -1) diff --git a/src/third_party/wiredtiger/src/reconcile/rec_track.c b/src/third_party/wiredtiger/src/reconcile/rec_track.c index 1515550deda..10a64fdf116 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_track.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_track.c @@ -46,7 +46,7 @@ __ovfl_discard_verbose( "discard: %s%s%p %s", tag == NULL ? "" : tag, tag == NULL ? "" : ": ", - page, + (void *)page, __wt_addr_string(session, unpack->data, unpack->size, tmp)); __wt_scr_free(session, &tmp); @@ -108,7 +108,7 @@ __ovfl_discard_wrapup(WT_SESSION_IMPL *session, WT_PAGE *page) * __ovfl_discard_wrapup_err -- * Resolve the page's overflow discard list after an error occurs. */ -static int +static void __ovfl_discard_wrapup_err(WT_SESSION_IMPL *session, WT_PAGE *page) { WT_OVFL_TRACK *track; @@ -117,8 +117,6 @@ __ovfl_discard_wrapup_err(WT_SESSION_IMPL *session, WT_PAGE *page) __wt_free(session, track->discard); track->discard_entries = track->discard_allocated = 0; - - return (0); } /* @@ -180,7 +178,7 @@ __ovfl_reuse_verbose(WT_SESSION_IMPL *session, "reuse: %s%s%p %s (%s%s%s) {%.*s}", tag == NULL ? "" : tag, tag == NULL ? "" : ": ", - page, + (void *)page, __wt_addr_string( session, WT_OVFL_REUSE_ADDR(reuse), reuse->addr_size, tmp), F_ISSET(reuse, WT_OVFL_REUSE_INUSE) ? "inuse" : "", @@ -578,7 +576,7 @@ __ovfl_txnc_verbose(WT_SESSION_IMPL *session, "txn-cache: %s%s%p %s %" PRIu64 " {%.*s}", tag == NULL ? "" : tag, tag == NULL ? "" : ": ", - page, + (void *)page, __wt_addr_string( session, WT_OVFL_TXNC_ADDR(txnc), txnc->addr_size, tmp), txnc->current, @@ -903,7 +901,7 @@ __wt_ovfl_track_wrapup_err(WT_SESSION_IMPL *session, WT_PAGE *page) track = page->modify->ovfl_track; if (track->discard != NULL) - WT_RET(__ovfl_discard_wrapup_err(session, page)); + __ovfl_discard_wrapup_err(session, page); if (track->ovfl_reuse[0] != NULL) WT_RET(__ovfl_reuse_wrapup_err(session, page)); diff --git a/src/third_party/wiredtiger/src/reconcile/rec_write.c b/src/third_party/wiredtiger/src/reconcile/rec_write.c index 9c742476910..a9912628942 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_write.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_write.c @@ -159,7 +159,7 @@ typedef struct { WT_ADDR addr; /* Split's written location */ uint32_t size; /* Split's size */ - uint32_t cksum; /* Split's checksum */ + uint32_t checksum; /* Split's checksum */ void *disk_image; /* Split's disk image */ @@ -374,14 +374,19 @@ __wt_reconcile(WT_SESSION_IMPL *session, */ __wt_writelock(session, &page->page_lock); + oldest_id = __wt_txn_oldest_id(session); + if (LF_ISSET(WT_EVICTING)) + mod->last_eviction_id = oldest_id; + +#ifdef HAVE_DIAGNOSTIC /* * Check that transaction time always moves forward for a given page. * If this check fails, reconciliation can free something that a future * reconciliation will need. */ - oldest_id = __wt_txn_oldest_id(session); WT_ASSERT(session, WT_TXNID_LE(mod->last_oldest_id, oldest_id)); mod->last_oldest_id = oldest_id; +#endif /* Initialize the reconciliation structure for each new run. */ if ((ret = __rec_write_init( @@ -1872,7 +1877,7 @@ __rec_split_bnd_init(WT_SESSION_IMPL *session, WT_BOUNDARY *bnd) __wt_free(session, bnd->addr.addr); WT_CLEAR(bnd->addr); bnd->size = 0; - bnd->cksum = 0; + bnd->checksum = 0; __wt_free(session, bnd->disk_image); @@ -3195,7 +3200,7 @@ __rec_split_write(WT_SESSION_IMPL *session, WT_ILLEGAL_VALUE(session); } bnd->size = (uint32_t)buf->size; - bnd->cksum = 0; + bnd->checksum = 0; /* * Check if we've saved updates that belong to this block, and move @@ -3301,7 +3306,7 @@ supd_check_complete: */ dsk->write_gen = 0; memset(WT_BLOCK_HEADER_REF(dsk), 0, btree->block_header); - bnd->cksum = __wt_cksum(buf->data, buf->size); + bnd->checksum = __wt_checksum(buf->data, buf->size); /* * One last check: don't reuse blocks if compacting, the reason @@ -3314,7 +3319,7 @@ supd_check_complete: mod->mod_multi_entries > bnd_slot) { multi = &mod->mod_multi[bnd_slot]; if (multi->size == bnd->size && - multi->cksum == bnd->cksum) { + multi->checksum == bnd->checksum) { multi->addr.reuse = 1; bnd->addr = multi->addr; @@ -3329,7 +3334,7 @@ supd_check_complete: if (WT_VERBOSE_ISSET(session, WT_VERB_SPLIT) && r->entries < 6) __wt_verbose(session, WT_VERB_SPLIT, "Reconciliation creating a page with %" PRIu32 - " entries, memory footprint %" PRIu64 + " entries, memory footprint %" WT_SIZET_FMT ", page count %" PRIu32 ", %s, split state: %d\n", r->entries, r->page->memory_footprint, r->bnd_next, F_ISSET(r, WT_EVICTING) ? "evict" : "checkpoint", @@ -3406,7 +3411,7 @@ __rec_update_las(WT_SESSION_IMPL *session, */ __wt_las_set_written(session); - WT_ERR(__wt_las_cursor(session, &cursor, &session_flags)); + __wt_las_cursor(session, &cursor, &session_flags); /* Ensure enough room for a column-store key without checking. */ WT_ERR(__wt_scr_alloc(session, WT_INTPACK64_MAXSIZE, &key)); @@ -5637,7 +5642,8 @@ __rec_write_wrapup(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) switch (r->bnd_next) { case 0: /* Page delete */ - __wt_verbose(session, WT_VERB_RECONCILE, "page %p empty", page); + __wt_verbose( + session, WT_VERB_RECONCILE, "page %p empty", (void *)page); WT_STAT_FAST_CONN_INCR(session, rec_page_delete); WT_STAT_FAST_DATA_INCR(session, rec_page_delete); @@ -5699,7 +5705,7 @@ __rec_write_wrapup(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) default: /* Page split */ __wt_verbose(session, WT_VERB_RECONCILE, "page %p reconciled into %" PRIu32 " pages", - page, r->bnd_next); + (void *)page, r->bnd_next); switch (page->type) { case WT_PAGE_COL_INT: @@ -5844,7 +5850,7 @@ __rec_split_row(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) multi->addr = bnd->addr; multi->addr.reuse = 0; multi->size = bnd->size; - multi->cksum = bnd->cksum; + multi->checksum = bnd->checksum; bnd->addr.addr = NULL; } mod->mod_multi_entries = r->bnd_next; @@ -5891,7 +5897,7 @@ __rec_split_col(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) multi->addr = bnd->addr; multi->addr.reuse = 0; multi->size = bnd->size; - multi->cksum = bnd->cksum; + multi->checksum = bnd->checksum; bnd->addr.addr = NULL; } mod->mod_multi_entries = r->bnd_next; diff --git a/src/third_party/wiredtiger/src/schema/schema_create.c b/src/third_party/wiredtiger/src/schema/schema_create.c index f250612d0ae..ed88e687a19 100644 --- a/src/third_party/wiredtiger/src/schema/schema_create.c +++ b/src/third_party/wiredtiger/src/schema/schema_create.c @@ -446,7 +446,7 @@ __create_index(WT_SESSION_IMPL *session, */ npublic_cols = 0; if (!have_extractor) { - WT_ERR(__wt_config_subinit(session, &kcols, &icols)); + __wt_config_subinit(session, &kcols, &icols); while ((ret = __wt_config_next(&kcols, &ckey, &cval)) == 0) ++npublic_cols; WT_ERR_NOTFOUND_OK(ret); @@ -465,7 +465,7 @@ __create_index(WT_SESSION_IMPL *session, * key_format, which we are calculating now, but not part of an index * cursor's key_format. */ - WT_ERR(__wt_config_subinit(session, &pkcols, &table->colconf)); + __wt_config_subinit(session, &pkcols, &table->colconf); for (i = 0; i < table->nkey_columns && (ret = __wt_config_next(&pkcols, &ckey, &cval)) == 0; i++) { @@ -581,7 +581,7 @@ __create_table(WT_SESSION_IMPL *session, WT_ERR_NOTFOUND_OK(ret); WT_ERR(__wt_config_gets(session, cfg, "colgroups", &cval)); - WT_ERR(__wt_config_subinit(session, &conf, &cval)); + __wt_config_subinit(session, &conf, &cval); for (ncolgroups = 0; (ret = __wt_config_next(&conf, &cgkey, &cgval)) == 0; ncolgroups++) diff --git a/src/third_party/wiredtiger/src/schema/schema_open.c b/src/third_party/wiredtiger/src/schema/schema_open.c index 1554d021953..44bd66e011a 100644 --- a/src/third_party/wiredtiger/src/schema/schema_open.c +++ b/src/third_party/wiredtiger/src/schema/schema_open.c @@ -54,7 +54,7 @@ __wt_schema_open_colgroups(WT_SESSION_IMPL *session, WT_TABLE *table) WT_RET(__wt_scr_alloc(session, 0, &buf)); - WT_ERR(__wt_config_subinit(session, &cparser, &table->cgconf)); + __wt_config_subinit(session, &cparser, &table->cgconf); /* Open each column group. */ for (i = 0; i < WT_COLGROUPS(table); i++) { @@ -175,7 +175,7 @@ __open_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx) session, idx->config, "columns", &idx->colconf)); /* Start with the declared index columns. */ - WT_ERR(__wt_config_subinit(session, &colconf, &idx->colconf)); + __wt_config_subinit(session, &colconf, &idx->colconf); for (npublic_cols = 0; (ret = __wt_config_next(&colconf, &ckey, &cval)) == 0; ++npublic_cols) @@ -202,7 +202,7 @@ __open_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx) * Now add any primary key columns from the table that are not * already part of the index key. */ - WT_ERR(__wt_config_subinit(session, &colconf, &table->colconf)); + __wt_config_subinit(session, &colconf, &table->colconf); for (i = 0; i < table->nkey_columns && (ret = __wt_config_next(&colconf, &ckey, &cval)) == 0; i++) { @@ -465,7 +465,7 @@ __schema_open_table(WT_SESSION_IMPL *session, * Count the number of columns: tables are "simple" if the columns * are not named. */ - WT_ERR(__wt_config_subinit(session, &cparser, &table->colconf)); + __wt_config_subinit(session, &cparser, &table->colconf); table->is_simple = true; while ((ret = __wt_config_next(&cparser, &ckey, &cval)) == 0) table->is_simple = false; @@ -482,7 +482,7 @@ __schema_open_table(WT_SESSION_IMPL *session, "colgroups", &table->cgconf)); /* Count the number of column groups. */ - WT_ERR(__wt_config_subinit(session, &cparser, &table->cgconf)); + __wt_config_subinit(session, &cparser, &table->cgconf); table->ncolgroups = 0; while ((ret = __wt_config_next(&cparser, &ckey, &cval)) == 0) ++table->ncolgroups; diff --git a/src/third_party/wiredtiger/src/schema/schema_plan.c b/src/third_party/wiredtiger/src/schema/schema_plan.c index 12a1aa9c22f..475902be887 100644 --- a/src/third_party/wiredtiger/src/schema/schema_plan.c +++ b/src/third_party/wiredtiger/src/schema/schema_plan.c @@ -45,7 +45,7 @@ __find_next_col(WT_SESSION_IMPL *session, WT_TABLE *table, cgcols: cval = colgroup->colconf; col = table->nkey_columns; } - WT_RET(__wt_config_subinit(session, &conf, &cval)); + __wt_config_subinit(session, &conf, &cval); for (; (ret = __wt_config_next(&conf, &k, &v)) == 0; col++) { if (k.len == colname->len && strncmp(colname->str, k.str, k.len) == 0) { @@ -105,7 +105,7 @@ __wt_schema_colcheck(WT_SESSION_IMPL *session, WT_RET_TEST(ret != WT_NOTFOUND, ret); /* Walk through the named columns. */ - WT_RET(__wt_config_subinit(session, &conf, colconf)); + __wt_config_subinit(session, &conf, colconf); for (ncols = 0; (ret = __wt_config_next(&conf, &k, &v)) == 0; ncols++) ; WT_RET_TEST(ret != WT_NOTFOUND, ret); @@ -140,7 +140,7 @@ __wt_table_check(WT_SESSION_IMPL *session, WT_TABLE *table) return (0); /* Walk through the columns. */ - WT_RET(__wt_config_subinit(session, &conf, &table->colconf)); + __wt_config_subinit(session, &conf, &table->colconf); /* Skip over the key columns. */ for (i = 0; i < table->nkey_columns; i++) @@ -186,7 +186,7 @@ __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table, start_cg = start_col = UINT_MAX; /* -Wuninitialized */ /* Work through the value columns by skipping over the key columns. */ - WT_RET(__wt_config_initn(session, &conf, columns, len)); + __wt_config_initn(session, &conf, columns, len); if (value_only) for (i = 0; i < table->nkey_columns; i++) WT_RET(__wt_config_next(&conf, &k, &v)); @@ -281,7 +281,7 @@ __find_column_format(WT_SESSION_IMPL *session, WT_TABLE *table, WT_PACK pack; bool inkey; - WT_RET(__wt_config_subinit(session, &conf, &table->colconf)); + __wt_config_subinit(session, &conf, &table->colconf); WT_RET(__pack_init(session, &pack, table->key_format)); inkey = true; @@ -323,7 +323,7 @@ __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table, WT_DECL_RET; bool have_next; - WT_RET(__wt_config_initn(session, &config, columns, len)); + __wt_config_initn(session, &config, columns, len); /* * If an empty column list is specified, this will fail with * WT_NOTFOUND, that's okay. @@ -331,7 +331,7 @@ __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table, WT_RET_NOTFOUND_OK(ret = __wt_config_next(&config, &next_k, &next_v)); if (ret == WT_NOTFOUND) { if (extra_cols != NULL) { - WT_RET(__wt_config_init(session, &config, extra_cols)); + __wt_config_init(session, &config, extra_cols); WT_RET(__wt_config_next(&config, &next_k, &next_v)); extra_cols = NULL; } else if (format->size == 0) { @@ -347,7 +347,7 @@ __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table, have_next = ret == 0; if (!have_next && extra_cols != NULL) { - WT_RET(__wt_config_init(session, &config, extra_cols)); + __wt_config_init(session, &config, extra_cols); WT_RET(__wt_config_next(&config, &next_k, &next_v)); have_next = true; extra_cols = NULL; diff --git a/src/third_party/wiredtiger/src/schema/schema_stat.c b/src/third_party/wiredtiger/src/schema/schema_stat.c index c204d6b1a24..1cd39d97364 100644 --- a/src/third_party/wiredtiger/src/schema/schema_stat.c +++ b/src/third_party/wiredtiger/src/schema/schema_stat.c @@ -83,7 +83,7 @@ __curstat_size_only(WT_SESSION_IMPL *session, * we determine that neither of those conditions can be satisfied. */ WT_ERR(__wt_config_getones(session, tableconf, "columns", &colconf)); - WT_ERR(__wt_config_subinit(session, &cparser, &colconf)); + __wt_config_subinit(session, &cparser, &colconf); if ((ret = __wt_config_next(&cparser, &ckey, &cval)) == 0) goto err; diff --git a/src/third_party/wiredtiger/src/support/err.c b/src/third_party/wiredtiger/src/support/err.c index 0be428602bc..8bfac250b3a 100644 --- a/src/third_party/wiredtiger/src/support/err.c +++ b/src/third_party/wiredtiger/src/support/err.c @@ -155,6 +155,7 @@ __wt_event_handler_set(WT_SESSION_IMPL *session, WT_EVENT_HANDLER *handler) int __wt_eventv(WT_SESSION_IMPL *session, bool msg_event, int error, const char *file_name, int line_number, const char *fmt, va_list ap) + WT_GCC_FUNC_ATTRIBUTE((cold)) { WT_EVENT_HANDLER *handler; WT_DECL_RET; diff --git a/src/third_party/wiredtiger/src/support/global.c b/src/third_party/wiredtiger/src/support/global.c index 325666b1471..aa69e0db9d6 100644 --- a/src/third_party/wiredtiger/src/support/global.c +++ b/src/third_party/wiredtiger/src/support/global.c @@ -55,7 +55,7 @@ __wt_global_once(void) return; } - __wt_cksum_init(); + __wt_checksum_init(); TAILQ_INIT(&__wt_process.connqh); diff --git a/src/third_party/wiredtiger/src/support/huffman.c b/src/third_party/wiredtiger/src/support/huffman.c index 05612cdbe80..3ec282915ca 100644 --- a/src/third_party/wiredtiger/src/support/huffman.c +++ b/src/third_party/wiredtiger/src/support/huffman.c @@ -560,7 +560,7 @@ __wt_huffman_close(WT_SESSION_IMPL *session, void *huffman_arg) * __wt_print_huffman_code -- * Prints a symbol's Huffman code. */ -int +void __wt_print_huffman_code(void *huffman_arg, uint16_t symbol) { WT_HUFFMAN_CODE code; @@ -583,8 +583,6 @@ __wt_print_huffman_code(void *huffman_arg, uint16_t symbol) "%" PRIx16 ", length %" PRIu8 "\n", symbol, code.pattern, code.length); } - - return (0); } #endif diff --git a/src/third_party/wiredtiger/src/support/stat.c b/src/third_party/wiredtiger/src/support/stat.c index 8927be862c1..81859ef1ca8 100644 --- a/src/third_party/wiredtiger/src/support/stat.c +++ b/src/third_party/wiredtiger/src/support/stat.c @@ -562,7 +562,6 @@ static const char * const __stats_connection_desc[] = { "cache: eviction server candidate queue empty when topping up", "cache: eviction server candidate queue not empty when topping up", "cache: eviction server evicting pages", - "cache: eviction server skipped very large page", "cache: eviction server slept, because we did not make progress with eviction", "cache: eviction server unable to reach eviction goal", "cache: eviction state", @@ -805,7 +804,6 @@ __wt_stat_connection_clear_single(WT_CONNECTION_STATS *stats) stats->cache_eviction_queue_empty = 0; stats->cache_eviction_queue_not_empty = 0; stats->cache_eviction_server_evicting = 0; - stats->cache_eviction_server_toobig = 0; stats->cache_eviction_server_slept = 0; stats->cache_eviction_slow = 0; /* not clearing cache_eviction_state */ @@ -1049,8 +1047,6 @@ __wt_stat_connection_aggregate( WT_STAT_READ(from, cache_eviction_queue_not_empty); to->cache_eviction_server_evicting += WT_STAT_READ(from, cache_eviction_server_evicting); - to->cache_eviction_server_toobig += - WT_STAT_READ(from, cache_eviction_server_toobig); to->cache_eviction_server_slept += WT_STAT_READ(from, cache_eviction_server_slept); to->cache_eviction_slow += WT_STAT_READ(from, cache_eviction_slow); diff --git a/src/third_party/wiredtiger/src/support/thread_group.c b/src/third_party/wiredtiger/src/support/thread_group.c index 016956c527f..f5ddabad7d4 100644 --- a/src/third_party/wiredtiger/src/support/thread_group.c +++ b/src/third_party/wiredtiger/src/support/thread_group.c @@ -61,7 +61,7 @@ __thread_group_grow( thread = group->threads[group->current_threads++]; __wt_verbose(session, WT_VERB_THREAD_GROUP, "Starting utility thread: %p:%"PRIu32"\n", - group, thread->id); + (void *)group, thread->id); F_SET(thread, WT_THREAD_RUN); WT_ASSERT(session, thread->session != NULL); WT_RET(__wt_thread_create(thread->session, @@ -101,7 +101,7 @@ __thread_group_shrink(WT_SESSION_IMPL *session, if (thread->tid != 0) { __wt_verbose(session, WT_VERB_THREAD_GROUP, "Stopping utility thread: %p:%"PRIu32"\n", - group, thread->id); + (void *)group, thread->id); F_CLR(thread, WT_THREAD_RUN); __wt_cond_signal(session, group->wait_cond); WT_TRET(__wt_thread_join(session, thread->tid)); @@ -206,8 +206,7 @@ err: /* */ if (ret != 0) { WT_TRET(__wt_thread_group_destroy(session, group)); - WT_PANIC_RET(session, ret, - "Error while resizing thread group"); + WT_PANIC_RET(session, ret, "Error while resizing thread group"); } return (ret); } @@ -226,11 +225,10 @@ __wt_thread_group_resize( __wt_verbose(session, WT_VERB_THREAD_GROUP, "Resize thread group: %p, from min: %" PRIu32 " -> %" PRIu32 " from max: %" PRIu32 " -> %" PRIu32 "\n", - group, group->min, new_min, group->max, new_max); + (void *)group, group->min, new_min, group->max, new_max); __wt_writelock(session, group->lock); - WT_TRET(__thread_group_resize( - session, group, new_min, new_max, flags)); + WT_TRET(__thread_group_resize(session, group, new_min, new_max, flags)); __wt_writeunlock(session, group->lock); return (ret); } @@ -255,7 +253,7 @@ __wt_thread_group_create( cond_alloced = false; __wt_verbose(session, WT_VERB_THREAD_GROUP, - "Creating thread group: %p\n", group); + "Creating thread group: %p\n", (void *)group); WT_RET(__wt_rwlock_alloc(session, &group->lock, "Thread group")); WT_ERR(__wt_cond_alloc( @@ -283,16 +281,14 @@ err: if (ret != 0) { * Shut down a thread group. Our caller must hold the lock. */ int -__wt_thread_group_destroy( - WT_SESSION_IMPL *session, WT_THREAD_GROUP *group) +__wt_thread_group_destroy(WT_SESSION_IMPL *session, WT_THREAD_GROUP *group) { WT_DECL_RET; __wt_verbose(session, WT_VERB_THREAD_GROUP, - "Destroying thread group: %p\n", group); + "Destroying thread group: %p\n", (void *)group); - WT_ASSERT(session, - __wt_rwlock_islocked(session, group->lock)); + WT_ASSERT(session, __wt_rwlock_islocked(session, group->lock)); /* Shut down all threads and free associated resources. */ WT_TRET(__thread_group_shrink(session, group, 0)); diff --git a/src/third_party/wiredtiger/src/txn/txn_ckpt.c b/src/third_party/wiredtiger/src/txn/txn_ckpt.c index 5406367c372..91cee92b862 100644 --- a/src/third_party/wiredtiger/src/txn/txn_ckpt.c +++ b/src/third_party/wiredtiger/src/txn/txn_ckpt.c @@ -113,7 +113,7 @@ __checkpoint_apply_all(WT_SESSION_IMPL *session, const char *cfg[], /* Step through the targets and optionally operate on each one. */ WT_ERR(__wt_config_gets(session, cfg, "target", &cval)); - WT_ERR(__wt_config_subinit(session, &targetconf, &cval)); + __wt_config_subinit(session, &targetconf, &cval); while ((ret = __wt_config_next(&targetconf, &k, &v)) == 0) { if (!target_list) { WT_ERR(__wt_scr_alloc(session, 512, &tmp)); @@ -320,14 +320,20 @@ __checkpoint_reduce_dirty_cache(WT_SESSION_IMPL *session) WT_CACHE *cache; WT_CONNECTION_IMPL *conn; struct timespec start, last, stop; - u_int current_dirty; + double current_dirty, delta; uint64_t bytes_written_last, bytes_written_start, bytes_written_total; - uint64_t cache_size, current_us, stepdown_us, total_ms; + uint64_t cache_size, max_write; + uint64_t current_us, stepdown_us, total_ms, work_us; bool progress; conn = S2C(session); cache = conn->cache; + /* Give up if scrubbing is disabled. */ + if (cache->eviction_checkpoint_target == 0 || + cache->eviction_checkpoint_target >= cache->eviction_dirty_trigger) + return (0); + WT_RET(__wt_epoch(session, &start)); last = start; bytes_written_last = 0; @@ -338,75 +344,89 @@ __checkpoint_reduce_dirty_cache(WT_SESSION_IMPL *session) * size can briefly become zero if we're transitioning to a shared * cache via reconfigure. This avoids potential divide by zero. */ - if (cache_size < (WT_MEGABYTE * 5)) + if (cache_size < 10 * WT_MEGABYTE) return (0); stepdown_us = 10000; + work_us = 0; progress = false; + /* Step down the scrub target (as a percentage) in units of 10MB. */ + delta = WT_MIN(1.0, (100 * 10.0 * WT_MEGABYTE) / cache_size); + + /* + * Start with the scrub target equal to the expected maximum percentage + * of dirty data in cache. + */ + cache->eviction_scrub_limit = cache->eviction_dirty_trigger; + + /* Stop if we write as much dirty data as is currently in cache. */ + max_write = __wt_cache_dirty_leaf_inuse(cache); + /* Step down the dirty target to the eviction trigger */ for (;;) { - current_dirty = (u_int)((100 * - __wt_cache_dirty_leaf_inuse(cache)) / cache_size); - if (current_dirty <= cache->eviction_dirty_target) + current_dirty = + (100.0 * __wt_cache_dirty_leaf_inuse(cache)) / cache_size; + if (current_dirty <= + (double)cache->eviction_checkpoint_target) break; - __wt_sleep(0, stepdown_us / 4); + __wt_sleep(0, stepdown_us / 10); WT_RET(__wt_epoch(session, &stop)); current_us = WT_TIMEDIFF_US(stop, last); total_ms = WT_TIMEDIFF_MS(stop, start); bytes_written_total = cache->bytes_written - bytes_written_start; + if (current_dirty > cache->eviction_scrub_limit) { + /* + * We haven't reached the current target. + * + * Don't wait indefinitely: there might be dirty pages + * that can't be evicted. If we can't meet the target, + * give up and start the checkpoint for real. + */ + if (current_us > WT_MAX(WT_MILLION, 10 * stepdown_us) || + bytes_written_total > max_write) + break; + continue; + } + /* - * Estimate how long the next step down of 1% of dirty data - * should take. + * Estimate how long the next step down of dirty data should + * take. * * The calculation here assumes that the system is writing from * cache as fast as it can, and determines the write throughput * based on the change in the bytes written from cache since * the start of the call. We use that to estimate how long it - * will take to step the dirty target down by 1%. + * will take to step the dirty target down by delta. * * Take care to avoid dividing by zero. */ if (bytes_written_total - bytes_written_last > WT_MEGABYTE && - bytes_written_total > total_ms && total_ms > 0 && - (!progress || - current_dirty <= cache->eviction_dirty_trigger)) { - stepdown_us = (uint64_t)(WT_THOUSAND * ( - (double)(cache_size / 100) / - (double)(bytes_written_total / total_ms))); + work_us > 0) { + stepdown_us = (uint64_t)((delta * cache_size / 100) / + ((double)bytes_written_total / work_us)); + stepdown_us = WT_MAX(1, stepdown_us); if (!progress) stepdown_us = WT_MIN(stepdown_us, 200000); - } - - bytes_written_last = bytes_written_total; - - if (current_dirty <= cache->eviction_dirty_trigger) { progress = true; - /* - * Smooth out step down: try to limit the impact on - * performance to 10% by waiting once we reach the last - * level. - */ - __wt_sleep(0, 10 * stepdown_us); - cache->eviction_dirty_trigger = current_dirty - 1; - WT_STAT_FAST_CONN_SET(session, - txn_checkpoint_scrub_target, current_dirty - 1); - WT_RET(__wt_epoch(session, &last)); - continue; + bytes_written_last = bytes_written_total; } + work_us += current_us; + /* - * We haven't reached the current target. - * - * Don't wait indefinitely: there might be dirty pages that - * can't be evicted. If we can't meet the target, give up - * and start the checkpoint for real. + * Smooth out step down: try to limit the impact on + * performance to 10% by waiting once we reach the last + * level. */ - if (current_us > 10 * stepdown_us) - break; + __wt_sleep(0, 10 * stepdown_us); + cache->eviction_scrub_limit = current_dirty - delta; + WT_STAT_FAST_CONN_SET(session, txn_checkpoint_scrub_target, + cache->eviction_scrub_limit); + WT_RET(__wt_epoch(session, &last)); } WT_RET(__wt_epoch(session, &stop)); @@ -525,7 +545,7 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) WT_TXN_ISOLATION saved_isolation; WT_TXN_STATE *txn_state; void *saved_meta_next; - u_int i, orig_trigger; + u_int i; uint64_t fsync_duration_usecs; bool full, idle, logging, tracking; const char *txn_cfg[] = { WT_CONFIG_BASE(session, @@ -533,7 +553,6 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) conn = S2C(session); cache = conn->cache; - orig_trigger = cache->eviction_dirty_trigger; txn = &session->txn; txn_global = &conn->txn_global; txn_state = WT_SESSION_TXN_STATE(session); @@ -685,9 +704,8 @@ __txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) * Unblock updates -- we can figure out that any updates to clean pages * after this point are too new to be written in the checkpoint. */ - cache->eviction_dirty_trigger = orig_trigger; - WT_STAT_FAST_CONN_SET( - session, txn_checkpoint_scrub_target, orig_trigger); + cache->eviction_scrub_limit = 0.0; + WT_STAT_FAST_CONN_SET(session, txn_checkpoint_scrub_target, 0); /* * Mark old checkpoints that are being deleted and figure out which @@ -810,9 +828,8 @@ err: /* if (tracking) WT_TRET(__wt_meta_track_off(session, false, ret != 0)); - cache->eviction_dirty_trigger = orig_trigger; - WT_STAT_FAST_CONN_SET( - session, txn_checkpoint_scrub_target, orig_trigger); + cache->eviction_scrub_limit = 0.0; + WT_STAT_FAST_CONN_SET(session, txn_checkpoint_scrub_target, 0); if (F_ISSET(txn, WT_TXN_RUNNING)) { /* @@ -1054,7 +1071,7 @@ __checkpoint_lock_tree(WT_SESSION_IMPL *session, cval.len = 0; WT_ERR(__wt_config_gets(session, cfg, "drop", &cval)); if (cval.len != 0) { - WT_ERR(__wt_config_subinit(session, &dropconf, &cval)); + __wt_config_subinit(session, &dropconf, &cval); while ((ret = __wt_config_next(&dropconf, &k, &v)) == 0) { /* Disallow unsafe checkpoint names. */ diff --git a/src/third_party/wiredtiger/src/txn/txn_log.c b/src/third_party/wiredtiger/src/txn/txn_log.c index c7d83d1db64..f9dd9bee807 100644 --- a/src/third_party/wiredtiger/src/txn/txn_log.c +++ b/src/third_party/wiredtiger/src/txn/txn_log.c @@ -450,11 +450,10 @@ __wt_txn_truncate_log( * __wt_txn_truncate_end -- * Finish truncating a range of a file. */ -int +void __wt_txn_truncate_end(WT_SESSION_IMPL *session) { F_CLR(session, WT_SESSION_LOGGING_INMEM); - return (0); } /* diff --git a/src/third_party/wiredtiger/src/txn/txn_nsnap.c b/src/third_party/wiredtiger/src/txn/txn_nsnap.c index 05c45c0dc38..d0110d9edd8 100644 --- a/src/third_party/wiredtiger/src/txn/txn_nsnap.c +++ b/src/third_party/wiredtiger/src/txn/txn_nsnap.c @@ -220,8 +220,7 @@ __wt_txn_named_snapshot_drop(WT_SESSION_IMPL *session, const char *cfg[]) /* We are done if there are no named drops */ if (names_config.len != 0) { - WT_RET(__wt_config_subinit( - session, &objectconf, &names_config)); + __wt_config_subinit(session, &objectconf, &names_config); while ((ret = __wt_config_next(&objectconf, &k, &v)) == 0) { ret = __nsnap_drop_one(session, &k); if (ret != 0) @@ -352,7 +351,7 @@ __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, * __wt_txn_named_snapshot_destroy -- * Destroy all named snapshots on connection close */ -int +void __wt_txn_named_snapshot_destroy(WT_SESSION_IMPL *session) { WT_NAMED_SNAPSHOT *nsnap; @@ -365,6 +364,4 @@ __wt_txn_named_snapshot_destroy(WT_SESSION_IMPL *session) TAILQ_REMOVE(&txn_global->nsnaph, nsnap, q); __nsnap_destroy(session, nsnap); } - - return (0); } diff --git a/src/third_party/wiredtiger/src/utilities/util_list.c b/src/third_party/wiredtiger/src/utilities/util_list.c index 57062b9e9b5..e91dbfce05b 100644 --- a/src/third_party/wiredtiger/src/utilities/util_list.c +++ b/src/third_party/wiredtiger/src/utilities/util_list.c @@ -238,7 +238,7 @@ list_print_checkpoint(WT_SESSION *session, const char *key) ci.root_size, ci.root_size); printf("\t\t" "root checksum: %" PRIu32 " (0x%" PRIx32 ")\n", - ci.root_cksum, ci.root_cksum); + ci.root_checksum, ci.root_checksum); } } diff --git a/src/third_party/wiredtiger/test/bloom/test_bloom.c b/src/third_party/wiredtiger/test/bloom/test_bloom.c index 9a7584f951f..7a298f000aa 100644 --- a/src/third_party/wiredtiger/test/bloom/test_bloom.c +++ b/src/third_party/wiredtiger/test/bloom/test_bloom.c @@ -160,8 +160,7 @@ run(void) item.size = g.c_key_max; for (i = 0; i < g.c_ops; i++) { item.data = g.entries[i]; - if ((ret = __wt_bloom_insert(bloomp, &item)) != 0) - testutil_die(ret, "__wt_bloom_insert: %" PRIu32, i); + __wt_bloom_insert(bloomp, &item); } testutil_check(__wt_bloom_finalize(bloomp)); diff --git a/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c b/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c index 6293d36f916..6b2f0d4466c 100644 --- a/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c +++ b/src/third_party/wiredtiger/test/checkpoint/test_checkpoint.c @@ -34,7 +34,7 @@ static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *); static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *); static void onint(int) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn)); -static int cleanup(void); +static void cleanup(void); static int usage(void); static int wt_connect(const char *); static int wt_shutdown(void); @@ -139,7 +139,7 @@ main(int argc, char *argv[]) printf(" %d: %d workers, %d tables\n", cnt, g.nworkers, g.ntables); - (void)cleanup(); /* Clean up previous runs */ + cleanup(); /* Clean up previous runs */ /* Setup a fresh set of cookies in the global array. */ if ((g.cookies = calloc( @@ -240,14 +240,13 @@ wt_shutdown(void) * cleanup -- * Clean up from previous runs. */ -static int +static void cleanup(void) { g.running = 0; g.ntables_created = 0; testutil_clean_work_dir(g.home); - return (0); } static int @@ -283,7 +282,7 @@ onint(int signo) { WT_UNUSED(signo); - (void)cleanup(); + cleanup(); fprintf(stderr, "\n"); exit(EXIT_FAILURE); diff --git a/src/third_party/wiredtiger/test/csuite/Makefile.am b/src/third_party/wiredtiger/test/csuite/Makefile.am index 097468f0e85..15db2fbcf46 100644 --- a/src/third_party/wiredtiger/test/csuite/Makefile.am +++ b/src/third_party/wiredtiger/test/csuite/Makefile.am @@ -1,6 +1,5 @@ AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/src/include \ - -I$(top_srcdir)/test/utility \ - -DCRC_PATH="\"$(top_srcdir)/src/checksum/x86/checksum.c\"" + -I$(top_srcdir)/test/utility LDADD = $(top_builddir)/test/utility/libtest_util.la \ $(top_builddir)/libwiredtiger.la AM_LDFLAGS = -static @@ -11,13 +10,16 @@ noinst_PROGRAMS = test_wt1965_col_efficiency test_wt2246_col_append_SOURCES = wt2246_col_append/main.c noinst_PROGRAMS += test_wt2246_col_append +test_wt2323_join_visibility_SOURCES = wt2323_join_visibility/main.c +noinst_PROGRAMS += test_wt2323_join_visibility + test_wt2535_insert_race_SOURCES = wt2535_insert_race/main.c noinst_PROGRAMS += test_wt2535_insert_race test_wt2447_join_main_table_SOURCES = wt2447_join_main_table/main.c noinst_PROGRAMS += test_wt2447_join_main_table -test_wt2695_checksum_SOURCES = wt2695_checksum/main.c wt2695_checksum/sw.c +test_wt2695_checksum_SOURCES = wt2695_checksum/main.c noinst_PROGRAMS += test_wt2695_checksum test_wt2592_join_schema_SOURCES = wt2592_join_schema/main.c diff --git a/src/third_party/wiredtiger/test/csuite/wt2323_join_visibility/main.c b/src/third_party/wiredtiger/test/csuite/wt2323_join_visibility/main.c new file mode 100644 index 00000000000..bbf1626fe82 --- /dev/null +++ b/src/third_party/wiredtiger/test/csuite/wt2323_join_visibility/main.c @@ -0,0 +1,402 @@ +/*- + * Public Domain 2014-2016 MongoDB, Inc. + * Public Domain 2008-2014 WiredTiger, Inc. + * + * This is free and unencumbered software released into the public domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#include "test_util.h" + +/* + * JIRA ticket reference: WT-2323 + * + * Test case description: We create two kinds of threads that race: One kind + * is populating/updating records in a table with a few indices, the other + * is reading from a join of that table. The hope in constructing this test + * was to have the updates interleaved between reads of multiple indices by + * the join, yielding an inconsistent view of the data. In the main table, + * we insert account records, with a positive or negative balance. The + * negative balance accounts always have a flag set to non-zero, positive + * balances have the flag set to zero. The join we do is: + * + * select (*) from account where account.postal_code = '54321' and + * account.balance < 0 and account.flags == 0 + * + * which should always yield no results. + * + * Failure mode: This test never actually failed with any combination of + * parameters, with N_INSERT up to 50000000. It seems that a snapshot is + * implicitly allocated in the session used by a join by the set_key calls + * that occur before the first 'next' of the join cursor is done. Despite + * that, the test seems interesting enough to keep around, with the number + * of inserts set low as a default. + */ + +void (*custom_die)(void) = NULL; + +#define N_RECORDS 10000 +#define N_INSERT 500000 +#define N_INSERT_THREAD 2 +#define N_JOIN_THREAD 2 +#define S64 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789::" +#define S1024 (S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64 S64) + +typedef struct { + char posturi[256]; + char baluri[256]; + char flaguri[256]; + char joinuri[256]; + bool bloom; + bool remove; +} SHARED_OPTS; + +typedef struct { + TEST_OPTS *testopts; + SHARED_OPTS *sharedopts; + int threadnum; + int nthread; + int done; + int joins; + int removes; + int inserts; + int notfounds; + int rollbacks; +} THREAD_ARGS; + +static void *thread_insert(void *); +static void *thread_join(void *); +static void test_join(TEST_OPTS *, SHARED_OPTS *, bool, bool); + +int +main(int argc, char *argv[]) +{ + SHARED_OPTS *sharedopts, _sharedopts; + TEST_OPTS *opts, _opts; + const char *tablename; + + opts = &_opts; + sharedopts = &_sharedopts; + memset(opts, 0, sizeof(*opts)); + memset(sharedopts, 0, sizeof(*sharedopts)); + + testutil_check(testutil_parse_opts(argc, argv, opts)); + testutil_make_work_dir(opts->home); + + tablename = strchr(opts->uri, ':'); + testutil_assert(tablename != NULL); + tablename++; + snprintf(sharedopts->posturi, sizeof(sharedopts->posturi), + "index:%s:post", tablename); + snprintf(sharedopts->baluri, sizeof(sharedopts->baluri), + "index:%s:bal", tablename); + snprintf(sharedopts->flaguri, sizeof(sharedopts->flaguri), + "index:%s:flag", tablename); + snprintf(sharedopts->joinuri, sizeof(sharedopts->joinuri), + "join:%s", opts->uri); + + testutil_check(wiredtiger_open(opts->home, NULL, + "create,cache_size=1G", &opts->conn)); + + test_join(opts, sharedopts, true, true); + test_join(opts, sharedopts, true, false); + test_join(opts, sharedopts, false, true); + test_join(opts, sharedopts, false, false); + + testutil_cleanup(opts); + + return (0); +} + +static void +test_join(TEST_OPTS *opts, SHARED_OPTS *sharedopts, bool bloom, + bool sometimes_remove) +{ + THREAD_ARGS insert_args[N_INSERT_THREAD], join_args[N_JOIN_THREAD]; + WT_CURSOR *maincur; + WT_SESSION *session; + pthread_t insert_tid[N_INSERT_THREAD], join_tid[N_JOIN_THREAD]; + int i; + + memset(insert_args, 0, sizeof(insert_args)); + memset(join_args, 0, sizeof(join_args)); + + sharedopts->bloom = bloom; + sharedopts->remove = sometimes_remove; + + fprintf(stderr, "Running with bloom=%d, remove=%d\n", + (int)bloom, (int)sometimes_remove); + + testutil_check( + opts->conn->open_session(opts->conn, NULL, NULL, &session)); + + /* + * Note: id is repeated as id2. This makes it easier to + * identify the primary key in dumps of the index files. + */ + testutil_check(session->create(session, opts->uri, + "key_format=i,value_format=iiSii," + "columns=(id,post,bal,extra,flag,id2)")); + + testutil_check(session->create(session, sharedopts->posturi, + "columns=(post)")); + testutil_check(session->create(session, sharedopts->baluri, + "columns=(bal)")); + testutil_check(session->create(session, sharedopts->flaguri, + "columns=(flag)")); + + /* + * Insert a single record with all items we need to + * call search() on, this makes our join logic easier. + */ + testutil_check(session->open_cursor(session, opts->uri, NULL, NULL, + &maincur)); + maincur->set_key(maincur, N_RECORDS); + maincur->set_value(maincur, 54321, 0, "", 0, N_RECORDS); + testutil_check(maincur->insert(maincur)); + testutil_check(maincur->close(maincur)); + + for (i = 0; i < N_INSERT_THREAD; ++i) { + insert_args[i].threadnum = i; + insert_args[i].nthread = N_INSERT_THREAD; + insert_args[i].testopts = opts; + insert_args[i].sharedopts = sharedopts; + testutil_check(pthread_create(&insert_tid[i], NULL, + thread_insert, (void *)&insert_args[i])); + } + + for (i = 0; i < N_JOIN_THREAD; ++i) { + join_args[i].threadnum = i; + join_args[i].nthread = N_JOIN_THREAD; + join_args[i].testopts = opts; + join_args[i].sharedopts = sharedopts; + testutil_check(pthread_create(&join_tid[i], NULL, + thread_join, (void *)&join_args[i])); + } + + /* + * Wait for insert threads to finish. When they + * are done, signal join threads to complete. + */ + for (i = 0; i < N_INSERT_THREAD; ++i) + testutil_check(pthread_join(insert_tid[i], NULL)); + + for (i = 0; i < N_JOIN_THREAD; ++i) + join_args[i].done = 1; + + for (i = 0; i < N_JOIN_THREAD; ++i) + testutil_check(pthread_join(join_tid[i], NULL)); + + fprintf(stderr, "\n"); + for (i = 0; i < N_JOIN_THREAD; ++i) { + fprintf(stderr, " join thread %d did %d joins\n", + i, join_args[i].joins); + } + for (i = 0; i < N_INSERT_THREAD; ++i) + fprintf(stderr, + " insert thread %d did " + "%d inserts, %d removes, %d notfound, %d rollbacks\n", + i, insert_args[i].inserts, insert_args[i].removes, + insert_args[i].notfounds, insert_args[i].rollbacks); + + testutil_check(session->drop(session, sharedopts->posturi, NULL)); + testutil_check(session->drop(session, sharedopts->baluri, NULL)); + testutil_check(session->drop(session, sharedopts->flaguri, NULL)); + testutil_check(session->drop(session, opts->uri, NULL)); + testutil_check(session->close(session, NULL)); +} + +static void *thread_insert(void *arg) +{ + SHARED_OPTS *sharedopts; + TEST_OPTS *opts; + THREAD_ARGS *threadargs; + WT_CURSOR *maincur; + WT_RAND_STATE rnd; + WT_SESSION *session; + int bal, i, flag, key, post, ret; + const char *extra = S1024; + + threadargs = (THREAD_ARGS *)arg; + opts = threadargs->testopts; + sharedopts = threadargs->sharedopts; + testutil_check(__wt_random_init_seed(NULL, &rnd)); + + testutil_check(opts->conn->open_session( + opts->conn, NULL, NULL, &session)); + + testutil_check(session->open_cursor(session, opts->uri, NULL, NULL, + &maincur)); + + for (i = 0; i < N_INSERT; i++) { + /* + * Insert threads may stomp on each other's records; + * that's okay. + */ + key = (int)(__wt_random(&rnd) % N_RECORDS); + maincur->set_key(maincur, key); + if (sharedopts->remove) + testutil_check(session->begin_transaction(session, + "isolation=snapshot")); + if (sharedopts->remove && __wt_random(&rnd) % 5 == 0 && + maincur->search(maincur) == 0) { + /* + * Another thread can be removing at the + * same time. + */ + ret = maincur->remove(maincur); + testutil_assert(ret == 0 || + (N_INSERT_THREAD > 1 && + (ret == WT_NOTFOUND || ret == WT_ROLLBACK))); + if (ret == 0) + threadargs->removes++; + else if (ret == WT_NOTFOUND) + threadargs->notfounds++; + else if (ret == WT_ROLLBACK) + threadargs->rollbacks++; + } else { + if (__wt_random(&rnd) % 2 == 0) + post = 54321; + else + post = i % 100000; + if (__wt_random(&rnd) % 2 == 0) { + bal = -100; + flag = 1; + } else { + bal = 1 + (i % 1000) * 100; + flag = 0; + } + maincur->set_value(maincur, post, bal, extra, flag, + key); + ret = maincur->insert(maincur); + testutil_assert(ret == 0 || + (N_INSERT_THREAD > 1 && ret == WT_ROLLBACK)); + testutil_check(maincur->reset(maincur)); + if (ret == 0) + threadargs->inserts++; + else if (ret == WT_ROLLBACK) + threadargs->rollbacks++; + } + if (sharedopts->remove) + testutil_check(session->commit_transaction(session, + NULL)); + if (i % 1000 == 0 && i != 0) { + if (i % 10000 == 0) + fprintf(stderr, "*"); + else + fprintf(stderr, "."); + } + } + testutil_check(maincur->close(maincur)); + testutil_check(session->close(session, NULL)); + return (NULL); +} + +static void *thread_join(void *arg) +{ + SHARED_OPTS *sharedopts; + TEST_OPTS *opts; + THREAD_ARGS *threadargs; + WT_CURSOR *postcur, *balcur, *flagcur, *joincur; + WT_SESSION *session; + int bal, flag, key, key2, post, ret; + char cfg[128]; + char *extra; + + threadargs = (THREAD_ARGS *)arg; + opts = threadargs->testopts; + sharedopts = threadargs->sharedopts; + + testutil_check(opts->conn->open_session( + opts->conn, NULL, NULL, &session)); + + testutil_check(session->open_cursor( + session, sharedopts->posturi, NULL, NULL, &postcur)); + testutil_check(session->open_cursor( + session, sharedopts->baluri, NULL, NULL, &balcur)); + testutil_check(session->open_cursor( + session, sharedopts->flaguri, NULL, NULL, &flagcur)); + + for (threadargs->joins = 0; threadargs->done == 0; + threadargs->joins++) { + testutil_check(session->open_cursor( + session, sharedopts->joinuri, NULL, NULL, &joincur)); + postcur->set_key(postcur, 54321); + testutil_check(postcur->search(postcur)); + testutil_check(session->join(session, joincur, postcur, + "compare=eq")); + + balcur->set_key(balcur, 0); + testutil_check(balcur->search(balcur)); + if (sharedopts->bloom) + sprintf(cfg, "compare=lt,strategy=bloom,count=%d", + N_RECORDS); + else + sprintf(cfg, "compare=lt"); + testutil_check(session->join(session, joincur, balcur, cfg)); + + flagcur->set_key(flagcur, 0); + testutil_check(flagcur->search(flagcur)); + if (sharedopts->bloom) + sprintf(cfg, "compare=eq,strategy=bloom,count=%d", + N_RECORDS); + else + sprintf(cfg, "compare=eq"); + testutil_check(session->join(session, joincur, flagcur, cfg)); + + /* Expect no values returned */ + ret = joincur->next(joincur); + if (ret == 0) { + /* + * The values may already have been changed, but + * print them for informational purposes. + */ + testutil_check(joincur->get_key(joincur, &key)); + testutil_check(joincur->get_value(joincur, &post, + &bal, &extra, &flag, &key2)); + fprintf(stderr, "FAIL: iteration %d: " + "key=%d/%d, postal_code=%d, balance=%d, flag=%d\n", + threadargs->joins, key, key2, post, bal, flag); + /* Save the results. */ + testutil_check(opts->conn->close(opts->conn, NULL)); + opts->conn = NULL; + return (NULL); + } + testutil_assert(ret == WT_NOTFOUND); + testutil_check(joincur->close(joincur)); + + /* + * Reset the cursors, potentially allowing the insert + * threads to proceed. + */ + testutil_check(postcur->reset(postcur)); + testutil_check(balcur->reset(balcur)); + testutil_check(flagcur->reset(flagcur)); + if (threadargs->joins % 100 == 0) + fprintf(stderr, "J"); + } + testutil_check(postcur->close(postcur)); + testutil_check(balcur->close(balcur)); + testutil_check(flagcur->close(flagcur)); + testutil_check(session->close(session, NULL)); + return (NULL); +} diff --git a/src/third_party/wiredtiger/test/csuite/wt2695_checksum/main.c b/src/third_party/wiredtiger/test/csuite/wt2695_checksum/main.c index dc6f5b5cd87..df6f562f719 100644 --- a/src/third_party/wiredtiger/test/csuite/wt2695_checksum/main.c +++ b/src/third_party/wiredtiger/test/csuite/wt2695_checksum/main.c @@ -34,8 +34,6 @@ void (*custom_die)(void) = NULL; -uint32_t cksum_sw(const void *, size_t); - static inline void check(uint32_t hw, uint32_t sw, size_t len, const char *msg) { @@ -61,57 +59,66 @@ main(void) testutil_check(__wt_random_init_seed(NULL, &rnd)); /* Initialize the WiredTiger library checksum functions. */ - __wt_cksum_init(); + __wt_checksum_init(); /* * Some simple known checksums. */ len = 1; - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0x527d5351, len, "nul x1: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0x527d5351, len, "nul x1: software"); len = 2; - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0xf16177d2, len, "nul x2: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0xf16177d2, len, "nul x2: software"); len = 3; - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0x6064a37a, len, "nul x3: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0x6064a37a, len, "nul x3: software"); len = 4; - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0x48674bc7, len, "nul x4: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0x48674bc7, len, "nul x4: software"); len = strlen("123456789"); memcpy(data, "123456789", len); - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0xe3069283, len, "known string #1: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0xe3069283, len, "known string #1: software"); len = strlen("The quick brown fox jumps over the lazy dog"); memcpy(data, "The quick brown fox jumps over the lazy dog", len); - hw = __wt_cksum(data, len); + hw = __wt_checksum(data, len); check(hw, (uint32_t)0x22620404, len, "known string #2: hardware"); - sw = cksum_sw(data, len); + sw = __wt_checksum_sw(data, len); check(sw, (uint32_t)0x22620404, len, "known string #2: software"); /* + * Offset the string by 1 to ensure the hardware code handles unaligned + * reads. + */ + hw = __wt_checksum(data + 1, len - 1); + check(hw, (uint32_t)0xae11f7f5, len, "known string #2: hardware"); + sw = __wt_checksum_sw(data + 1, len - 1); + check(sw, (uint32_t)0xae11f7f5, len, "known string #2: software"); + + /* * Checksums of power-of-two data chunks. */ for (i = 0, len = 512; i < 1000; ++i) { for (j = 0; j < len; ++j) data[j] = __wt_random(&rnd) & 0xff; - hw = __wt_cksum(data, len); - sw = cksum_sw(data, len); + hw = __wt_checksum(data, len); + sw = __wt_checksum_sw(data, len); check(hw, sw, len, "random power-of-two"); len *= 2; @@ -126,8 +133,8 @@ main(void) len = __wt_random(&rnd) % DATASIZE; for (j = 0; j < len; ++j) data[j] = __wt_random(&rnd) & 0xff; - hw = __wt_cksum(data, len); - sw = cksum_sw(data, len); + hw = __wt_checksum(data, len); + sw = __wt_checksum_sw(data, len); check(hw, sw, len, "random"); } diff --git a/src/third_party/wiredtiger/test/csuite/wt2695_checksum/sw.c b/src/third_party/wiredtiger/test/csuite/wt2695_checksum/sw.c deleted file mode 100644 index 892d9480bf3..00000000000 --- a/src/third_party/wiredtiger/test/csuite/wt2695_checksum/sw.c +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * Public Domain 2014-2016 MongoDB, Inc. - * Public Domain 2008-2014 WiredTiger, Inc. - * - * This is free and unencumbered software released into the public domain. - * - * Anyone is free to copy, modify, publish, use, compile, sell, or - * distribute this software, either in source code form or as a compiled - * binary, for any purpose, commercial or non-commercial, and by any - * means. - * - * In jurisdictions that recognize copyright laws, the author or authors - * of this software dedicate any and all copyright interest in the - * software to the public domain. We make this dedication for the benefit - * of the public at large and to the detriment of our heirs and - * successors. We intend this dedication to be an overt act of - * relinquishment in perpetuity of all present and future rights to this - * software under copyright law. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ -#include "test_util.h" - -/* - * Build the software version of the CRC code. - */ -#define __wt_cksum __wt_cksum_notused -uint32_t __wt_cksum_notused(const void *, size_t); -#define __wt_cksum_init __wt_cksum_init_notused -void __wt_cksum_init_notused(void); - -#include CRC_PATH - -/* - * cksum_sw -- - * Checksum in software. - */ -uint32_t cksum_sw(const void *, size_t); -uint32_t -cksum_sw(const void *chunk, size_t len) -{ - return (__wt_cksum_sw(chunk, len)); -} diff --git a/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c b/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c index c57d5ba056c..67ba4a20ada 100644 --- a/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c +++ b/src/third_party/wiredtiger/test/csuite/wt2853_perf/main.c @@ -86,6 +86,9 @@ main(int argc, char *argv[]) opts = &_opts; sharedopts = &_sharedopts; + + if (testutil_disable_long_tests()) + return (0); memset(opts, 0, sizeof(*opts)); memset(sharedopts, 0, sizeof(*sharedopts)); memset(insert_args, 0, sizeof(insert_args)); @@ -183,7 +186,8 @@ main(int argc, char *argv[]) return (0); } -static void *thread_insert(void *arg) +static void * +thread_insert(void *arg) { TEST_OPTS *opts; THREAD_ARGS *threadargs; @@ -249,7 +253,8 @@ static void *thread_insert(void *arg) return (NULL); } -static void *thread_get(void *arg) +static void * +thread_get(void *arg) { SHARED_OPTS *sharedopts; TEST_OPTS *opts; diff --git a/src/third_party/wiredtiger/test/format/config.h b/src/third_party/wiredtiger/test/format/config.h index 16fffb6fafe..6e3f5473479 100644 --- a/src/third_party/wiredtiger/test/format/config.h +++ b/src/third_party/wiredtiger/test/format/config.h @@ -70,8 +70,8 @@ static CONFIG c[] = { C_BOOL, 90, 0, 0, &g.c_auto_throttle, NULL }, { "backups", - "if backups are enabled", /* 5% */ - C_BOOL, 5, 0, 0, &g.c_backups, NULL }, + "if backups are enabled", /* 20% */ + C_BOOL, 20, 0, 0, &g.c_backups, NULL }, { "bitcnt", "number of bits for fixed-length column-store files", @@ -203,8 +203,8 @@ static CONFIG c[] = { C_BOOL, 0, 0, 0, &g.c_leak_memory, NULL }, { "logging", - "if logging configured", /* 30% */ - C_BOOL, 30, 0, 0, &g.c_logging, NULL }, + "if logging configured", /* 50% */ + C_BOOL, 50, 0, 0, &g.c_logging, NULL }, { "logging_archive", "if log file archival configured", /* 50% */ diff --git a/src/third_party/wiredtiger/test/format/format.h b/src/third_party/wiredtiger/test/format/format.h index ece30601cf0..047be552308 100644 --- a/src/third_party/wiredtiger/test/format/format.h +++ b/src/third_party/wiredtiger/test/format/format.h @@ -239,7 +239,7 @@ typedef struct { } GLOBAL; extern GLOBAL g; -typedef struct { +typedef struct WT_COMPILER_TYPE_ALIGN(WT_CACHE_LINE_ALIGNMENT) { WT_RAND_STATE rnd; /* thread RNG state */ uint64_t search; /* operations */ @@ -261,7 +261,7 @@ typedef struct { #define TINFO_COMPLETE 2 /* Finished */ #define TINFO_JOINED 3 /* Resolved */ volatile int state; /* state */ -} TINFO WT_COMPILER_TYPE_ALIGN(WT_CACHE_LINE_ALIGNMENT); +} TINFO; #ifdef HAVE_BERKELEY_DB void bdb_close(void); diff --git a/src/third_party/wiredtiger/test/format/rebalance.c b/src/third_party/wiredtiger/test/format/rebalance.c index d35dcec1d53..5fd86ef3317 100644 --- a/src/third_party/wiredtiger/test/format/rebalance.c +++ b/src/third_party/wiredtiger/test/format/rebalance.c @@ -42,7 +42,8 @@ wts_rebalance(void) /* Dump the current object. */ (void)snprintf(cmd, sizeof(cmd), - "../../wt -h %s dump -f %s/rebalance.orig %s", + ".." DIR_DELIM_STR ".." DIR_DELIM_STR "wt" + " -h %s dump -f %s/rebalance.orig %s", g.home, g.home, g.uri); testutil_checkfmt(system(cmd), "command failed: %s", cmd); @@ -66,13 +67,18 @@ wts_rebalance(void) wts_close(); (void)snprintf(cmd, sizeof(cmd), - "../../wt -h %s dump -f %s/rebalance.new %s", + ".." DIR_DELIM_STR ".." DIR_DELIM_STR "wt" + " -h %s dump -f %s/rebalance.new %s", g.home, g.home, g.uri); testutil_checkfmt(system(cmd), "command failed: %s", cmd); /* Compare the old/new versions of the object. */ (void)snprintf(cmd, sizeof(cmd), +#ifdef _WIN32 + "fc /b %s\\rebalance.orig %s\\rebalance.new > NUL", +#else "cmp %s/rebalance.orig %s/rebalance.new > /dev/null", +#endif g.home, g.home); testutil_checkfmt(system(cmd), "command failed: %s", cmd); } diff --git a/src/third_party/wiredtiger/test/format/util.c b/src/third_party/wiredtiger/test/format/util.c index cebe2153b3e..667f6d6bcb1 100644 --- a/src/third_party/wiredtiger/test/format/util.c +++ b/src/third_party/wiredtiger/test/format/util.c @@ -319,17 +319,23 @@ path_setup(const char *home) */ #undef CMD #ifdef _WIN32 -#define CMD "test -e %s || mkdir %s; " \ - "cd %s && del /s /q * >:nul && rd /s /q KVS; " \ - "mkdir KVS" +#define CMD "del /q rand.copy & " \ + "(IF EXIST %s\\rand copy /y %s\\rand rand.copy) & " \ + "(IF EXIST %s rd /s /q %s) & mkdir %s & " \ + "(IF EXIST rand.copy copy rand.copy %s\\rand) & " \ + "cd %s & mkdir KVS" + len = strlen(g.home) * 7 + strlen(CMD) + 1; + g.home_init = dmalloc(len); + snprintf(g.home_init, len, CMD, + g.home, g.home, g.home, g.home, g.home, g.home, g.home); #else #define CMD "test -e %s || mkdir %s; " \ "cd %s > /dev/null && rm -rf `ls | sed /rand/d`; " \ "mkdir KVS" -#endif len = strlen(g.home) * 3 + strlen(CMD) + 1; g.home_init = dmalloc(len); snprintf(g.home_init, len, CMD, g.home, g.home, g.home); +#endif /* Primary backup directory. */ len = strlen(g.home) + strlen("BACKUP") + 2; @@ -342,7 +348,7 @@ path_setup(const char *home) */ #undef CMD #ifdef _WIN32 -#define CMD "del %s/%s %s/%s /s /q >:nul && mkdir %s/%s %s/%s" +#define CMD "rd /s /q %s\\%s %s\\%s & mkdir %s\\%s %s\\%s" #else #define CMD "rm -rf %s/%s %s/%s && mkdir %s/%s %s/%s" #endif diff --git a/src/third_party/wiredtiger/test/format/wts.c b/src/third_party/wiredtiger/test/format/wts.c index 9acca409d6e..74c4bb902b3 100644 --- a/src/third_party/wiredtiger/test/format/wts.c +++ b/src/third_party/wiredtiger/test/format/wts.c @@ -307,15 +307,16 @@ wts_init(void) /* * Ensure that we can service at least one operation per-thread - * concurrently without filling the cache with pinned pages. We - * choose a multiplier of three because the max configurations control - * on disk size and in memory pages are often significantly larger - * than their disk counterparts. + * concurrently without filling the cache with pinned pages. We choose + * a multiplier of three because the max configurations control on disk + * size and in memory pages are often significantly larger than their + * disk counterparts. We also apply the default eviction_dirty_trigger + * of 20% so that workloads don't get stuck with dirty pages in cache. */ maxintlpage = 1U << g.c_intl_page_max; maxleafpage = 1U << g.c_leaf_page_max; while (3 * g.c_threads * (maxintlpage + maxleafpage) > - g.c_cache << 20) { + (g.c_cache << 20) / 5) { if (maxleafpage <= 512 && maxintlpage <= 512) break; if (maxintlpage > 512) diff --git a/src/third_party/wiredtiger/test/java/com/wiredtiger/test/ConcurrentCloseTest.java b/src/third_party/wiredtiger/test/java/com/wiredtiger/test/ConcurrentCloseTest.java new file mode 100644 index 00000000000..fece0353bf0 --- /dev/null +++ b/src/third_party/wiredtiger/test/java/com/wiredtiger/test/ConcurrentCloseTest.java @@ -0,0 +1,179 @@ +/*- + * Public Domain 2014-2016 MongoDB, Inc. + * Public Domain 2008-2014 WiredTiger, Inc. + * + * This is free and unencumbered software released into the public domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +package com.wiredtiger.test; + +import com.wiredtiger.db.Connection; +import com.wiredtiger.db.Cursor; +import com.wiredtiger.db.Session; +import com.wiredtiger.db.WiredTigerException; +import com.wiredtiger.db.wiredtiger; + +import static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.Assert; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/* + * Test multiple threads concurrently inserting and reading. + * Each insert thread opens and closes for each record, so the + * test stresses the concurrency of these calls in particular. + * This is a test case for a problem reported in WT-2788. + */ +class InsertThread extends Thread { + private Connection conn; + private int threadId; + + public InsertThread(Connection conn, int threadId) { + this.conn = conn; + this.threadId = threadId; + } + + public void run() + { + try { + int ret; + for (int i = 0; i < 500; i++) { + Session session = conn.open_session(null); + Cursor cursor = session.open_cursor("table:cclose", null, + "overwrite"); + cursor.putKeyString("key"+threadId + "-" + i); + cursor.putValueString("value1"); + ret = cursor.insert(); + cursor.close(); + ret = session.close(null); + } + } catch (WiredTigerException wte) { + System.err.println("Exception " + wte); + } + } +} + +class ScanThread extends Thread { + private Connection conn; + + public ScanThread(Connection conn) { + this.conn = conn; + } + + public void run() + { + try { + int ret; + + Session session = conn.open_session(null); + Cursor cursor = session.open_cursor("table:cclose", null, null); + + /* Show all records. */ + while ((ret = cursor.next()) == 0) { + String key = cursor.getKeyString(); + String value = cursor.getValueString(); + System.out.println("Got record: " + key + " : " + value); + } + if (ret != wiredtiger.WT_NOTFOUND) + System.err.println("Cursor.next: " + + wiredtiger.wiredtiger_strerror(ret)); + cursor.close(); + session.close(null); + } catch (WiredTigerException wte) { + System.err.println("Exception " + wte); + } + } +} + +public class ConcurrentCloseTest { + Connection conn; + Session session; + + public static String home; + + public static final int NUM_THREADS = 10; + + @Test + public void test_threads() + { + setup(); + try { + List<Thread> threads = new ArrayList<Thread>(); + int i, ret; + + ret = session.create("table:cclose", "key_format=S,value_format=S"); + Cursor cursor = session.open_cursor("table:cclose", null, + "overwrite"); + cursor.putKeyString("key1"); + cursor.putValueString("value1"); + ret = cursor.insert(); + cursor.close(); + ret = session.close(null); + + for (i = 0; i < NUM_THREADS; i++) { + Thread insertThread = new InsertThread(conn, i); + Thread scanThread = new InsertThread(conn, i); + insertThread.start(); + scanThread.start(); + threads.add(insertThread); + threads.add(scanThread); + } + + for (Thread thread : threads) + try { + thread.join(); + ret = -1; + } + catch (InterruptedException ie) { + } + + ret = conn.close(null); + System.exit(ret); + } + catch (WiredTigerException wte) { + System.err.println("Exception: " + wte); + wte.printStackTrace(); + System.exit(1); + } + } + + private void setup() { + conn = wiredtiger.open("WT_HOME", "create"); + session = conn.open_session(null); + } + + private void teardown() { + session.close(""); + conn.close(""); + } + + +} diff --git a/src/third_party/wiredtiger/test/manydbs/manydbs.c b/src/third_party/wiredtiger/test/manydbs/manydbs.c index e485e73067f..c5c9a9a7ccd 100644 --- a/src/third_party/wiredtiger/test/manydbs/manydbs.c +++ b/src/third_party/wiredtiger/test/manydbs/manydbs.c @@ -93,7 +93,7 @@ get_stat(WT_SESSION *stat_session, int stat_field, uint64_t *valuep) return (ret); } -static int +static void run_ops(int dbs) { WT_ITEM data; @@ -119,7 +119,6 @@ run_ops(int dbs) testutil_check(cursors[db]->insert(cursors[db])); } } - return (0); } int @@ -211,7 +210,7 @@ main(int argc, char *argv[]) WT_STAT_CONN_COND_AUTO_WAIT_RESET, &cond_reset_orig[i])); for (i = 0; i < MAX_IDLE_TIME; i += IDLE_INCR) { if (!idle) - testutil_check(run_ops(dbs)); + run_ops(dbs); printf("Sleep %d (%d of %d)\n", IDLE_INCR, i, MAX_IDLE_TIME); sleep(IDLE_INCR); } diff --git a/src/third_party/wiredtiger/test/mciproject.yml b/src/third_party/wiredtiger/test/mciproject.yml index ff58d1839cf..eb74914eb46 100644 --- a/src/third_party/wiredtiger/test/mciproject.yml +++ b/src/third_party/wiredtiger/test/mciproject.yml @@ -128,6 +128,20 @@ tasks: ./test/fops/t fi + - name: format + depends_on: + - name: compile + commands: + - func: "fetch binaries" + - command: shell.exec + params: + working_dir: "wiredtiger" + script: | + set -o errexit + set -o verbose + # format assumes we run it from the format directory + cmd.exe /c "cd test\\format && ..\\..\\t_format.exe reverse=0 encryption=none logging_compression=none runs=20" + buildvariants: - name: ubuntu1404 display_name: Ubuntu 14.04 @@ -165,6 +179,7 @@ buildvariants: - name: compile - name: compile-windows-alt - name: unit-test + #- name: format - Enable when we have a solution for hangs and crashses - name: fops - name: osx-1010 diff --git a/src/third_party/wiredtiger/test/salvage/salvage.c b/src/third_party/wiredtiger/test/salvage/salvage.c index c3349188623..bad0167ca8e 100644 --- a/src/third_party/wiredtiger/test/salvage/salvage.c +++ b/src/third_party/wiredtiger/test/salvage/salvage.c @@ -602,8 +602,8 @@ copy(u_int gen, u_int recno) dsk->recno = recno; dsk->write_gen = gen; blk = WT_BLOCK_HEADER_REF(buf); - blk->cksum = 0; - blk->cksum = __wt_cksum(dsk, PSIZE); + blk->checksum = 0; + blk->checksum = __wt_checksum(dsk, PSIZE); CHECK(fwrite(buf, 1, PSIZE, ofp) == PSIZE); } diff --git a/src/third_party/wiredtiger/test/suite/test_join06.py b/src/third_party/wiredtiger/test/suite/test_join06.py index 5fedd365712..a6681cdccd0 100644 --- a/src/third_party/wiredtiger/test/suite/test_join06.py +++ b/src/third_party/wiredtiger/test/suite/test_join06.py @@ -37,8 +37,10 @@ class test_join06(wttest.WiredTigerTestCase): nentries = 1000 isoscen = [ - ('isolation_read_uncommitted', dict(uncommitted=True)), - ('isolation_default', dict(uncommitted=False)) + ('isolation_read_uncommitted', dict(isolation='read-uncommitted')), + ('isolation_read_committed', dict(isolation='read-committed')), + ('isolation_default', dict(isolation='')), + ('isolation_snapshot', dict(isolation='snapshot')) ] bloomscen = [ @@ -79,8 +81,8 @@ class test_join06(wttest.WiredTigerTestCase): # TODO: needed? #self.reopen_conn() - if self.uncommitted: - self.session.begin_transaction('isolation=read-uncommitted') + if self.isolation != '': + self.session.begin_transaction('isolation=' + self.isolation) jc = self.session.open_cursor('join:table:join06', None, None) c0 = self.session.open_cursor('index:join06:index0', None, None) @@ -96,7 +98,7 @@ class test_join06(wttest.WiredTigerTestCase): self.assertEquals(0, c1.search()) self.session.join(jc, c1, joinconfig) - if self.uncommitted and self.bloom: + if self.isolation == 'read-uncommitted' and self.bloom: # Make sure that read-uncommitted with Bloom is not allowed. # This is detected on the first next() operation. msg = '/cannot be used with read-uncommitted/' @@ -106,7 +108,7 @@ class test_join06(wttest.WiredTigerTestCase): # Changes made in another session may or may not be visible to us, # depending on the isolation level. - if self.uncommitted: + if self.isolation == 'read-uncommitted': # isolation level is read-uncommitted, so we will see # additions deletions made in our other session. mbr = set(range(525,1000,10)) | set(range(55,100,10)) | set([520]) @@ -116,12 +118,11 @@ class test_join06(wttest.WiredTigerTestCase): mbr = set(range(520,600)) | set(range(53,60)) altered = False - while jc.next() == 0: [k] = jc.get_keys() [v0,v1] = jc.get_values() #self.tty('GOT: ' + str(k) + ': ' + str(jc.get_values())) - if altered and self.uncommitted: + if altered and self.isolation == 'read-uncommitted': self.assertEquals(self.gen_values2(k), [v0, v1]) else: self.assertEquals(self.gen_values(k), [v0, v1]) @@ -150,7 +151,7 @@ class test_join06(wttest.WiredTigerTestCase): jc.close() c1.close() c0.close() - if self.uncommitted: + if self.isolation != '': self.session.commit_transaction() self.session.drop('table:join06') diff --git a/src/third_party/wiredtiger/test/utility/misc.c b/src/third_party/wiredtiger/test/utility/misc.c index dffd29a5b6a..096bc752726 100644 --- a/src/third_party/wiredtiger/test/utility/misc.c +++ b/src/third_party/wiredtiger/test/utility/misc.c @@ -82,12 +82,22 @@ testutil_clean_work_dir(char *dir) int ret; char *buf; +#ifdef _WIN32 /* Additional bytes for the Windows rd command. */ + len = 2 * strlen(dir) + strlen(RM_COMMAND) + + strlen(DIR_EXISTS_COMMAND) + 4; + if ((buf = malloc(len)) == NULL) + testutil_die(ENOMEM, "Failed to allocate memory"); + + snprintf(buf, len, "%s %s %s %s", DIR_EXISTS_COMMAND, dir, + RM_COMMAND, dir); +#else len = strlen(dir) + strlen(RM_COMMAND) + 1; if ((buf = malloc(len)) == NULL) testutil_die(ENOMEM, "Failed to allocate memory"); snprintf(buf, len, "%s%s", RM_COMMAND, dir); +#endif if ((ret = system(buf)) != 0 && ret != ENOENT) testutil_die(ret, "%s", buf); @@ -139,6 +149,23 @@ testutil_cleanup(TEST_OPTS *opts) } /* + * testutil_disable_long_tests -- + * Return if TESTUTIL_DISABLE_LONG_TESTS is set. + */ +bool +testutil_disable_long_tests(void) +{ + const char *res; + + if (__wt_getenv(NULL, + "TESTUTIL_DISABLE_LONG_TESTS", &res) == WT_NOTFOUND) + return (false); + + free((void *)res); + return (true); +} + +/* * dcalloc -- * Call calloc, dying on failure. */ diff --git a/src/third_party/wiredtiger/test/utility/parse_opts.c b/src/third_party/wiredtiger/test/utility/parse_opts.c index 4054f318259..08aeafa9617 100644 --- a/src/third_party/wiredtiger/test/utility/parse_opts.c +++ b/src/third_party/wiredtiger/test/utility/parse_opts.c @@ -47,7 +47,7 @@ testutil_parse_opts(int argc, char * const *argv, TEST_OPTS *opts) opts->running = true; opts->verbose = false; - if ((opts->progname = strrchr(argv[0], '/')) == NULL) + if ((opts->progname = strrchr(argv[0], DIR_DELIM)) == NULL) opts->progname = argv[0]; else ++opts->progname; diff --git a/src/third_party/wiredtiger/test/utility/test_util.h b/src/third_party/wiredtiger/test/utility/test_util.h index 821e06084d2..3c1d0e2630a 100644 --- a/src/third_party/wiredtiger/test/utility/test_util.h +++ b/src/third_party/wiredtiger/test/utility/test_util.h @@ -29,9 +29,12 @@ #ifdef _WIN32 #define DIR_DELIM '\\' + #define DIR_DELIM_STR "\\" + #define DIR_EXISTS_COMMAND "IF EXIST " #define RM_COMMAND "rd /s /q " #else #define DIR_DELIM '/' + #define DIR_DELIM_STR "/" #define RM_COMMAND "rm -rf " #endif @@ -118,6 +121,7 @@ void *dstrdup(const void *); void *dstrndup(const char *, size_t); void testutil_clean_work_dir(char *); void testutil_cleanup(TEST_OPTS *); +bool testutil_disable_long_tests(void); void testutil_make_work_dir(char *); int testutil_parse_opts(int, char * const *, TEST_OPTS *); void testutil_work_dir_from_path(char *, size_t, const char *); diff --git a/src/third_party/wiredtiger/test/windows/windows_shim.c b/src/third_party/wiredtiger/test/windows/windows_shim.c index 6e8da8f86d4..b161b29c2fa 100644 --- a/src/third_party/wiredtiger/test/windows/windows_shim.c +++ b/src/third_party/wiredtiger/test/windows/windows_shim.c @@ -105,6 +105,17 @@ pthread_rwlock_unlock(pthread_rwlock_t *rwlock) } int +pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) +{ + if (TryAcquireSRWLockExclusive(&rwlock->rwlock)) { + rwlock->exclusive_locked = GetCurrentThreadId(); + return (0); + } + + return (EBUSY); +} + +int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) { AcquireSRWLockExclusive(&rwlock->rwlock); diff --git a/src/third_party/wiredtiger/test/windows/windows_shim.h b/src/third_party/wiredtiger/test/windows/windows_shim.h index f32edce88e7..a6050e92bca 100644 --- a/src/third_party/wiredtiger/test/windows/windows_shim.h +++ b/src/third_party/wiredtiger/test/windows/windows_shim.h @@ -30,6 +30,7 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> +#include <errno.h> #include <stdint.h> #include <direct.h> #include <io.h> @@ -109,6 +110,7 @@ int pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *); int pthread_rwlock_rdlock(pthread_rwlock_t *); int pthread_rwlock_unlock(pthread_rwlock_t *); +int pthread_rwlock_trywrlock(pthread_rwlock_t *); int pthread_rwlock_wrlock(pthread_rwlock_t *); int pthread_create(pthread_t *, const pthread_attr_t *, |