diff options
author | Monica Ng <monica.ng@mongodb.com> | 2023-02-19 23:24:22 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-20 00:05:35 +0000 |
commit | 713b8810e0f1a17a0e1225a6555ee0141b5fe9bb (patch) | |
tree | 6fdcacd3705a58e44f6d0fbb28e359eb8a28b9f4 | |
parent | 91646da9a94d42f4ed45246e5d73fe2abcd8e489 (diff) | |
download | mongo-713b8810e0f1a17a0e1225a6555ee0141b5fe9bb.tar.gz |
Import wiredtiger: 5356295ea4603967a3b046838228589e511edd10 from branch mongodb-master
ref: 771763d532..5356295ea4
for: 7.0.0-rc0
WT-10439 Update diagnostic categories
29 files changed, 317 insertions, 162 deletions
diff --git a/src/third_party/wiredtiger/dist/api_data.py b/src/third_party/wiredtiger/dist/api_data.py index e91206d61c3..0e46f656c9b 100644 --- a/src/third_party/wiredtiger/dist/api_data.py +++ b/src/third_party/wiredtiger/dist/api_data.py @@ -523,30 +523,6 @@ connection_runtime_config = [ the maximum number of milliseconds an application thread will wait for space to be available in cache before giving up. Default will wait forever''', min=0), - Config('extra_diagnostics', '[]', r''' - enable additional diagnostics in WiredTiger. These additional diagnostics include - diagnostic assertions that can cause WiredTiger to abort when an invalid state - is detected. - Options are given as a list, such as - <code>"extra_diagnostics=[out_of_order,visibility]"</code>. - Choosing \c all enables all assertions. When WiredTiger is compiled with - \c HAVE_DIAGNOSTIC=1 all assertions are enabled and cannot be reconfigured - ''', - type='list', choices=[ - "all", "concurrent_access", "data_validation", "invalid_op", "out_of_order", - "panic", "slow_operation", "visibility"]), - - Config('history_store', '', r''' - history store configuration options''', - type='category', subconfig=[ - Config('file_max', '0', r''' - the maximum number of bytes that WiredTiger is allowed to use for its history store - mechanism. If the history store file exceeds this size, a panic will be triggered. The - default value means that the history store file is unbounded and may use as much - space as the filesystem will accommodate. The minimum non-zero setting is 100MB.''', - # !!! Must match WT_HS_FILE_MIN - min='0') - ]), Config('cache_overhead', '8', r''' assume the heap allocator overhead is the specified percentage, and adjust the cache usage by that amount (for example, if there is 10GB of data in cache, a percentage of @@ -695,6 +671,19 @@ connection_runtime_config = [ cache_size and has to be greater than its counterpart \c eviction_updates_target. This setting only alters behavior if it is lower than \c eviction_trigger''', min=0, max='10TB'), + Config('extra_diagnostics', '[]', r''' + enable additional diagnostics in WiredTiger. These additional diagnostics include + diagnostic assertions that can cause WiredTiger to abort when an invalid state + is detected. + Options are given as a list, such as + <code>"extra_diagnostics=[out_of_order,visibility]"</code>. + Choosing \c all enables all assertions. When WiredTiger is compiled with + \c HAVE_DIAGNOSTIC=1 all assertions are enabled and cannot be reconfigured + ''', + type='list', choices=[ + "all", "checkpoint_validate", "cursor_check", "disk_validate", "eviction_check", + "generation_check", "hs_validate", "key_out_of_order", "log_validate", "prepared", + "slow_operation", "txn_visibility"]), Config('file_manager', '', r''' control how file handles are managed''', type='category', subconfig=[ @@ -709,6 +698,17 @@ connection_runtime_config = [ interval in seconds at which to check for files that are inactive and close them''', min=1, max=100000), ]), + Config('history_store', '', r''' + history store configuration options''', + type='category', subconfig=[ + Config('file_max', '0', r''' + the maximum number of bytes that WiredTiger is allowed to use for its history store + mechanism. If the history store file exceeds this size, a panic will be triggered. The + default value means that the history store file is unbounded and may use as much + space as the filesystem will accommodate. The minimum non-zero setting is 100MB.''', + # !!! Must match WT_HS_FILE_MIN + min='0') + ]), Config('io_capacity', '', r''' control how many bytes per second are written and read. Exceeding the capacity results in throttling.''', diff --git a/src/third_party/wiredtiger/dist/s_string.ok b/src/third_party/wiredtiger/dist/s_string.ok index 4696ac4a591..8de2c530e42 100644 --- a/src/third_party/wiredtiger/dist/s_string.ok +++ b/src/third_party/wiredtiger/dist/s_string.ok @@ -114,7 +114,6 @@ DECL DECR DESC DHANDLE -DIAG DIRECTIO DNE DOI diff --git a/src/third_party/wiredtiger/examples/c/ex_extra_diagnostics.c b/src/third_party/wiredtiger/examples/c/ex_extra_diagnostics.c new file mode 100644 index 00000000000..616b0f9939a --- /dev/null +++ b/src/third_party/wiredtiger/examples/c/ex_extra_diagnostics.c @@ -0,0 +1,54 @@ +/*- + * Public Domain 2014-present 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. + * + * ex_extra_diagnostics.c + * This is an example demonstrating how to enable and update extra diagnostic + * code at runtime. + */ +#include <test_util.h> + +static const char *home; + +int +main(int argc, char *argv[]) +{ + WT_CONNECTION *conn; + + home = example_setup(argc, argv); + /*! [Configure extra_diagnostics] */ + /* Open a connection to the database, enabling key ordering checks. */ + error_check(wiredtiger_open(home, NULL, "create,extra_diagnostics=[key_out_of_order]", &conn)); + + /* + * Reconfigure the connection to turn on transaction visibility checks. As key_out_of_order is + * not provided in the new configuration it is disabled. + */ + error_check(conn->reconfigure(conn, "extra_diagnostics=[txn_visibility]")); + /*! [Configure extra_diagnostics] */ + + return (EXIT_SUCCESS); +} diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 58327417743..2da8e28888e 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-master", - "commit": "771763d532243b0df79fa5ca12caf226236a6f0b" + "commit": "5356295ea4603967a3b046838228589e511edd10" } diff --git a/src/third_party/wiredtiger/src/block/block_ckpt.c b/src/third_party/wiredtiger/src/block/block_ckpt.c index 763e5d5076c..a89cb7c63dd 100644 --- a/src/third_party/wiredtiger/src/block/block_ckpt.c +++ b/src/third_party/wiredtiger/src/block/block_ckpt.c @@ -72,7 +72,7 @@ __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint live_open = block->live_open; block->live_open = true; __wt_spin_unlock(session, &block->live_lock); - WT_ERR_ASSERT(session, WT_DIAG_CONCURRENT_ACCESS, live_open == false, EBUSY, + WT_ERR_ASSERT(session, WT_DIAGNOSTIC_CHECKPOINT_VALIDATE, live_open == false, EBUSY, "%s: attempt to re-open live file", block->name); ci = &block->live; @@ -486,7 +486,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) ci = &block->live; fatal = locked = false; - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION)) + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_CHECKPOINT_VALIDATE)) WT_RET(__ckpt_verify(session, ckptbase)); /* @@ -581,7 +581,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) */ if (next_ckpt->bpriv == NULL && !F_ISSET(next_ckpt, WT_CKPT_ADD)) { WT_ERR(__ckpt_extlist_read(session, block, next_ckpt, &local)); - WT_ERR_ASSERT(session, WT_DIAG_INVALID_OP, local == true, WT_PANIC, + WT_ERR_ASSERT(session, WT_DIAGNOSTIC_CHECKPOINT_VALIDATE, local == true, WT_PANIC, "tiered storage checkpoint follows local checkpoint"); } } diff --git a/src/third_party/wiredtiger/src/btree/bt_discard.c b/src/third_party/wiredtiger/src/btree/bt_discard.c index b5408d29eec..71ce1c89170 100644 --- a/src/third_party/wiredtiger/src/btree/bt_discard.c +++ b/src/third_party/wiredtiger/src/btree/bt_discard.c @@ -37,7 +37,7 @@ __wt_ref_out(WT_SESSION_IMPL *session, WT_REF *ref) * state, so our check can race with readers without indicating a real problem. If we find a * hazard pointer, wait for it to be cleared. */ - WT_ASSERT_OPTIONAL(session, WT_DIAG_CONCURRENT_ACCESS, + WT_ASSERT_OPTIONAL(session, WT_DIAGNOSTIC_EVICTION_CHECK, __wt_hazard_check_assert(session, ref, true), "Attempted to free a page with active hazard pointers"); @@ -353,7 +353,7 @@ __wt_free_ref_index(WT_SESSION_IMPL *session, WT_PAGE *page, WT_PAGE_INDEX *pind * Used when unrolling splits and other error paths where there should never have been a * hazard pointer taken. */ - WT_ASSERT_OPTIONAL(session, WT_DIAG_CONCURRENT_ACCESS, + WT_ASSERT_OPTIONAL(session, WT_DIAGNOSTIC_EVICTION_CHECK, __wt_hazard_check_assert(session, ref, false), "Attempting to discard ref to a page with hazard pointers"); diff --git a/src/third_party/wiredtiger/src/btree/bt_split.c b/src/third_party/wiredtiger/src/btree/bt_split.c index 8ca6bbe21e1..133a9b11506 100644 --- a/src/third_party/wiredtiger/src/btree/bt_split.c +++ b/src/third_party/wiredtiger/src/btree/bt_split.c @@ -373,7 +373,7 @@ __split_ref_prepare( } WT_INTL_FOREACH_END; - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER)) + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER)) WT_WITH_PAGE_INDEX(session, __split_verify_intl_key_order(session, child)); } *lockedp = locked; @@ -535,7 +535,7 @@ __split_root(WT_SESSION_IMPL *session, WT_PAGE *root) /* Finalize the WT_REF move. */ __split_ref_final(session, split_gen, &locked); - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER)) { WT_WITH_PAGE_INDEX(session, ret = __split_verify_root(session, root)); WT_ERR(ret); } @@ -790,7 +790,7 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, WT_REF **ref_new, uint32_t split_gen = __wt_gen(session, WT_GEN_SPLIT); parent->pg_intl_split_gen = split_gen; - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER)) + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER)) WT_WITH_PAGE_INDEX(session, __split_verify_intl_key_order(session, parent)); /* The split is complete and verified, ignore benign errors. */ @@ -1062,7 +1062,7 @@ __split_internal(WT_SESSION_IMPL *session, WT_PAGE *parent, WT_PAGE *page) /* Finalize the WT_REF move. */ __split_ref_final(session, split_gen, &locked); - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER)) { WT_WITH_PAGE_INDEX(session, __split_verify_intl_key_order(session, parent)); WT_WITH_PAGE_INDEX(session, __split_verify_intl_key_order(session, page)); } @@ -1677,7 +1677,7 @@ __wt_multi_to_ref(WT_SESSION_IMPL *session, WT_PAGE *page, WT_MULTI *multi, WT_R session, multi->disk_image != NULL || (multi->supd_entries == 0 && !multi->supd_restore)); /* Verify any disk image we have. */ - WT_ASSERT_OPTIONAL(session, WT_DIAG_DATA_VALIDATION, + WT_ASSERT_OPTIONAL(session, WT_DIAGNOSTIC_DISK_VALIDATE, multi->disk_image == NULL || __wt_verify_dsk_image(session, "[page instantiate]", multi->disk_image, 0, &multi->addr, WT_VRFY_DISK_EMPTY_PAGE_OK) == 0, @@ -1778,7 +1778,7 @@ __split_insert(WT_SESSION_IMPL *session, WT_REF *ref) * otherwise the page might be evicted based on its last reconciliation which no longer matches * reality after the split. */ - WT_ASSERT_OPTIONAL(session, WT_DIAG_DATA_VALIDATION, __wt_leaf_page_can_split(session, page), + WT_ASSERT_ALWAYS(session, __wt_leaf_page_can_split(session, page), "Attempted to split a page that cannot be split"); WT_ASSERT_ALWAYS(session, __wt_page_is_modified(page), "Attempted to split a clean page"); diff --git a/src/third_party/wiredtiger/src/btree/col_modify.c b/src/third_party/wiredtiger/src/btree/col_modify.c index 7b7ff70d7e5..7c02e284536 100644 --- a/src/third_party/wiredtiger/src/btree/col_modify.c +++ b/src/third_party/wiredtiger/src/btree/col_modify.c @@ -81,7 +81,7 @@ __wt_col_modify(WT_CURSOR_BTREE *cbt, uint64_t recno, const WT_ITEM *value, WT_U /* Since on this path we never set append, make sure we aren't appending. */ WT_ASSERT_ALWAYS( session, recno != WT_RECNO_OOB, "Out-of-bound recno provided for a non-append operation"); - WT_ASSERT_OPTIONAL(session, WT_DIAG_OUT_OF_ORDER, + WT_ASSERT_OPTIONAL(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER, cbt->compare == 0 || recno <= (btree->type == BTREE_COL_VAR ? __col_var_last_recno(cbt->ref) : __col_fix_last_recno(cbt->ref)), diff --git a/src/third_party/wiredtiger/src/config/config_def.c b/src/third_party/wiredtiger/src/config/config_def.c index 445d83beca1..02bbe6f245c 100644 --- a/src/third_party/wiredtiger/src/config/config_def.c +++ b/src/third_party/wiredtiger/src/config/config_def.c @@ -136,9 +136,10 @@ static const WT_CONFIG_CHECK confchk_WT_CONNECTION_reconfigure[] = { {"eviction_updates_target", "int", NULL, "min=0,max=10TB", NULL, 0}, {"eviction_updates_trigger", "int", NULL, "min=0,max=10TB", NULL, 0}, {"extra_diagnostics", "list", NULL, - "choices=[\"all\",\"concurrent_access\"," - "\"data_validation\",\"invalid_op\",\"out_of_order\",\"panic\"," - "\"slow_operation\",\"visibility\"]", + "choices=[\"all\",\"checkpoint_validate\",\"cursor_check\"" + ",\"disk_validate\",\"eviction_check\",\"generation_check\"," + "\"hs_validate\",\"key_out_of_order\",\"log_validate\"," + "\"prepared\",\"slow_operation\",\"txn_visibility\"]", NULL, 0}, {"file_manager", "category", NULL, NULL, confchk_wiredtiger_open_file_manager_subconfigs, 3}, {"history_store", "category", NULL, NULL, confchk_wiredtiger_open_history_store_subconfigs, 1}, @@ -890,9 +891,10 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open[] = { {"eviction_updates_trigger", "int", NULL, "min=0,max=10TB", NULL, 0}, {"exclusive", "boolean", NULL, NULL, NULL, 0}, {"extensions", "list", NULL, NULL, NULL, 0}, {"extra_diagnostics", "list", NULL, - "choices=[\"all\",\"concurrent_access\"," - "\"data_validation\",\"invalid_op\",\"out_of_order\",\"panic\"," - "\"slow_operation\",\"visibility\"]", + "choices=[\"all\",\"checkpoint_validate\",\"cursor_check\"" + ",\"disk_validate\",\"eviction_check\",\"generation_check\"," + "\"hs_validate\",\"key_out_of_order\",\"log_validate\"," + "\"prepared\",\"slow_operation\",\"txn_visibility\"]", NULL, 0}, {"file_extend", "list", NULL, "choices=[\"data\",\"log\"]", NULL, 0}, {"file_manager", "category", NULL, NULL, confchk_wiredtiger_open_file_manager_subconfigs, 3}, @@ -981,9 +983,10 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open_all[] = { {"eviction_updates_trigger", "int", NULL, "min=0,max=10TB", NULL, 0}, {"exclusive", "boolean", NULL, NULL, NULL, 0}, {"extensions", "list", NULL, NULL, NULL, 0}, {"extra_diagnostics", "list", NULL, - "choices=[\"all\",\"concurrent_access\"," - "\"data_validation\",\"invalid_op\",\"out_of_order\",\"panic\"," - "\"slow_operation\",\"visibility\"]", + "choices=[\"all\",\"checkpoint_validate\",\"cursor_check\"" + ",\"disk_validate\",\"eviction_check\",\"generation_check\"," + "\"hs_validate\",\"key_out_of_order\",\"log_validate\"," + "\"prepared\",\"slow_operation\",\"txn_visibility\"]", NULL, 0}, {"file_extend", "list", NULL, "choices=[\"data\",\"log\"]", NULL, 0}, {"file_manager", "category", NULL, NULL, confchk_wiredtiger_open_file_manager_subconfigs, 3}, @@ -1071,9 +1074,10 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open_basecfg[] = { {"eviction_updates_trigger", "int", NULL, "min=0,max=10TB", NULL, 0}, {"extensions", "list", NULL, NULL, NULL, 0}, {"extra_diagnostics", "list", NULL, - "choices=[\"all\",\"concurrent_access\"," - "\"data_validation\",\"invalid_op\",\"out_of_order\",\"panic\"," - "\"slow_operation\",\"visibility\"]", + "choices=[\"all\",\"checkpoint_validate\",\"cursor_check\"" + ",\"disk_validate\",\"eviction_check\",\"generation_check\"," + "\"hs_validate\",\"key_out_of_order\",\"log_validate\"," + "\"prepared\",\"slow_operation\",\"txn_visibility\"]", NULL, 0}, {"file_extend", "list", NULL, "choices=[\"data\",\"log\"]", NULL, 0}, {"file_manager", "category", NULL, NULL, confchk_wiredtiger_open_file_manager_subconfigs, 3}, @@ -1158,9 +1162,10 @@ static const WT_CONFIG_CHECK confchk_wiredtiger_open_usercfg[] = { {"eviction_updates_trigger", "int", NULL, "min=0,max=10TB", NULL, 0}, {"extensions", "list", NULL, NULL, NULL, 0}, {"extra_diagnostics", "list", NULL, - "choices=[\"all\",\"concurrent_access\"," - "\"data_validation\",\"invalid_op\",\"out_of_order\",\"panic\"," - "\"slow_operation\",\"visibility\"]", + "choices=[\"all\",\"checkpoint_validate\",\"cursor_check\"" + ",\"disk_validate\",\"eviction_check\",\"generation_check\"," + "\"hs_validate\",\"key_out_of_order\",\"log_validate\"," + "\"prepared\",\"slow_operation\",\"txn_visibility\"]", NULL, 0}, {"file_extend", "list", NULL, "choices=[\"data\",\"log\"]", NULL, 0}, {"file_manager", "category", NULL, NULL, confchk_wiredtiger_open_file_manager_subconfigs, 3}, diff --git a/src/third_party/wiredtiger/src/conn/conn_api.c b/src/third_party/wiredtiger/src/conn/conn_api.c index b2ad5f1f200..f27ee0c8016 100644 --- a/src/third_party/wiredtiger/src/conn/conn_api.c +++ b/src/third_party/wiredtiger/src/conn/conn_api.c @@ -1963,11 +1963,16 @@ err: int __wt_extra_diagnostics_config(WT_SESSION_IMPL *session, const char *cfg[]) { - static const WT_NAME_FLAG extra_diagnostics_types[] = {{"all", WT_DIAG_ALL}, - {"concurrent_access", WT_DIAG_CONCURRENT_ACCESS}, - {"data_validation", WT_DIAG_DATA_VALIDATION}, {"invalid_op", WT_DIAG_INVALID_OP}, - {"out_of_order", WT_DIAG_OUT_OF_ORDER}, {"panic", WT_DIAG_PANIC}, - {"slow_operation", WT_DIAG_SLOW_OPERATION}, {"visibility", WT_DIAG_VISIBILITY}, {NULL, 0}}; + static const WT_NAME_FLAG extra_diagnostics_types[] = {{"all", WT_DIAGNOSTIC_ALL}, + {"checkpoint_validate", WT_DIAGNOSTIC_CHECKPOINT_VALIDATE}, + {"cursor_check", WT_DIAGNOSTIC_CURSOR_CHECK}, {"disk_validate", WT_DIAGNOSTIC_DISK_VALIDATE}, + {"eviction_check", WT_DIAGNOSTIC_EVICTION_CHECK}, + {"generation_check", WT_DIAGNOSTIC_GENERATION_CHECK}, + {"hs_validate", WT_DIAGNOSTIC_HS_VALIDATE}, + {"key_out_of_order", WT_DIAGNOSTIC_KEY_OUT_OF_ORDER}, + {"log_validate", WT_DIAGNOSTIC_LOG_VALIDATE}, {"prepared", WT_DIAGNOSTIC_PREPARED}, + {"slow_operation", WT_DIAGNOSTIC_SLOW_OPERATION}, + {"txn_visibility", WT_DIAGNOSTIC_TXN_VISIBILITY}, {NULL, 0}}; WT_CONNECTION_IMPL *conn; WT_CONFIG_ITEM cval, sval; @@ -1980,7 +1985,7 @@ __wt_extra_diagnostics_config(WT_SESSION_IMPL *session, const char *cfg[]) WT_RET(__wt_config_gets(session, cfg, "extra_diagnostics", &cval)); #ifdef HAVE_DIAGNOSTIC - flags = WT_DIAG_ALL; + flags = WT_DIAGNOSTIC_ALL; for (ft = extra_diagnostics_types; ft->name != NULL; ft++) { if ((ret = __wt_config_subgets(session, &cval, ft->name, &sval)) == 0 && sval.val != 0) WT_RET_MSG(session, EINVAL, diff --git a/src/third_party/wiredtiger/src/cursor/cur_hs.c b/src/third_party/wiredtiger/src/cursor/cur_hs.c index fe4ac858d4e..a2ea52ccf68 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_hs.c +++ b/src/third_party/wiredtiger/src/cursor/cur_hs.c @@ -1002,7 +1002,7 @@ __curhs_insert(WT_CURSOR *cursor) /* We no longer own the update memory, the page does; don't free it under any circumstances. */ hs_tombstone = hs_upd = NULL; - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_HS_VALIDATE)) { /* Do a search again and call next to check the key order. */ ret = __curhs_file_cursor_search_near(session, file_cursor, &exact); /* We can get not found if the inserted history store record is obsolete. */ diff --git a/src/third_party/wiredtiger/src/docs/debugging.dox b/src/third_party/wiredtiger/src/docs/debugging.dox new file mode 100644 index 00000000000..f540b182b0a --- /dev/null +++ b/src/third_party/wiredtiger/src/docs/debugging.dox @@ -0,0 +1,84 @@ +/*! @page debugging Debugging + +WiredTiger contains many assertions and diagnostic code blocks that are used to detect +unexpected control flow and invalid program states. For performance reasons most checks +are disabled by default and must be enabled either by compiling WiredTiger in diagnostic +mode via the \c `-DHAVE_DIAGNOSTIC=1` flag, or for a subset of checks by turning them on at +runtime with the \c WT_CONNECTION configuration item \c extra_diagnostics . +Note that in diagnostic mode all checks are always enabled and cannot be disabled. + +There are two types of checks available. Assertions and diagnostic code blocks: + +@section assertions Assertions +WiredTiger offers the following assertions: + +<table> +@hrow{Assertion, Behavior in diagnostic mode, Behavior in release mode} +@row{\c WT_ASSERT, Always run and abort WiredTiger on failure, Never run.} +@row{\c WT_ASSERT_ALWAYS, Always run and abort WiredTiger on failure, + Always run and abort WiredTiger on failure.} +@row{\c WT_ASSERT_OPTIONAL, Always run and abort WiredTiger on failure, + Takes a \c WT_DIAGNOSTIC_* category argument and only runs when the category is + enabled on the \c WT_CONNECTION. On failure abort WiredTiger} +@row{\c WT_ERR_ASSERT, Always run and abort WiredTiger on failure, + Always run and take a \c WT_DIAGNOSTIC_* category argument. When the category is + enabled on the \c WT_CONNECTION and the assertion fails abort WiredTiger. When + the assertion fails and the category is not enabled on the \c WT_CONNECTION return + a WT_ERR } +@row{\c WT_RET_ASSERT, Always run and abort WiredTiger on failure, + Always run and take a \c WT_DIAGNOSTIC_* category argument. When the category is + enabled on the \c WT_CONNECTION and the assertion fails abort WiredTiger. When + the assertion fails and the category is not enabled on the \c WT_CONNECTION return + a WT_RET } +@row{\c WT_RET_PANIC_ASSERT, Always run and abort WiredTiger on failure, + Always run and take a \c WT_DIAGNOSTIC_* category argument. When the category is + enabled on the \c WT_CONNECTION and the assertion fails abort WiredTiger. When + the assertion fails and the category is not enabled on the \c WT_CONNECTION return + a WT_RET_PANIC } +</table> + +@section diagnostic_code_blocks Diagnostic Code Blocks + +Longer, more extensive checks are marked by \c `#ifdef HAVE_DIAGNOSTIC` or +\c EXTRA_DIAGNOSTICS_ENABLED blocks. Similar to assertions these checks are enabled either +by running WiredTiger in diagnostic mode or by setting \c extra_diagnostics on the \c WT_CONNECTION. + +<table> +@hrow{Check, Behavior in diagnostic mode, Behavior in release mode} +@row{\c `#ifdef HAVE_DIAGNOSTIC`, Always run the code block, Never run the code block.} +@row{\c EXTRA_DIAGNOSTICS_ENABLED, Always run the code block, + Takes a \c WT_DIAGNOSTIC_* category as an argument and only runs when the category + is enabled on the \c WT_CONNECTION.} +</table> + +@section diagnostic_categories Diagnostic Categories + +Diagnostic checks across WiredTiger are grouped into categories that get enabled/disabled together. +The following diagnostic categories (\c WT_DIAGNOSTIC_*) are defined: + +<table> +@hrow{Category, Description} +@row{\c WT_DIAGNOSTIC_ALL, Enable all diagnostic categories.} +@row{\c WT_DIAGNOSTIC_CHECKPOINT_VALIDATE, Verify data integrity of checkpoints.} +@row{\c WT_DIAGNOSTIC_CURSOR_CHECK, Verify expected outcome of cursor operation.} +@row{\c WT_DIAGNOSTIC_DISK_VALIDATE, Validate correctness of data written to and read from disk.} +@row{\c WT_DIAGNOSTIC_EVICTION_CHECK, Ensure correct page state when performing eviction. } +@row{\c WT_DIAGNOSTIC_GENERATION_CHECK, Check correctness of generation logic.} +@row{\c WT_DIAGNOSTIC_HS_VALIDATE, Ensure correctness of records in the history store and data fetched from it.} +@row{\c WT_DIAGNOSTIC_KEY_OUT_OF_ORDER, Verify correct ordering of keys in the btree.} +@row{\c WT_DIAGNOSTIC_LOG_VALIDATE, Verify correctness of the Write Ahead Log.} +@row{\c WT_DIAGNOSTIC_PREPARED, Ensure correct behavior of prepared transactions.} +@row{\c WT_DIAGNOSTIC_SLOW_OPERATION, Identify and abort on slow operations in WiredTiger.} +@row{\c WT_DIAGNOSTIC_TXN_VISIBILITY, Verify correct visibility of transactional data.} +</table> + +@subsection extra_diagnostics_configuration Configuring runtime diagnostics + +Enabling assertions and diagnostic code blocks at runtime is controlled by the \c extra_diagnostics +configuration option when opening (::wiredtiger_open) or re-configuring (WT_CONNECTION::reconfigure) +a wiredtiger connection. The \c extra_diagnostics configuration takes in a list of categories. Any category provided in the list is enabled and any category not provided is disabled. +For example: + +@snippet ex_extra_diagnostics.c Configure extra_diagnostics + +*/ diff --git a/src/third_party/wiredtiger/src/docs/programming.dox b/src/third_party/wiredtiger/src/docs/programming.dox index 0e23ce2bf18..14bbda27495 100644 --- a/src/third_party/wiredtiger/src/docs/programming.dox +++ b/src/third_party/wiredtiger/src/docs/programming.dox @@ -40,6 +40,7 @@ each of which is ordered by one or more columns. <h2>Programming notes</h2> - @subpage message_handling - @subpage verbose_messaging +- @subpage debugging - @subpage threads - @subpage namespace - @subpage readonly diff --git a/src/third_party/wiredtiger/src/docs/spell.ok b/src/third_party/wiredtiger/src/docs/spell.ok index c690f9e9f04..c129ee55435 100644 --- a/src/third_party/wiredtiger/src/docs/spell.ok +++ b/src/third_party/wiredtiger/src/docs/spell.ok @@ -391,6 +391,7 @@ hugepage iSi icount ie +ifdef iflag incr indices diff --git a/src/third_party/wiredtiger/src/history/hs_rec.c b/src/third_party/wiredtiger/src/history/hs_rec.c index 4bf502425d9..d3800e46b8d 100644 --- a/src/third_party/wiredtiger/src/history/hs_rec.c +++ b/src/third_party/wiredtiger/src/history/hs_rec.c @@ -135,7 +135,7 @@ __hs_insert_record(WT_SESSION_IMPL *session, WT_CURSOR *cursor, WT_BTREE *btree, if (ret == 0) { WT_ERR(cursor->get_key(cursor, &hs_btree_id, hs_key, &hs_start_ts, &hs_counter)); - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER | WT_DIAG_VISIBILITY)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_HS_VALIDATE)) { /* Allocate buffer for the existing history store value for the same key. */ WT_ERR(__wt_scr_alloc(session, 0, &existing_val)); @@ -1113,7 +1113,7 @@ __hs_delete_record( * the update chain, then delete it from the history store. These checks ensure we've * retrieved the correct update from the history store. */ - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_VISIBILITY)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_HS_VALIDATE)) { __wt_hs_upd_time_window(r->hs_cursor, &hs_tw); WT_ASSERT_ALWAYS(session, hs_tw->start_txn == WT_TXN_NONE || hs_tw->start_txn == upd->txnid, diff --git a/src/third_party/wiredtiger/src/include/connection.h b/src/third_party/wiredtiger/src/include/connection.h index 6b4ead2bd2c..959448554c2 100644 --- a/src/third_party/wiredtiger/src/include/connection.h +++ b/src/third_party/wiredtiger/src/include/connection.h @@ -588,14 +588,18 @@ struct __wt_connection_impl { uint16_t debug_flags; /* AUTOMATIC FLAG VALUE GENERATION START 0 */ -#define WT_DIAG_ALL 0x01u -#define WT_DIAG_CONCURRENT_ACCESS 0x02u -#define WT_DIAG_DATA_VALIDATION 0x04u -#define WT_DIAG_INVALID_OP 0x08u -#define WT_DIAG_OUT_OF_ORDER 0x10u -#define WT_DIAG_PANIC 0x20u -#define WT_DIAG_SLOW_OPERATION 0x40u -#define WT_DIAG_VISIBILITY 0x80u +#define WT_DIAGNOSTIC_ALL 0x001u +#define WT_DIAGNOSTIC_CHECKPOINT_VALIDATE 0x002u +#define WT_DIAGNOSTIC_CURSOR_CHECK 0x004u +#define WT_DIAGNOSTIC_DISK_VALIDATE 0x008u +#define WT_DIAGNOSTIC_EVICTION_CHECK 0x010u +#define WT_DIAGNOSTIC_GENERATION_CHECK 0x020u +#define WT_DIAGNOSTIC_HS_VALIDATE 0x040u +#define WT_DIAGNOSTIC_KEY_OUT_OF_ORDER 0x080u +#define WT_DIAGNOSTIC_LOG_VALIDATE 0x100u +#define WT_DIAGNOSTIC_PREPARED 0x200u +#define WT_DIAGNOSTIC_SLOW_OPERATION 0x400u +#define WT_DIAGNOSTIC_TXN_VISIBILITY 0x800u /* AUTOMATIC FLAG VALUE GENERATION STOP 16 */ /* Categories of assertions that can be runtime enabled. */ uint16_t extra_diagnostics_flags; diff --git a/src/third_party/wiredtiger/src/include/error.h b/src/third_party/wiredtiger/src/include/error.h index 49adbe4c9e5..7e510a01f4c 100644 --- a/src/third_party/wiredtiger/src/include/error.h +++ b/src/third_party/wiredtiger/src/include/error.h @@ -175,12 +175,12 @@ /* * EXTRA_DIAGNOSTICS_ENABLED -- * Fetch whether diagnostic asserts for the provided category are runtime enabled. - * When compiled with HAVE_DIAGNOSTIC=1, the WT_DIAG_ALL category is always set on + * When compiled with HAVE_DIAGNOSTIC=1, the WT_DIAGNOSTIC_ALL category is always set on * the connection and this function will always return true for non-null sessions. */ #define EXTRA_DIAGNOSTICS_ENABLED(session, category) \ ((session != NULL) && \ - UNLIKELY(FLD_ISSET(S2C(session)->extra_diagnostics_flags, category | WT_DIAG_ALL))) + UNLIKELY(FLD_ISSET(S2C(session)->extra_diagnostics_flags, category | WT_DIAGNOSTIC_ALL))) /* * WT_ASSERT -- diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in index abc5ebe4953..194f685854c 100644 --- a/src/third_party/wiredtiger/src/include/wiredtiger.in +++ b/src/third_party/wiredtiger/src/include/wiredtiger.in @@ -2351,8 +2351,10 @@ struct __wt_connection { * <code>"extra_diagnostics=[out_of_order\,visibility]"</code>. Choosing \c all enables all * assertions. When WiredTiger is compiled with \c HAVE_DIAGNOSTIC=1 all assertions are * enabled and cannot be reconfigured., a list\, with values chosen from the following - * options: \c "all"\, \c "concurrent_access"\, \c "data_validation"\, \c "invalid_op"\, \c - * "out_of_order"\, \c "panic"\, \c "slow_operation"\, \c "visibility"; default \c [].} + * options: \c "all"\, \c "checkpoint_validate"\, \c "cursor_check"\, \c "disk_validate"\, + * \c "eviction_check"\, \c "generation_check"\, \c "hs_validate"\, \c "key_out_of_order"\, + * \c "log_validate"\, \c "prepared"\, \c "slow_operation"\, \c "txn_visibility"; default \c + * [].} * @config{file_manager = (, control how file handles are managed., a set of related * configuration options defined as follows.} * @config{ @@ -3123,8 +3125,9 @@ struct __wt_connection { * <code>"extra_diagnostics=[out_of_order\,visibility]"</code>. Choosing \c all enables all * assertions. When WiredTiger is compiled with \c HAVE_DIAGNOSTIC=1 all assertions are enabled and * cannot be reconfigured., a list\, with values chosen from the following options: \c "all"\, \c - * "concurrent_access"\, \c "data_validation"\, \c "invalid_op"\, \c "out_of_order"\, \c "panic"\, - * \c "slow_operation"\, \c "visibility"; default \c [].} + * "checkpoint_validate"\, \c "cursor_check"\, \c "disk_validate"\, \c "eviction_check"\, \c + * "generation_check"\, \c "hs_validate"\, \c "key_out_of_order"\, \c "log_validate"\, \c + * "prepared"\, \c "slow_operation"\, \c "txn_visibility"; default \c [].} * @config{file_extend, file size extension configuration. If set\, extend files of the given type * in allocations of the given size\, instead of a block at a time as each new block is written. * For example\, <code>file_extend=(data=16MB)</code>. If set to 0\, disable file size extension for diff --git a/src/third_party/wiredtiger/src/log/log_slot.c b/src/third_party/wiredtiger/src/log/log_slot.c index 5f32df4f172..24742599135 100644 --- a/src/third_party/wiredtiger/src/log/log_slot.c +++ b/src/third_party/wiredtiger/src/log/log_slot.c @@ -154,7 +154,7 @@ retry: while (slot->slot_unbuffered == 0) { WT_STAT_CONN_INCR(session, log_slot_close_unbuf); __wt_yield(); - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_SLOW_OPERATION)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_SLOW_OPERATION)) { ++count; if (count > WT_MILLION) { time_stop = __wt_clock(session); diff --git a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c index e54467c0f32..e2a2a6888e7 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c @@ -214,7 +214,7 @@ __clsm_enter(WT_CURSOR_LSM *clsm, bool reset, bool update) switch_txn = clsm->chunks[i]->switch_txn; if (WT_TXNID_LT(switch_txn, pinned_id)) break; - WT_ASSERT_OPTIONAL(session, WT_DIAG_VISIBILITY, + WT_ASSERT_OPTIONAL(session, WT_DIAGNOSTIC_TXN_VISIBILITY, !__wt_txn_visible_all(session, switch_txn, WT_TS_NONE), "Switch transaction is not globally visible"); } @@ -665,7 +665,7 @@ retry: clsm->dsk_gen = lsm_tree->dsk_gen; err: - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_CURSOR_CHECK)) { /* Check that all cursors are open as expected. */ if (ret == 0 && F_ISSET(clsm, WT_CLSM_OPEN_READ)) { for (i = 0; i != clsm->nchunks; i++) { diff --git a/src/third_party/wiredtiger/src/meta/meta_ckpt.c b/src/third_party/wiredtiger/src/meta/meta_ckpt.c index 5161da537f0..6d736b27216 100644 --- a/src/third_party/wiredtiger/src/meta/meta_ckpt.c +++ b/src/third_party/wiredtiger/src/meta/meta_ckpt.c @@ -827,7 +827,7 @@ __wt_meta_ckptlist_get( session, ckptbasep, &btree->ckpt_bytes_allocated, NULL)); if (allocated != NULL) *allocated = btree->ckpt_bytes_allocated; - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_CHECKPOINT_VALIDATE)) { /* * Sanity check: Let's compare to a list generated from metadata. There should be no * differences. diff --git a/src/third_party/wiredtiger/src/reconcile/rec_child.c b/src/third_party/wiredtiger/src/reconcile/rec_child.c index 2a2d7f2db1e..9d71ffd3c11 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_child.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_child.c @@ -242,7 +242,7 @@ __wt_rec_child_modify( * We should never be here during eviction, active child pages in an evicted page's * subtree fails the eviction attempt. */ - WT_RET_ASSERT(session, WT_DIAG_CONCURRENT_ACCESS, !F_ISSET(r, WT_REC_EVICT), EBUSY, + WT_RET_ASSERT(session, WT_DIAGNOSTIC_EVICTION_CHECK, !F_ISSET(r, WT_REC_EVICT), EBUSY, "unexpected WT_REF_LOCKED child state during eviction reconciliation"); /* If the page is being read from disk, it's not modified by definition. */ @@ -265,7 +265,7 @@ __wt_rec_child_modify( * We should never be here during eviction, active child pages in an evicted page's * subtree fails the eviction attempt. */ - WT_RET_ASSERT(session, WT_DIAG_CONCURRENT_ACCESS, !F_ISSET(r, WT_REC_EVICT), EBUSY, + WT_RET_ASSERT(session, WT_DIAGNOSTIC_EVICTION_CHECK, !F_ISSET(r, WT_REC_EVICT), EBUSY, "unexpected WT_REF_MEM child state during eviction reconciliation"); /* @@ -369,7 +369,7 @@ __wt_rec_child_modify( * checkpoint, all splits in process will have completed before we walk any pages for * checkpoint. */ - WT_RET_ASSERT(session, WT_DIAG_CONCURRENT_ACCESS, false, EBUSY, + WT_RET_ASSERT(session, WT_DIAGNOSTIC_EVICTION_CHECK, false, EBUSY, "unexpected WT_REF_SPLIT child state during reconciliation"); /* NOTREACHED */ return (EBUSY); diff --git a/src/third_party/wiredtiger/src/reconcile/rec_write.c b/src/third_party/wiredtiger/src/reconcile/rec_write.c index e6380d7e0eb..a2a3820b2ae 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_write.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_write.c @@ -839,7 +839,7 @@ __rec_write(WT_SESSION_IMPL *session, WT_ITEM *buf, uint8_t *addr, size_t *addr_ btree = S2BT(session); result_len = 0; - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_DISK_VALIDATE)) { /* Checkpoint calls are different than standard calls. */ WT_ASSERT_ALWAYS(session, (!checkpoint && addr != NULL && addr_sizep != NULL) || diff --git a/src/third_party/wiredtiger/src/support/err.c b/src/third_party/wiredtiger/src/support/err.c index 57ce29339fe..ea33983bd49 100644 --- a/src/third_party/wiredtiger/src/support/err.c +++ b/src/third_party/wiredtiger/src/support/err.c @@ -554,21 +554,21 @@ __wt_panic_func(WT_SESSION_IMPL *session, int error, const char *func, int line, WT_PANIC, func, line, category, WT_VERBOSE_ERROR, "the process must exit and restart", ap)); va_end(ap); - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_PANIC)) { - /* - * In the diagnostic builds, we want to drop core in case of panics that are not due to data - * corruption. A core could be useful in debugging. - * - * In the case of corruption, we want to be able to test the application's capability to - * salvage by returning an error code. But we do not want to lose the ability to drop core - * if required. Hence in the diagnostic mode, the application can set the debug flag to - * choose between dropping a core and returning an error. - */ - if (conn != NULL && - (!F_ISSET(conn, WT_CONN_DATA_CORRUPTION) || - FLD_ISSET(conn->debug_flags, WT_CONN_DEBUG_CORRUPTION_ABORT))) - __wt_abort(session); - } +#ifdef HAVE_DIAGNOSTIC + /* + * In the diagnostic builds, we want to drop core in case of panics that are not due to data + * corruption. A core could be useful in debugging. + * + * In the case of corruption, we want to be able to test the application's capability to salvage + * by returning an error code. But we do not want to lose the ability to drop core if required. + * Hence in the diagnostic mode, the application can set the debug flag to choose between + * dropping a core and returning an error. + */ + if (conn != NULL && + (!F_ISSET(conn, WT_CONN_DATA_CORRUPTION) || + FLD_ISSET(conn->debug_flags, WT_CONN_DEBUG_CORRUPTION_ABORT))) + __wt_abort(session); +#endif /* * When unit testing assertions we want to be able to fire them and continue running the test, but diff --git a/src/third_party/wiredtiger/src/support/generation.c b/src/third_party/wiredtiger/src/support/generation.c index 44a5256f12b..40d9771a840 100644 --- a/src/third_party/wiredtiger/src/support/generation.c +++ b/src/third_party/wiredtiger/src/support/generation.c @@ -260,8 +260,8 @@ __wt_gen_active(WT_SESSION_IMPL *session, int which, uint64_t generation) return (true); } - WT_ASSERT_OPTIONAL(session, WT_DIAG_VISIBILITY, generation < __gen_oldest(session, which), - "Generation is older than gen_oldest"); + WT_ASSERT_OPTIONAL(session, WT_DIAGNOSTIC_GENERATION_CHECK, + generation < __gen_oldest(session, which), "Generation is older than gen_oldest"); return (false); } diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c index db48ca8e045..b818be071f3 100644 --- a/src/third_party/wiredtiger/src/txn/txn.c +++ b/src/third_party/wiredtiger/src/txn/txn.c @@ -124,7 +124,7 @@ __wt_txn_release_snapshot(WT_SESSION_IMPL *session) txn_global = &S2C(session)->txn_global; txn_shared = WT_SESSION_TXN_SHARED(session); - WT_ASSERT_OPTIONAL(session, WT_DIAG_VISIBILITY, + WT_ASSERT_OPTIONAL(session, WT_DIAGNOSTIC_TXN_VISIBILITY, txn_shared->pinned_id == WT_TXN_NONE || session->txn->isolation == WT_ISO_READ_UNCOMMITTED || !__wt_txn_visible_all(session, txn_shared->pinned_id, WT_TS_NONE), "A transactions pinned id cannot become globally visible before its snapshot is released"); @@ -1042,8 +1042,8 @@ __txn_search_prepared_op( case WT_TXN_OP_REF_DELETE: case WT_TXN_OP_TRUNCATE_COL: case WT_TXN_OP_TRUNCATE_ROW: - WT_RET_PANIC_ASSERT( - session, WT_DIAG_INVALID_OP, false, WT_PANIC, "invalid prepared operation update type"); + WT_RET_PANIC_ASSERT(session, WT_DIAGNOSTIC_PREPARED, false, WT_PANIC, + "invalid prepared operation update type"); break; } @@ -1052,7 +1052,7 @@ __txn_search_prepared_op( F_SET(txn, txn_flags); F_CLR(txn, WT_TXN_PREPARE_IGNORE_API_CHECK); WT_RET(ret); - WT_RET_ASSERT(session, WT_DIAG_INVALID_OP, *updp != NULL, WT_NOTFOUND, + WT_RET_ASSERT(session, WT_DIAGNOSTIC_PREPARED, *updp != NULL, WT_NOTFOUND, "unable to locate update associated with a prepared operation"); return (0); @@ -1433,7 +1433,7 @@ __txn_resolve_prepared_op(WT_SESSION_IMPL *session, WT_TXN_OP *op, bool commit, WT_ERR(__txn_fixup_hs_update(session, hs_cursor)); prepare_verify: - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_PREPARED)) { for (; head_upd != NULL; head_upd = head_upd->next) { /* * Assert if we still have an update from the current transaction that hasn't been diff --git a/src/third_party/wiredtiger/src/txn/txn_log.c b/src/third_party/wiredtiger/src/txn/txn_log.c index 95de25ca4e3..0f3be66851c 100644 --- a/src/third_party/wiredtiger/src/txn/txn_log.c +++ b/src/third_party/wiredtiger/src/txn/txn_log.c @@ -78,7 +78,7 @@ __txn_op_log( * operations, we shouldn't see them here. */ if (CUR2BT(cbt)->type == BTREE_ROW) { - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION)) + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_LOG_VALIDATE)) __txn_op_log_row_key_check(session, cbt); switch (upd->type) { diff --git a/src/third_party/wiredtiger/src/txn/txn_timestamp.c b/src/third_party/wiredtiger/src/txn/txn_timestamp.c index 2a099846c83..2f7871d007e 100644 --- a/src/third_party/wiredtiger/src/txn/txn_timestamp.c +++ b/src/third_party/wiredtiger/src/txn/txn_timestamp.c @@ -458,9 +458,8 @@ __txn_assert_after_reads(WT_SESSION_IMPL *session, const char *op, wt_timestamp_ uint32_t i, session_cnt; char ts_string[2][WT_TS_INT_STRING_SIZE]; - txn_global = &S2C(session)->txn_global; - - if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_VISIBILITY)) { + if (EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_TXN_VISIBILITY)) { + txn_global = &S2C(session)->txn_global; WT_ORDERED_READ(session_cnt, S2C(session)->session_cnt); WT_STAT_CONN_INCR(session, txn_walk_sessions); WT_STAT_CONN_INCRV(session, txn_sessions_walked, session_cnt); @@ -485,6 +484,7 @@ __txn_assert_after_reads(WT_SESSION_IMPL *session, const char *op, wt_timestamp_ WT_UNUSED(session); WT_UNUSED(op); WT_UNUSED(ts); + WT_UNUSED(txn_global); } } diff --git a/src/third_party/wiredtiger/test/unittest/tests/test_assertions.cpp b/src/third_party/wiredtiger/test/unittest/tests/test_assertions.cpp index dea57314e4e..7b2e511eaeb 100644 --- a/src/third_party/wiredtiger/test/unittest/tests/test_assertions.cpp +++ b/src/third_party/wiredtiger/test/unittest/tests/test_assertions.cpp @@ -31,6 +31,12 @@ #define NO_ASSERT_FIRED 0 #define ASSERT_FIRED 1 +uint16_t DIAGNOSTIC_FLAGS[] = {WT_DIAGNOSTIC_ALL, WT_DIAGNOSTIC_CHECKPOINT_VALIDATE, + WT_DIAGNOSTIC_CURSOR_CHECK, WT_DIAGNOSTIC_DISK_VALIDATE, WT_DIAGNOSTIC_EVICTION_CHECK, + WT_DIAGNOSTIC_GENERATION_CHECK, WT_DIAGNOSTIC_HS_VALIDATE, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER, + WT_DIAGNOSTIC_LOG_VALIDATE, WT_DIAGNOSTIC_PREPARED, WT_DIAGNOSTIC_SLOW_OPERATION, + WT_DIAGNOSTIC_TXN_VISIBILITY}; + int check_assertion_fired(WT_SESSION_IMPL *session) { @@ -108,26 +114,18 @@ call_wt_optional(WT_SESSION_IMPL *session, uint16_t category, bool assert_should void all_diag_asserts_off(WT_SESSION_IMPL *session) { - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_INVALID_OP) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_PANIC) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_CONCURRENT_ACCESS) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_SLOW_OPERATION) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_VISIBILITY) == false); + for (uint16_t flag : DIAGNOSTIC_FLAGS) { + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, flag) == false); + } } /* Assert that all diagnostic assert categories are on. */ void all_diag_asserts_on(WT_SESSION_IMPL *session) { - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_INVALID_OP) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_PANIC) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_CONCURRENT_ACCESS) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_SLOW_OPERATION) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_VISIBILITY) == true); + for (uint16_t flag : DIAGNOSTIC_FLAGS) { + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, flag) == true); + } } /* Assert that all expected asserts (passed in via the "category" arg) fire. */ @@ -223,13 +221,13 @@ TEST_CASE("Connection config: off/on", "[assertions]") } } -/* When WT_DIAG_ALL is enabled, all asserts are enabled. */ -TEST_CASE("Connection config: WT_DIAG_ALL", "[assertions]") +/* When WT_DIAGNOSTIC_ALL is enabled, all asserts are enabled. */ +TEST_CASE("Connection config: WT_DIAGNOSTIC_ALL", "[assertions]") { ConnectionWrapper conn(DB_HOME, "create, extra_diagnostics= [all]"); WT_SESSION_IMPL *session = conn.createSession(); - REQUIRE(configured_asserts_abort(session, WT_DIAG_ALL) == 0); + REQUIRE(configured_asserts_abort(session, WT_DIAGNOSTIC_ALL) == 0); all_diag_asserts_on(session); } @@ -237,35 +235,35 @@ TEST_CASE("Connection config: WT_DIAG_ALL", "[assertions]") /* When a category is enabled, all asserts for that category are enabled. */ TEST_CASE("Connection config: check one enabled category", "[assertions]") { - ConnectionWrapper conn(DB_HOME, "create, extra_diagnostics=[out_of_order]"); + ConnectionWrapper conn(DB_HOME, "create, extra_diagnostics=[key_out_of_order]"); WT_SESSION_IMPL *session = conn.createSession(); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER) == true); - REQUIRE(configured_asserts_abort(session, WT_DIAG_OUT_OF_ORDER) == 0); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER) == true); + REQUIRE(configured_asserts_abort(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER) == 0); } /* Asserts that categories are enabled/disabled following the connection configuration. */ TEST_CASE("Connection config: check multiple enabled categories", "[assertions]") { - ConnectionWrapper conn(DB_HOME, "create, extra_diagnostics= [visibility, concurrent_access]"); + ConnectionWrapper conn(DB_HOME, "create, extra_diagnostics= [txn_visibility, prepared]"); WT_SESSION_IMPL *session = conn.createSession(); - REQUIRE(configured_asserts_abort(session, WT_DIAG_VISIBILITY) == 0); + REQUIRE(configured_asserts_abort(session, WT_DIAGNOSTIC_TXN_VISIBILITY) == 0); // Checking state. - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_VISIBILITY) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_CONCURRENT_ACCESS) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_SLOW_OPERATION) == false); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_TXN_VISIBILITY) == true); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_PREPARED) == true); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_SLOW_OPERATION) == false); } /* Asserts that categories are enabled/disabled following the connection configuration. */ TEST_CASE("Connection config: check disabled category", "[assertions]") { - ConnectionWrapper conn(DB_HOME, "create, extra_diagnostics = [invalid_op]"); + ConnectionWrapper conn(DB_HOME, "create, extra_diagnostics = [eviction_check]"); WT_SESSION_IMPL *session = conn.createSession(); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_SLOW_OPERATION) == false); - REQUIRE(configured_asserts_off(session, WT_DIAG_SLOW_OPERATION) == 0); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_SLOW_OPERATION) == false); + REQUIRE(configured_asserts_off(session, WT_DIAGNOSTIC_SLOW_OPERATION) == 0); } /* Reconfigure with extra_diagnostics not provided. */ @@ -299,8 +297,8 @@ TEST_CASE("Reconfigure: extra_diagnostics with invalid item", "[assertions]") WT_SESSION_IMPL *session = conn.createSession(); all_diag_asserts_off(session); - REQUIRE( - connection->reconfigure(connection, "extra_diagnostics=[slow_operation, panic, INVALID]")); + REQUIRE(connection->reconfigure( + connection, "extra_diagnostics=[slow_operation, eviction_check, INVALID]")); all_diag_asserts_off(session); } @@ -311,36 +309,37 @@ TEST_CASE("Reconfigure: extra_diagnostics with valid items", "[assertions]") auto connection = conn.getWtConnection(); WT_SESSION_IMPL *session = conn.createSession(); - connection->reconfigure(connection, "extra_diagnostics=[data_validation, invalid_op, panic]"); - - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_INVALID_OP) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_PANIC) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_CONCURRENT_ACCESS) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_SLOW_OPERATION) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_VISIBILITY) == false); + connection->reconfigure( + connection, "extra_diagnostics=[checkpoint_validate, log_validate, eviction_check]"); + + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_CHECKPOINT_VALIDATE) == true); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_LOG_VALIDATE) == true); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_EVICTION_CHECK) == true); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_PREPARED) == false); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER) == false); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_SLOW_OPERATION) == false); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_TXN_VISIBILITY) == false); } /* Reconfigure with assertion categories changed from enabled->disabled and vice-versa. */ TEST_CASE("Reconfigure: Transition cases", "[assertions]") { - ConnectionWrapper conn(DB_HOME, "create, extra_diagnostics= [concurrent_access, out_of_order]"); + ConnectionWrapper conn(DB_HOME, "create, extra_diagnostics= [prepared, key_out_of_order]"); auto connection = conn.getWtConnection(); WT_SESSION_IMPL *session = conn.createSession(); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_CONCURRENT_ACCESS) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION) == false); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_PREPARED) == true); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER) == true); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_CHECKPOINT_VALIDATE) == false); connection->reconfigure( - connection, "extra_diagnostics=[data_validation, slow_operation, out_of_order]"); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_OUT_OF_ORDER) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_DATA_VALIDATION) == true); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_SLOW_OPERATION) == true); - - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_CONCURRENT_ACCESS) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_VISIBILITY) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_INVALID_OP) == false); - REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAG_PANIC) == false); + connection, "extra_diagnostics=[checkpoint_validate, key_out_of_order, slow_operation]"); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_KEY_OUT_OF_ORDER) == true); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_CHECKPOINT_VALIDATE) == true); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_SLOW_OPERATION) == true); + + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_PREPARED) == false); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_TXN_VISIBILITY) == false); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_LOG_VALIDATE) == false); + REQUIRE(EXTRA_DIAGNOSTICS_ENABLED(session, WT_DIAGNOSTIC_EVICTION_CHECK) == false); } |